-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (31 loc) · 1.02 KB
/
index.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
37
38
39
const argv = require("minimist")(process.argv.slice(2), {
default: {
type: "file",
path: "itm.fifo",
host: "localhost",
port: 3344,
nomerge: false
},
});
console.dir(argv);
///////////////////////////////////////////////////////////////////////////////
const decoder = require("./source/itmdecoder");
const itmDecoder = new decoder(!argv.nomerge);
let itm_src;
if (argv.type == "file") {
let src = require("./source/srcfile");
itm_src = new src(argv.path);
} else if (argv.type == "pipe") {
let src = require("./source/srcfifo");
itm_src = new src(argv.path);
} else if (argv.type == "socket") {
let src = require("./source/srcsocket");
itm_src = new src(argv.host, argv.port);
}
itm_src.on("data", itmDecoder.decode.bind(itmDecoder));
itm_src.on("connected", () => console.log("connected"));
itm_src.on("disconnected", () => console.log("disconnected"));
itmDecoder.on("ev", (ev) =>
console.log(ev));
itmDecoder.on("error", (ev) =>
console.log("error", ev));