Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const through2 = require("through2");
const byline = require("byline");
const turf = require("@turf/turf");
const OSRM = require("osrm");
const random = require("random");
const moment = require("moment");
const osrm = new OSRM("./data/nyc.osrm");
const DRIFT = 0.01;
const PERIOD = 20;
var normal = random.normal();
var k = 0;
process.stdin.pipe(byline.createStream()).pipe(
through2((chunk, enc, next) => {
k++;
if (k % 1000 === 0) console.error(k);
var line = chunk.toString();
if (line.length && k > 1) {
// skip header or trailing endline
var cell = line.split(",");
var record = {
timeA: moment(cell[1]),
timeB: moment(cell[2]),
ptA: [+cell[5], +cell[6]],
ptB: [+cell[9], +cell[10]]
};
async function run() {
let stream = fs.createReadStream('txt/millionsOfGuesses.txt');
stream.setEncoding('utf8');
// read the file stream a line at a time.
let lineStream = byline.createStream(stream, { keepEmptyLines: false });
// awaitable interface for reading the stream.
let reader = aw.createReader(lineStream);
// readline for prompting the user.
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
try {
let line;
while (null !== (line = await reader.readAsync())) {
let guessedCard = await checkGuess(rl, line);
if (guessedCard) {
exports.parserExecute = function (urls) {
if (urls && Array.isArray(urls)) {
var results = [];
for (var i = 0, l = urls.length; i < l; i++) {
results.push(parseUrl(urls[i]));
}
return results;
} else {
var stdin = process.stdin;
var stdout = process.stdout;
var stream = byline.createStream(stdin);
stream.on('end', function () {
process.exit(0);
});
stream.on('close', function () {
process.exit(0);
});
stream.on('data', function (line) {
stdout.write(JSON.stringify(parseUrl(line.toString())) + '\n');
});
}
};
.on('root',function(){
var rs = fs.createReadStream(npmfile);
rs.setEncoding('ascii')
var linestream = byline.createStream()
linestream.on('data', function(line){
try {
try {
var data = JSON.parse( cutcomma(line) )
}
catch(e){
console.log(e)
return
}
var v = data.value
var doc = {
name:v.name,
exports.parserExecute = function (urls) {
if (urls && Array.isArray(urls)) {
var results = [];
for (var i = 0, l = urls.length; i < l; i++) {
results.push(parseUrl(urls[i]));
}
return results;
} else {
var stdin = process.stdin;
var stdout = process.stdout;
var stream = byline.createStream(stdin);
stream.on('end', function () {
process.exit(0);
});
stream.on('close ', function () {
process.exit(0);
});
stream.on('data', function (line) {
stdout.write(JSON.stringify(parseUrl(line.toString())) + '\n');
});
}
};
exports.parserExecute = function (urls) {
if (urls && Array.isArray(urls)) {
var results = [];
for (var i = 0, l = urls.length; i < l; i++) {
results.push(parseUrl(urls[i]));
}
return results;
} else {
var stdin = process.stdin;
var stdout = process.stdout;
var stream = byline.createStream(stdin);
stream.on('end', function () {
process.exit(0);
});
stream.on('close ', function () {
process.exit(0);
});
stream.on('data', function (line) {
stdout.write(JSON.stringify(parseUrl(line.toString())) + '\n');
});
}
};
exports.parserExecute = function (urls) {
if (urls && Array.isArray(urls)) {
var results = [];
for (var i = 0, l = urls.length; i < l; i++) {
results.push(parseUrl(urls[i]));
}
return results;
} else {
var stdin = process.stdin;
var stdout = process.stdout;
var stream = byline.createStream(stdin);
stream.on('end', function () {
process.exit(0);
});
stream.on('close ', function () {
process.exit(0);
});
stream.on('data', function (line) {
stdout.write(JSON.stringify(parseUrl(line.toString())) + '\n');
});
}
};
exports.parserExecute = function (urls) {
if (urls && Array.isArray(urls)) {
var results = [];
for (var i = 0, l = urls.length; i < l; i++) {
results.push(parseUrl(urls[i]));
}
return results;
} else {
var stdin = process.stdin;
var stdout = process.stdout;
var stream = byline.createStream(stdin);
stream.on('end', function () {
process.exit(0);
});
stream.on('close ', function () {
process.exit(0);
});
stream.on('data', function (line) {
stdout.write(JSON.stringify(parseUrl(line.toString())) + '\n');
});
}
};
exports.parserExecute = function (urls) {
if (urls && Array.isArray(urls)) {
var results = [];
for (var i = 0, l = urls.length; i < l; i++) {
results.push(parseUrl(urls[i]));
}
return results;
} else {
var stdin = process.stdin;
var stdout = process.stdout;
var stream = byline.createStream(stdin);
stream.on('end', function () {
process.exit(0);
});
stream.on('close ', function () {
process.exit(0);
});
stream.on('data', function (line) {
stdout.write(JSON.stringify(parseUrl(line.toString())) + '\n');
});
}
};
_loadThesaurus(callback) {
logger.info("Loading the NCI Thesaurus...");
let header = [
"code", "concept_name", "parents", "synonyms",
"definition", "display_name", "semantic_types"
];
let delimiter = "\t";
let exclude = [
"definition", "semantic_types"
]
this.thesaurus = [];
let rs = fs.createReadStream(path.join(__dirname, THESAURUS_FILEPATH));
let ls = byline.createStream();
let cs = new CsvStream({header, delimiter, exclude});
rs.on("error", (err) => { logger.error(err); })
.pipe(ls)
.on("error", (err) => { logger.error(err); })
.pipe(cs)
.on("error", (err) => { logger.error(err); })
.on("data", (jsonRow) => {
this.thesaurus.push(jsonRow);
})
.on("finish", () => {
logger.info(`Loaded ${this.thesaurus.length} terms from the NCI Thesaurus.`);
return callback();
});
}