thread-stream 0.13.2 → 0.14.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/.github/dependabot.yml +11 -14
- package/.github/workflows/ci.yml +2 -2
- package/.github/workflows/package-manager-ci.yml +4 -4
- package/.taprc +1 -0
- package/index.js +9 -1
- package/package.json +2 -2
- package/test/base.test.js +23 -0
package/.github/dependabot.yml
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
version: 2
|
|
2
2
|
updates:
|
|
3
|
-
- package-ecosystem: github-actions
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
schedule:
|
|
15
|
-
interval: daily
|
|
16
|
-
open-pull-requests-limit: 10
|
|
3
|
+
- package-ecosystem: "github-actions"
|
|
4
|
+
directory: "/"
|
|
5
|
+
schedule:
|
|
6
|
+
interval: "monthly"
|
|
7
|
+
open-pull-requests-limit: 10
|
|
8
|
+
|
|
9
|
+
- package-ecosystem: "npm"
|
|
10
|
+
directory: "/"
|
|
11
|
+
schedule:
|
|
12
|
+
interval: "weekly"
|
|
13
|
+
open-pull-requests-limit: 10
|
package/.github/workflows/ci.yml
CHANGED
|
@@ -17,9 +17,9 @@ jobs:
|
|
|
17
17
|
os: [macOS-latest, windows-latest]
|
|
18
18
|
node-version: [12, 14, 16]
|
|
19
19
|
steps:
|
|
20
|
-
- uses: actions/checkout@
|
|
20
|
+
- uses: actions/checkout@v3
|
|
21
21
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
22
|
-
uses: actions/setup-node@
|
|
22
|
+
uses: actions/setup-node@v3
|
|
23
23
|
with:
|
|
24
24
|
node-version: ${{ matrix.node-version }}
|
|
25
25
|
- name: Use pnpm
|
|
@@ -39,9 +39,9 @@ jobs:
|
|
|
39
39
|
os: [macOS-latest]
|
|
40
40
|
node-version: [12, 14, 16]
|
|
41
41
|
steps:
|
|
42
|
-
- uses: actions/checkout@
|
|
42
|
+
- uses: actions/checkout@v3
|
|
43
43
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
44
|
-
uses: actions/setup-node@
|
|
44
|
+
uses: actions/setup-node@v3
|
|
45
45
|
with:
|
|
46
46
|
node-version: ${{ matrix.node-version }}
|
|
47
47
|
- name: Use yarn
|
package/.taprc
CHANGED
package/index.js
CHANGED
|
@@ -104,6 +104,11 @@ function nextFlush (stream) {
|
|
|
104
104
|
} else {
|
|
105
105
|
// multi-byte utf-8
|
|
106
106
|
stream.flush(() => {
|
|
107
|
+
// err is already handled in flush()
|
|
108
|
+
if (stream.destroyed) {
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
|
|
107
112
|
Atomics.store(stream[kImpl].state, READ_INDEX, 0)
|
|
108
113
|
Atomics.store(stream[kImpl].state, WRITE_INDEX, 0)
|
|
109
114
|
|
|
@@ -255,7 +260,10 @@ class ThreadStream extends EventEmitter {
|
|
|
255
260
|
|
|
256
261
|
flush (cb) {
|
|
257
262
|
if (this[kImpl].destroyed) {
|
|
258
|
-
|
|
263
|
+
if (typeof cb === 'function') {
|
|
264
|
+
process.nextTick(cb, new Error('the worker has exited'))
|
|
265
|
+
}
|
|
266
|
+
return
|
|
259
267
|
}
|
|
260
268
|
|
|
261
269
|
// TODO write all .buf
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "thread-stream",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "A streaming way to send data to a Node.js Worker Thread",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"dependencies": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"husky": "^7.0.0",
|
|
13
13
|
"sonic-boom": "^2.0.1",
|
|
14
14
|
"standard": "^16.0.3",
|
|
15
|
-
"tap": "^
|
|
15
|
+
"tap": "^16.0.0",
|
|
16
16
|
"why-is-node-running": "^2.2.0"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
package/test/base.test.js
CHANGED
|
@@ -246,3 +246,26 @@ test('pass down MessagePorts', async function (t) {
|
|
|
246
246
|
|
|
247
247
|
t.equal(strings, 'hello world\nsomething else\n')
|
|
248
248
|
})
|
|
249
|
+
|
|
250
|
+
test('destroy does not error', function (t) {
|
|
251
|
+
t.plan(3)
|
|
252
|
+
|
|
253
|
+
const dest = file()
|
|
254
|
+
const stream = new ThreadStream({
|
|
255
|
+
filename: join(__dirname, 'to-file.js'),
|
|
256
|
+
workerData: { dest },
|
|
257
|
+
sync: false
|
|
258
|
+
})
|
|
259
|
+
|
|
260
|
+
stream.on('ready', () => {
|
|
261
|
+
t.pass('ready emitted')
|
|
262
|
+
stream.worker.terminate()
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
stream.on('error', (err) => {
|
|
266
|
+
t.equal(err.message, 'The worker thread exited')
|
|
267
|
+
stream.flush((err) => {
|
|
268
|
+
t.equal(err.message, 'the worker has exited')
|
|
269
|
+
})
|
|
270
|
+
})
|
|
271
|
+
})
|