Skip to content

Instantly share code, notes, and snippets.

@sorsaffari
Last active September 14, 2018 11:03
Show Gist options
  • Save sorsaffari/9c00cf619d6fabff3964a99bbdd659da to your computer and use it in GitHub Desktop.
Save sorsaffari/9c00cf619d6fabff3964a99bbdd659da to your computer and use it in GitHub Desktop.
Phone Calls | Loading Data: processing JSON
function parseDataToObjects(input) {
const items = [];
return new Promise(function(resolve, reject) {
const pipeline = chain([
fs.createReadStream(input.dataPath + ".json"),
parser(),
streamArray()
]);
pipeline.on("data", function(result) {
items.push(result.value);
});
pipeline.on("end", function() {
resolve(items);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment