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.
Sven Slootweg 401abe9f06 | 5 months ago | |
---|---|---|
.gitignore | 5 months ago | |
README.md | 5 months ago | |
example.js | 5 months ago | |
index.js | 5 months ago | |
package.json | 5 months ago | |
pnpm-lock.yaml | 5 months ago | |
screenshot.png | 5 months ago |
README.md
@promistream/debug
A stream for debugging pipelines. Logs everything that goes through it, via console.debug
, and leaves it otherwise untouched.
Stream characteristics:
- Promistream version: 0
- Source stream: No
- Transform stream: Yes
- Sink stream: No
- Buffering: None
Possible errors thrown:
- None (other than those being passed through from upstream).
Example
This example is also included in the package in runnable form as example.js
.
"use strict";
const pipe = require("@promistream/pipe");
const fromIterable = require("@promistream/from-iterable");
const collect = require("@promistream/collect");
const debug = require("@promistream/debug");
(async function () {
let result = await pipe([
fromIterable([ 1, 2, 3, 4, 5 ]),
debug("example pipeline"),
collect()
]).read();
console.log(result);
})();
Example output (see the included screenshot.png for a colorized version):
[@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 /home/sven/projects/promistreams/streams/debug/node_modules/.pnpm/@promistream+from-iterable@0.1.0/node_modules/@promistream/from-iterable/index.js:26:10
at /home/sven/projects/promistreams/streams/debug/node_modules/.pnpm/@promistream+simple-source@0.1.4/node_modules/@promistream/simple-source/index.js:30:11
at tryCatcher (/home/sven/projects/promistreams/streams/debug/node_modules/.pnpm/bluebird@3.7.2/node_modules/bluebird/js/release/util.js:16:23)
at Promise.attempt.Promise.try (/home/sven/projects/promistreams/streams/debug/node_modules/.pnpm/bluebird@3.7.2/node_modules/bluebird/js/release/method.js:39:29)
at getValue (/home/sven/projects/promistreams/streams/debug/node_modules/.pnpm/@promistream+simple-source@0.1.4/node_modules/@promistream/simple-source/index.js:29:21)
at /home/sven/projects/promistreams/streams/debug/node_modules/.pnpm/@promistream+simple-source@0.1.4/node_modules/@promistream/simple-source/index.js:83:14
at tryCatcher (/home/sven/projects/promistreams/streams/debug/node_modules/.pnpm/bluebird@3.7.2/node_modules/bluebird/js/release/util.js:16:23)
at Promise.attempt.Promise.try (/home/sven/projects/promistreams/streams/debug/node_modules/.pnpm/bluebird@3.7.2/node_modules/bluebird/js/release/method.js:39:29)
at Object.produceValue_simpleSource [as read] (/home/sven/projects/promistreams/streams/debug/node_modules/.pnpm/@promistream+simple-source@0.1.4/node_modules/@promistream/simple-source/index.js:61:22)
at produceValue_debug (/home/sven/projects/promistreams/streams/debug/index.js:27:30)
at /home/sven/projects/promistreams/streams/debug/node_modules/.pnpm/@promistream+simple-sink@0.1.1/node_modules/@promistream/simple-sink/index.js:45:20
at tryCatcher (/home/sven/projects/promistreams/streams/debug/node_modules/.pnpm/bluebird@3.7.2/node_modules/bluebird/js/release/util.js:16:23)
at Promise.attempt.Promise.try (/home/sven/projects/promistreams/streams/debug/node_modules/.pnpm/bluebird@3.7.2/node_modules/bluebird/js/release/method.js:39:29)
at attemptRead (/home/sven/projects/promistreams/streams/debug/node_modules/.pnpm/@promistream+simple-sink@0.1.1/node_modules/@promistream/simple-sink/index.js:44:23)
at /home/sven/projects/promistreams/streams/debug/node_modules/.pnpm/@promistream+simple-sink@0.1.1/node_modules/@promistream/simple-sink/index.js:52:13
at tryCatcher (/home/sven/projects/promistreams/streams/debug/node_modules/.pnpm/bluebird@3.7.2/node_modules/bluebird/js/release/util.js:16:23) {
_help: 'https://www.npmjs.com/package/error-chain',
_promistreamIsEndOfStreamMarker: true,
_promistreamVersion: 1
}
[ 1, 2, 3, 4, 5 ]
API
debug(label)
Creates a new debug stream.
- label: Optional. The label to prefix the debug output with. Useful for distinguishing different pipelines, when multiple of them have a debug stream inserted at the same time.
Returns: the new debug stream.