You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.2 KiB
JavaScript

5 months ago
"use strict";
const pipe = require("@promistream/pipe");
const fromIterable = require("@promistream/from-iterable");
const collect = require("@promistream/collect");
const debug = require("./");
(async function () {
let result = await pipe([
fromIterable([ 1, 2, 3, 4, 5 ]),
debug("example pipeline"),
collect()
]).read();
console.log(result);
})();
/* Output:
[@promistream/debug][example pipeline] read was requested
[@promistream/debug][example pipeline] seen value: 1
[@promistream/debug][example pipeline] read was requested
[@promistream/debug][example pipeline] seen value: 2
[@promistream/debug][example pipeline] read was requested
[@promistream/debug][example pipeline] seen value: 3
[@promistream/debug][example pipeline] read was requested
[@promistream/debug][example pipeline] seen value: 4
[@promistream/debug][example pipeline] read was requested
[@promistream/debug][example pipeline] seen value: 5
[@promistream/debug][example pipeline] read was requested
[@promistream/debug][example pipeline] error thrown in read: EndOfStream: End of iterable reached
at <stacktrace goes here>
_help: 'https://www.npmjs.com/package/error-chain',
_promistreamIsEndOfStreamMarker: true,
_promistreamVersion: 1
}
[ 1, 2, 3, 4, 5 ]
*/