Converted substitute operation, added tests & moved to OperationError

This commit is contained in:
Matt C 2018-05-11 16:32:19 +01:00
parent 350d10d98b
commit 2d6a56343b
8 changed files with 125 additions and 12 deletions

View file

@ -6,6 +6,7 @@
* @license Apache-2.0
*
*/
import OperationError from "../errors/OperationError";
/**
* Affine Cipher Encode operation.
@ -22,7 +23,7 @@ export function affineEncode(input, args) {
let output = "";
if (!/^\+?(0|[1-9]\d*)$/.test(a) || !/^\+?(0|[1-9]\d*)$/.test(b)) {
return "The values of a and b can only be integers.";
throw new OperationError("The values of a and b can only be integers.");
}
for (let i = 0; i < input.length; i++) {