@vbarbarosh/node-helpers 3.47.1 → 3.47.2
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
CHANGED
package/src/stream_discard.js
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const Promise = require('bluebird');
|
|
2
|
+
const assert = require('assert');
|
|
3
|
+
const stream = require('stream');
|
|
4
|
+
const stream_each = require('./stream_each');
|
|
5
|
+
const stream_map_parallel = require('./stream_map_parallel');
|
|
6
|
+
|
|
7
|
+
describe('stream_map_parallel', function () {
|
|
8
|
+
it('basic', async function () {
|
|
9
|
+
const r = Array(100).fill().map((v,i) => i);
|
|
10
|
+
const out = [];
|
|
11
|
+
await stream.promises.pipeline(
|
|
12
|
+
stream.Readable.from(r),
|
|
13
|
+
stream_map_parallel({
|
|
14
|
+
concurrency: 5,
|
|
15
|
+
handler: async function (num) {
|
|
16
|
+
await Promise.delay(0);
|
|
17
|
+
return num;
|
|
18
|
+
},
|
|
19
|
+
}),
|
|
20
|
+
stream_each(function (item) {
|
|
21
|
+
out.push(item);
|
|
22
|
+
}),
|
|
23
|
+
);
|
|
24
|
+
assert.deepStrictEqual(out, r);
|
|
25
|
+
});
|
|
26
|
+
});
|