@promistream/from-node-stream 0.1.4 → 0.1.5
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/package.json +11 -10
- package/src/index.js +2 -4
- package/test.js +50 -3
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promistream/from-node-stream",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"main": "src/index.js",
|
|
5
|
-
"repository": "
|
|
5
|
+
"repository": "https://codeberg.org/promistream/from-node-stream.git",
|
|
6
6
|
"author": "Sven Slootweg <admin@cryto.net>",
|
|
7
7
|
"license": "WTFPL OR CC0-1.0",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@joepie91/consumable": "^1.0.1",
|
|
10
10
|
"@joepie91/unreachable": "^1.0.0",
|
|
11
11
|
"@joepie91/warning": "^1.1.0",
|
|
12
|
-
"@promistream/end-of-stream": "^0.1.
|
|
12
|
+
"@promistream/end-of-stream": "^0.1.3",
|
|
13
13
|
"@promistream/is-aborted": "^0.1.1",
|
|
14
14
|
"@promistream/is-end-of-stream": "^0.1.1",
|
|
15
15
|
"@promistream/propagate-abort": "^0.1.7",
|
|
16
|
-
"@promistream/propagate-peek": "^0.1.
|
|
17
|
-
"@promistream/simple-sink": "^0.3.
|
|
18
|
-
"@promistream/simple-source": "^0.1.
|
|
16
|
+
"@promistream/propagate-peek": "^0.1.2",
|
|
17
|
+
"@promistream/simple-sink": "^0.3.4",
|
|
18
|
+
"@promistream/simple-source": "^0.1.10",
|
|
19
19
|
"debug-instanced": "^1.0.0",
|
|
20
20
|
"promisify-event": "^1.0.0",
|
|
21
21
|
"push-buffer": "^1.5.5",
|
|
@@ -25,10 +25,11 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@promistream/buffered-map": "^0.1.1",
|
|
27
27
|
"@promistream/collect": "^0.1.2",
|
|
28
|
-
"@promistream/debug": "^0.1.
|
|
29
|
-
"@promistream/from-iterable": "^0.1.
|
|
30
|
-
"@promistream/map": "^0.1.
|
|
31
|
-
"@promistream/
|
|
28
|
+
"@promistream/debug": "^0.1.2",
|
|
29
|
+
"@promistream/from-iterable": "^0.1.1",
|
|
30
|
+
"@promistream/map": "^0.1.10",
|
|
31
|
+
"@promistream/parallelize": "^0.1.8",
|
|
32
|
+
"@promistream/pipe": "^0.1.8",
|
|
32
33
|
"@promistream/range-numbers": "^0.1.2",
|
|
33
34
|
"bluebird": "^3.7.2",
|
|
34
35
|
"through2": "^4.0.2"
|
package/src/index.js
CHANGED
|
@@ -75,6 +75,7 @@ function wireReadable(debug, stream) {
|
|
|
75
75
|
// We have run out of values
|
|
76
76
|
if (isPaused && buffer.countLane().requests > 0) {
|
|
77
77
|
debug("Resuming underlying Readable stream, as our buffer ran out");
|
|
78
|
+
isPaused = false;
|
|
78
79
|
stream.resume();
|
|
79
80
|
}
|
|
80
81
|
|
|
@@ -213,10 +214,9 @@ function convertFromTransform(stream) {
|
|
|
213
214
|
await tryWrite(await lastSource.read());
|
|
214
215
|
}
|
|
215
216
|
} catch (error) {
|
|
216
|
-
if (endMarker == null && (isEndOfStream(error) || isAborted(error))) {
|
|
217
|
+
if (endMarker == null && (isEndOfStream(error) || isAborted(error))) { // FIXME: isExhausted?
|
|
217
218
|
endMarker = error;
|
|
218
219
|
|
|
219
|
-
// TODO: Is this necessary? Is this not already handled by wiring for the readable/writable interface?
|
|
220
220
|
if (isAborted(error)) {
|
|
221
221
|
if (error.cause instanceof Error) {
|
|
222
222
|
destroy(error);
|
|
@@ -228,8 +228,6 @@ function convertFromTransform(stream) {
|
|
|
228
228
|
end();
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
|
|
232
|
-
buffer.pushError(error);
|
|
233
231
|
}
|
|
234
232
|
});
|
|
235
233
|
|
package/test.js
CHANGED
|
@@ -10,6 +10,7 @@ const pipe = require("@promistream/pipe");
|
|
|
10
10
|
const fromIterable = require("@promistream/from-iterable");
|
|
11
11
|
const fromNodeStream = require(".");
|
|
12
12
|
const collect = require("@promistream/collect");
|
|
13
|
+
const parallelize = require("@promistream/parallelize");
|
|
13
14
|
const debug = require("@promistream/debug");
|
|
14
15
|
|
|
15
16
|
test("readable stream", async () => {
|
|
@@ -55,9 +56,12 @@ test("transform stream", async () => {
|
|
|
55
56
|
fromNodeStream(new stream.Transform({
|
|
56
57
|
objectMode: true,
|
|
57
58
|
transform(chunk, _encoding, callback) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
/* Intentionally delay things, to validate that processing in the Node stream fully completes before the pipeline gets torn down */
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
this.push(chunk);
|
|
62
|
+
this.push(chunk * 2);
|
|
63
|
+
callback();
|
|
64
|
+
}, 10);
|
|
61
65
|
}
|
|
62
66
|
})),
|
|
63
67
|
collect()
|
|
@@ -65,3 +69,46 @@ test("transform stream", async () => {
|
|
|
65
69
|
|
|
66
70
|
assert.deepStrictEqual(result, [ 0, 0, 1, 2, 2, 4, 3, 6, 4, 8, 5, 10, 6, 12, 7, 14, 8, 16, 9, 18, 10, 20 ]);
|
|
67
71
|
});
|
|
72
|
+
|
|
73
|
+
test("transform stream with abort", async () => {
|
|
74
|
+
assert.rejects(async () => {
|
|
75
|
+
let pipeline = pipe([
|
|
76
|
+
fromIterable([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]),
|
|
77
|
+
fromNodeStream(new stream.Transform({
|
|
78
|
+
objectMode: true,
|
|
79
|
+
transform(chunk, _encoding, callback) {
|
|
80
|
+
setTimeout(() => {
|
|
81
|
+
this.push(chunk);
|
|
82
|
+
this.push(chunk * 2);
|
|
83
|
+
callback();
|
|
84
|
+
}, 10);
|
|
85
|
+
}
|
|
86
|
+
})),
|
|
87
|
+
collect()
|
|
88
|
+
]);
|
|
89
|
+
|
|
90
|
+
pipeline.abort(new Error("Some arbitrary error"));
|
|
91
|
+
let result = await pipeline.read();
|
|
92
|
+
}, { message: "Some arbitrary error" });
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("transform stream, parallel", async () => {
|
|
96
|
+
let result = await pipe([
|
|
97
|
+
fromIterable([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]),
|
|
98
|
+
fromNodeStream(new stream.Transform({
|
|
99
|
+
objectMode: true,
|
|
100
|
+
transform(chunk, _encoding, callback) {
|
|
101
|
+
/* Intentionally delay things, to validate that processing in the Node stream fully completes before the pipeline gets torn down */
|
|
102
|
+
setTimeout(() => {
|
|
103
|
+
this.push(chunk);
|
|
104
|
+
this.push(chunk * 2);
|
|
105
|
+
callback();
|
|
106
|
+
}, 10);
|
|
107
|
+
}
|
|
108
|
+
})),
|
|
109
|
+
parallelize(8),
|
|
110
|
+
collect()
|
|
111
|
+
]).read();
|
|
112
|
+
|
|
113
|
+
assert.deepStrictEqual(result, [ 0, 0, 1, 2, 2, 4, 3, 6, 4, 8, 5, 10, 6, 12, 7, 14, 8, 16, 9, 18, 10, 20 ]);
|
|
114
|
+
});
|