Created
January 19, 2019 00:27
-
-
Save maxjing/7f17e3681e4d56b9ca8ef0f6f990ac88 to your computer and use it in GitHub Desktop.
javascript readline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const instream = fs.createReadStream( | |
path.join(__dirname, `../reports/trendData`, `${type}.json`) | |
); | |
const outstream = new stream(); | |
const rl = readline.createInterface(instream, outstream); | |
const labels = []; | |
rl.on("line", function(line) { | |
labels.push(line.slice(-19, -5)); | |
}); | |
const scores = require("../reports/trendData/data/scores.json"); | |
rl.on("close", function() { | |
res.json({ id: type, labels: labels, scores: scores }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment