Skip to content

Instantly share code, notes, and snippets.

@TobyEalden
Forked from iendjinn/stream.js
Last active May 17, 2017 10:40
Show Gist options
  • Save TobyEalden/f9219f0b00b9205d9acc8f66a0d3433c to your computer and use it in GitHub Desktop.
Save TobyEalden/f9219f0b00b9205d9acc8f66a0d3433c to your computer and use it in GitHub Desktop.
const databot = function(input, output, context) {
const api = context.tdxApi;
let x = 0;
const readStream = api.getNDDatasetData(
"HygXQFrwx-", // This contains nearly 6 million documents
null,
null,
{limit: 0}
);
const writeStream = split(JSON.parse, null, {trailing: true});
readStream.on("data", (data) => {
console.log(x);
x++;
});
writeStream.on("end", () => {
console.log("done");
})
readStream.on("error", (err) => {
console.log("read error %s",err.message);
});
writeStream.on("error", (err) => {
console.log("read error %s",err.message);
});
readStream.pipe(writeStream);
}
// output
...
498204
498205
498206
498207
498208
498209
498210
498211
498212
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment