From fad4713a90d52b541ac6b2e5e2e25aabcc16083f Mon Sep 17 00:00:00 2001 From: n1474335 Date: Fri, 6 Apr 2018 12:40:39 +0000 Subject: [PATCH] ESM: Tidied up Rotate operations --- src/core/lib/Rotate.mjs | 9 --------- src/core/operations/ROT13.mjs | 15 ++++----------- src/core/operations/ROT47.mjs | 9 ++------- src/core/operations/RotateLeft.mjs | 9 +++++---- src/core/operations/RotateRight.mjs | 9 +++++---- test/tests/operations/Rotate.mjs | 3 ++- 6 files changed, 18 insertions(+), 36 deletions(-) diff --git a/src/core/lib/Rotate.mjs b/src/core/lib/Rotate.mjs index 97c4b1df..8d70fb25 100644 --- a/src/core/lib/Rotate.mjs +++ b/src/core/lib/Rotate.mjs @@ -9,13 +9,6 @@ */ -/** - * Default values for rotation operations - */ -export const ROTATE_AMOUNT = 1; -export const ROTATE_CARRY = false; - - /** * Runs rotation operations across the input data. * @@ -64,7 +57,6 @@ export function rotl(b) { * Rotates a byte array to the right by a specific amount as a whole, so that bits are wrapped * from the end of the array to the beginning. * - * @private * @param {byteArray} data * @param {number} amount * @returns {byteArray} @@ -90,7 +82,6 @@ export function rotrCarry(data, amount) { * Rotates a byte array to the left by a specific amount as a whole, so that bits are wrapped * from the beginning of the array to the end. * - * @private * @param {byteArray} data * @param {number} amount * @returns {byteArray} diff --git a/src/core/operations/ROT13.mjs b/src/core/operations/ROT13.mjs index 3bac332a..d3e4e75a 100644 --- a/src/core/operations/ROT13.mjs +++ b/src/core/operations/ROT13.mjs @@ -6,13 +6,6 @@ import Operation from "../Operation"; -/** - * Default arguments for ROT13 operation - */ -const ROT13_AMOUNT = 13, - ROT13_LOWERCASE = true, - ROT13_UPPERCASE = true; - /** * ROT13 operation. @@ -34,23 +27,23 @@ class ROT13 extends Operation { { name: "Rotate lower case chars", type: "boolean", - value: ROT13_LOWERCASE + value: true }, { name: "Rotate upper case chars", type: "boolean", - value: ROT13_UPPERCASE + value: true }, { name: "Amount", type: "number", - value: ROT13_AMOUNT + value: 13 }, ]; } /** - * @param {string} input + * @param {byteArray} input * @param {Object[]} args * @returns {byteArray} */ diff --git a/src/core/operations/ROT47.mjs b/src/core/operations/ROT47.mjs index 0421438b..e0722670 100644 --- a/src/core/operations/ROT47.mjs +++ b/src/core/operations/ROT47.mjs @@ -6,11 +6,6 @@ import Operation from "../Operation"; -/** - * Default argument for ROT47 operation - */ -const ROT47_AMOUNT = 47; - /** * ROT47 operation. @@ -32,13 +27,13 @@ class ROT47 extends Operation { { name: "Amount", type: "number", - value: ROT47_AMOUNT + value: 47 }, ]; } /** - * @param {string} input + * @param {byteArray} input * @param {Object[]} args * @returns {byteArray} */ diff --git a/src/core/operations/RotateLeft.mjs b/src/core/operations/RotateLeft.mjs index 84a14565..d21e0def 100644 --- a/src/core/operations/RotateLeft.mjs +++ b/src/core/operations/RotateLeft.mjs @@ -5,7 +5,8 @@ */ import Operation from "../Operation"; -import { rot, rotl, rotlCarry, ROTATE_AMOUNT, ROTATE_CARRY } from "../lib/Rotate"; +import {rot, rotl, rotlCarry} from "../lib/Rotate"; + /** * Rotate left operation. @@ -27,18 +28,18 @@ class RotateLeft extends Operation { { name: "Amount", type: "number", - value: ROTATE_AMOUNT + value: 1 }, { name: "Carry through", type: "boolean", - value: ROTATE_CARRY + value: false } ]; } /** - * @param {string} input + * @param {byteArray} input * @param {Object[]} args * @returns {byteArray} */ diff --git a/src/core/operations/RotateRight.mjs b/src/core/operations/RotateRight.mjs index 2018c6fc..f4a35cb6 100644 --- a/src/core/operations/RotateRight.mjs +++ b/src/core/operations/RotateRight.mjs @@ -5,7 +5,8 @@ */ import Operation from "../Operation"; -import { rot, rotr, rotrCarry, ROTATE_AMOUNT, ROTATE_CARRY } from "../lib/Rotate"; +import {rot, rotr, rotrCarry} from "../lib/Rotate"; + /** * Rotate right operation. @@ -27,18 +28,18 @@ class RotateRight extends Operation { { name: "Amount", type: "number", - value: ROTATE_AMOUNT + value: 1 }, { name: "Carry through", type: "boolean", - value: ROTATE_CARRY + value: false } ]; } /** - * @param {string} input + * @param {byteArray} input * @param {Object[]} args * @returns {byteArray} */ diff --git a/test/tests/operations/Rotate.mjs b/test/tests/operations/Rotate.mjs index e48373d4..d7ba9af1 100644 --- a/test/tests/operations/Rotate.mjs +++ b/test/tests/operations/Rotate.mjs @@ -1,5 +1,5 @@ /** - * Base64 tests. + * Rotate tests. * * @author Matt C [matt@artemisbot.uk] * @@ -8,6 +8,7 @@ */ import TestRegister from "../../TestRegister"; + TestRegister.addTests([ { name: "Rotate left: nothing",