1
0
forked from kalmar/DALGLI0
DALGLI0/03-rozwiazanie.js
2018-07-01 15:14:54 +02:00

19 lines
408 B
JavaScript

const crc = require("./crc.js");
let message = process.argv[3];
let flag = process.argv[2];
switch (flag) {
case '-e':
console.log(crc.encode(message).encoded);
break;
case '-d':
let fcs = JSON.parse(process.argv[4].replace(/'/g, '"'));
console.log(crc.decode(message, fcs));
break;
case '-t':
break;
default:
throw "incorect flag"
}