-
Notifications
You must be signed in to change notification settings - Fork 0
/
parseConfig.js
36 lines (34 loc) · 1.02 KB
/
parseConfig.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const caesarCipherCodeStream = require("./caesarCipherCodeStream");
const caesarCipherDecodeStream = require("./caesarCipherDecodeStream");
const rot8CodeStream = require("./rot8CodeStream");
const rot8DecodeStream = require("./rot8DecodeStream");
const atbashCodeStream = require("./atbashCodeStream");
function parseConfig(config) {
const streams = [];
const actions = config.split("-");
for (let action of actions) {
switch (action) {
case "C0":
streams.push(new caesarCipherDecodeStream());
break;
case "C1":
streams.push(new caesarCipherCodeStream());
break;
case "A":
case "A0":
case "A1":
streams.push(new atbashCodeStream());
break;
case "R0":
streams.push(new rot8DecodeStream());
break;
case "R1":
streams.push(new rot8CodeStream());
break;
default:
throw new Error("Неверный конфиг. Получено: " + action);
}
}
return streams;
}
module.exports = parseConfig;