mirror of
https://github.com/gnh1201/welsonjs.git
synced 2024-11-26 15:31:42 +00:00
34 lines
1.0 KiB
JavaScript
34 lines
1.0 KiB
JavaScript
// a mafia style PIPE IPC based file I/O test
|
|
|
|
var FILE = require("lib/file");
|
|
|
|
var filename = "data\\dead_targets.txt";
|
|
|
|
function recordDead(name) {
|
|
FILE.rotateFile(filename, name + "\r\n", 1000, FILE.CdoCharset.CdoUTF_8);
|
|
}
|
|
|
|
function checkIsDead(name) {
|
|
var text = FILE.readFile(filename, FILE.CdoCharset.CdoUTF_8);
|
|
var deadNames = splitLn(text);
|
|
return deadNames.indexOf(name) > -1;
|
|
}
|
|
|
|
function main(args) {
|
|
while (true) {
|
|
recordDead("kim@example.org");
|
|
//recordDead("lee@example.org");
|
|
recordDead("park@example.org");
|
|
//recordDead("choi@example.org");
|
|
recordDead("hong@example.org");
|
|
|
|
console.log(checkIsDead("kim@example.org") ? "DEAD" : "ALIVE");
|
|
console.log(checkIsDead("lee@example.org") ? "DEAD" : "ALIVE");
|
|
console.log(checkIsDead("park@example.org") ? "DEAD" : "ALIVE");
|
|
console.log(checkIsDead("choi@example.org") ? "DEAD" : "ALIVE");
|
|
console.log(checkIsDead("hong@example.org") ? "DEAD" : "ALIVE");
|
|
}
|
|
}
|
|
|
|
exports.main = main;
|