Prepare for first release

main
Sven Slootweg 5 months ago
parent b5c619f0d1
commit 401abe9f06

3
.gitignore vendored

@ -1 +1,4 @@
node_modules node_modules
# To make npm ignore it
.jj

@ -0,0 +1,84 @@
# @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`.
```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.

@ -6,6 +6,12 @@
"url": "https://git.cryto.net/promistream/debug.git" "url": "https://git.cryto.net/promistream/debug.git"
}, },
"main": "index.js", "main": "index.js",
"files": [
"index.js",
"example.js",
"README.md",
"screenshot.png"
],
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Loading…
Cancel
Save