@thi.ng/rstream 9.4.2 → 9.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -216,7 +216,7 @@ For Node.js REPL:
216
216
  const rs = await import("@thi.ng/rstream");
217
217
  ```
218
218
 
219
- Package sizes (brotli'd, pre-treeshake): ESM: 6.39 KB
219
+ Package sizes (brotli'd, pre-treeshake): ESM: 6.40 KB
220
220
 
221
221
  ## Dependencies
222
222
 
package/nodejs.d.ts CHANGED
@@ -1,25 +1,26 @@
1
1
  import type { Readable } from "node:stream";
2
- import { type Stream } from "./stream.js";
3
- import type { Subscription } from "./subscription.js";
2
+ import type { ISubscription } from "./api.js";
4
3
  /**
5
- * Adapter bridge from NodeJS streams. Creates and returns a new {@link stream}
6
- * of type `T` and pipes in data from `stdout` (also assumed to produce data of
7
- * type `T`). If given, also connects `stderr` to new rstream's error handler.
8
- * Unless `close` is false, the new stream closes once `stdout` is closed.
4
+ * Adapter bridge from NodeJS streams. Pipes data from given `stdout` (assumed
5
+ * to produce data of type `T`) into `ingest` or creates and returns a new
6
+ * {@link stream}. If given, also connects given `stderr` to `ingest`'s error
7
+ * handler. Unless `close` is false, `ingest` closes once `stdout` is closed.
9
8
  *
10
9
  * @param stdout -
11
10
  * @param stderr -
12
11
  * @param close -
12
+ * @param ingest -
13
13
  */
14
- export declare const fromNodeJS: <T>(stdout: Readable, stderr?: Readable, close?: boolean) => Stream<T>;
14
+ export declare const fromNodeJS: <T>(stdout: Readable, stderr?: Readable, close?: boolean, ingest?: ISubscription<T, T>) => ISubscription<T, T>;
15
15
  /**
16
16
  * Specialized version of {@link fromNodeJS} for string inputs and automatic
17
17
  * rechunking/splitting of the input using the optionally provided regexp (line
18
18
  * breaks by default).
19
19
  *
20
20
  * @remarks
21
- * Internally uses https://docs.thi.ng/umbrella/transducers/functions/rechunk.html
22
- * to rechunk input.
21
+ * Internally uses
22
+ * https://docs.thi.ng/umbrella/transducers/functions/rechunk.html to rechunk
23
+ * input.
23
24
  *
24
25
  * @example
25
26
  * ```ts tangle:../export/lines-from-nodejs.ts
@@ -45,6 +46,7 @@ export declare const fromNodeJS: <T>(stdout: Readable, stderr?: Readable, close?
45
46
  * @param stderr -
46
47
  * @param re -
47
48
  * @param close -
49
+ * @param ingest -
48
50
  */
49
- export declare const linesFromNodeJS: (stdout: Readable, stderr?: Readable, re?: RegExp, close?: boolean) => Subscription<string, string>;
51
+ export declare const linesFromNodeJS: (stdout: Readable, stderr?: Readable, re?: RegExp, close?: boolean, ingest?: ISubscription<string, string>) => ISubscription<string, string>;
50
52
  //# sourceMappingURL=nodejs.d.ts.map
package/nodejs.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { rechunk } from "@thi.ng/transducers/rechunk";
2
2
  import { stream } from "./stream.js";
3
- const fromNodeJS = (stdout, stderr, close = true) => {
4
- const ingest = stream();
3
+ const fromNodeJS = (stdout, stderr, close = true, ingest = stream()) => {
5
4
  stdout.on("data", (data) => ingest.next(data));
6
- stderr?.on("data", (data) => ingest.error(data));
7
- close && stdout.on("close", () => ingest.done());
5
+ if (stderr && ingest.error)
6
+ stderr.on("data", (data) => ingest.error(data));
7
+ if (close && ingest.done) stdout.on("close", () => ingest.done());
8
8
  return ingest;
9
9
  };
10
- const linesFromNodeJS = (stdout, stderr, re, close) => fromNodeJS(stdout, stderr, close).transform(rechunk(re));
10
+ const linesFromNodeJS = (stdout, stderr, re, close, ingest) => fromNodeJS(stdout, stderr, close, ingest).transform(rechunk(re));
11
11
  export {
12
12
  fromNodeJS,
13
13
  linesFromNodeJS
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/rstream",
3
- "version": "9.4.2",
3
+ "version": "9.5.0",
4
4
  "description": "Reactive streams & subscription primitives for constructing dataflow graphs / pipelines",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -44,19 +44,19 @@
44
44
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
45
45
  },
46
46
  "dependencies": {
47
- "@thi.ng/api": "^8.12.18",
48
- "@thi.ng/arrays": "^2.14.14",
49
- "@thi.ng/associative": "^7.1.34",
50
- "@thi.ng/atom": "^5.3.59",
51
- "@thi.ng/checks": "^3.8.8",
52
- "@thi.ng/errors": "^2.6.7",
53
- "@thi.ng/logger": "^3.3.1",
54
- "@thi.ng/transducers": "^9.6.31"
47
+ "@thi.ng/api": "^8.12.19",
48
+ "@thi.ng/arrays": "^2.14.15",
49
+ "@thi.ng/associative": "^7.1.35",
50
+ "@thi.ng/atom": "^5.3.60",
51
+ "@thi.ng/checks": "^3.8.9",
52
+ "@thi.ng/errors": "^2.6.8",
53
+ "@thi.ng/logger": "^3.3.2",
54
+ "@thi.ng/transducers": "^9.6.32"
55
55
  },
56
56
  "devDependencies": {
57
- "@types/node": "^24.10.9",
58
- "esbuild": "^0.27.2",
59
- "typedoc": "^0.28.16",
57
+ "@types/node": "^25.5.2",
58
+ "esbuild": "^0.28.0",
59
+ "typedoc": "^0.28.18",
60
60
  "typescript": "^5.9.3"
61
61
  },
62
62
  "keywords": [
@@ -223,5 +223,5 @@
223
223
  ],
224
224
  "year": 2017
225
225
  },
226
- "gitHead": "8ddf86ea0a1e658ddbf19cc645b29d0c176e29c4\n"
226
+ "gitHead": "a780d4a5f6f5fc595c9d28527686f63534927d32"
227
227
  }
package/subscription.js CHANGED
@@ -30,6 +30,7 @@ class Subscription {
30
30
  this.cacheLast = opts.cache;
31
31
  opts.xform && (this.xform = opts.xform(push()));
32
32
  }
33
+ wrapped;
33
34
  id;
34
35
  closeIn;
35
36
  closeOut;