ran the linter

This commit is contained in:
j83305 2020-06-02 11:27:29 +01:00
parent 44cf916f43
commit b842a38c84
2 changed files with 34 additions and 20 deletions

View file

@ -9,6 +9,11 @@
import OperationError from "../errors/OperationError.mjs";
/**
* Function to take the user input and encode using the given arguments
* @param input string of binary
* @param args array
*/
export function calculateParityBit(input, args) {
let count1s = 0;
for (let i = 0; i < input.length; i++) {
@ -31,7 +36,11 @@ export function calculateParityBit(input, args) {
}
}
// just removes the parity bit to return the original data
/**
* just removes the parity bit to return the original data
* @param input string of binary, encoded
* @param args array
*/
export function decodeParityBit(input, args) {
if (args[1] === "End") {
return input.slice(0, -1);

View file

@ -66,13 +66,18 @@ class ParityBit extends Operation {
if (input.length === 0) {
return input;
}
/**
* determines weather to use the encode or decode method based off args[2]
* @param input input to be encoded or decoded
* @param args array
*/
const method = (input, args) => args[2] === "Encode" ? calculateParityBit(input, args) : decodeParityBit(input, args);
if (args[3].length > 0) {
let byteStrings = input.split(args[3]);
const byteStrings = input.split(args[3]);
for (let byteStringsArrayIndex = 0; byteStringsArrayIndex < byteStrings.length; byteStringsArrayIndex++) {
byteStrings[byteStringsArrayIndex] = method(byteStrings[byteStringsArrayIndex], args);
}
return byteStrings.join(args[3])
return byteStrings.join(args[3]);
}
return method(input, args);
}