"use strict"; const Promise = require("bluebird"); const simpleSource = require("./"); const collect = require("@ppstreams/collect"); // FIXME: add devdep const pipe = require("@ppstreams/pipe"); const EndOfStream = require("@ppstreams/end-of-stream"); function generateNumbers() { let i = 0; let max = 10; return simpleSource({ onRequest: () => { if (i < max) { i += 1; return i; } else { throw new EndOfStream(); } }}); } return Promise.try(() => { return pipe([ generateNumbers(), collect() ]).read(); }).then((result) => { console.log(result); });