thread-stream 0.15.0 → 1.0.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.
@@ -12,9 +12,12 @@ jobs:
12
12
  test:
13
13
  runs-on: ${{ matrix.os }}
14
14
 
15
+ permissions:
16
+ contents: read
17
+
15
18
  strategy:
16
19
  matrix:
17
- node-version: [12, 14, 16]
20
+ node-version: [14, 16, 18]
18
21
  os: [macos-latest, ubuntu-latest, windows-latest]
19
22
 
20
23
  steps:
@@ -55,7 +58,10 @@ jobs:
55
58
  automerge:
56
59
  needs: test
57
60
  runs-on: ubuntu-latest
61
+ permissions:
62
+ pull-requests: write
63
+ contents: write
58
64
  steps:
59
- - uses: fastify/github-action-merge-dependabot@v2.7.1
65
+ - uses: fastify/github-action-merge-dependabot@v3
60
66
  with:
61
67
  github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -15,7 +15,7 @@ jobs:
15
15
  strategy:
16
16
  matrix:
17
17
  os: [macOS-latest, windows-latest]
18
- node-version: [12, 14, 16]
18
+ node-version: [14, 16, 18]
19
19
  steps:
20
20
  - uses: actions/checkout@v3
21
21
  - name: Use Node.js ${{ matrix.node-version }}
@@ -38,7 +38,7 @@ jobs:
38
38
  strategy:
39
39
  matrix:
40
40
  os: [macOS-latest]
41
- node-version: [12, 14, 16]
41
+ node-version: [14, 16, 18]
42
42
  steps:
43
43
  - uses: actions/checkout@v3
44
44
  - name: Use Node.js ${{ matrix.node-version }}
package/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
  [![npm version](https://img.shields.io/npm/v/thread-stream)](https://www.npmjs.com/package/thread-stream)
3
3
  [![Build Status](https://img.shields.io/github/workflow/status/pinojs/thread-stream/CI)](https://github.com/pinojs/thread-stream/actions)
4
4
  [![Known Vulnerabilities](https://snyk.io/test/github/pinojs/thread-stream/badge.svg)](https://snyk.io/test/github/pinojs/thread-stream)
5
- [![Coverage Status](https://coveralls.io/repos/github/pinojs/thread-stream/badge.svg?branch=master)](https://coveralls.io/github/pinojs/thread-stream?branch=master)
6
5
  [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
7
6
 
8
7
  A streaming way to send data to a Node.js Worker Thread.
package/index.js CHANGED
@@ -251,7 +251,7 @@ class ThreadStream extends EventEmitter {
251
251
 
252
252
  end () {
253
253
  if (this[kImpl].destroyed) {
254
- throw new Error('the worker has exited')
254
+ return
255
255
  }
256
256
 
257
257
  this[kImpl].ending = true
@@ -286,7 +286,7 @@ class ThreadStream extends EventEmitter {
286
286
 
287
287
  flushSync () {
288
288
  if (this[kImpl].destroyed) {
289
- throw new Error('the worker has exited')
289
+ return
290
290
  }
291
291
 
292
292
  writeSync(this)
package/lib/worker.js CHANGED
@@ -19,16 +19,16 @@ const data = Buffer.from(dataBuf)
19
19
  async function start () {
20
20
  let fn
21
21
  try {
22
- // TODO: fix loading .ts files in Windows. See: ../test/ts.test.ts
23
22
  if (filename.endsWith('.ts') || filename.endsWith('.cts')) {
24
23
  // TODO: add support for the TSM modules loader ( https://github.com/lukeed/tsm ).
25
- if (process[Symbol.for('ts-node.register.instance')]) {
24
+ if (!process[Symbol.for('ts-node.register.instance')]) {
26
25
  realRequire('ts-node/register')
27
26
  } else if (process.env.TS_NODE_DEV) {
28
27
  realRequire('ts-node-dev')
29
28
  }
30
29
  // TODO: Support ES imports once tsc, tap & ts-node provide better compatibility guarantees.
31
- fn = realRequire(decodeURIComponent(filename.replace('file://', '')))
30
+ // Remove extra forwardslash on Windows
31
+ fn = realRequire(decodeURIComponent(filename.replace(process.platform === 'win32' ? 'file:///' : 'file://', '')))
32
32
  } else {
33
33
  fn = (await realImport(filename))
34
34
  }
package/package.json CHANGED
@@ -1,23 +1,24 @@
1
1
  {
2
2
  "name": "thread-stream",
3
- "version": "0.15.0",
3
+ "version": "1.0.0",
4
4
  "description": "A streaming way to send data to a Node.js Worker Thread",
5
5
  "main": "index.js",
6
+ "types": "index.d.ts",
6
7
  "dependencies": {
7
8
  "real-require": "^0.1.0"
8
9
  },
9
10
  "devDependencies": {
10
- "@types/node": "^12.0.0",
11
+ "@types/node": "^17.0.37",
11
12
  "@types/tap": "^15.0.0",
12
- "desm": "^1.1.0",
13
+ "desm": "^1.3.0",
13
14
  "fastbench": "^1.0.1",
14
- "husky": "^7.0.0",
15
- "sonic-boom": "^2.0.1",
16
- "standard": "^16.0.3",
17
- "tap": "^16.0.0",
18
- "ts-node": "^10.7.0",
19
- "typescript": "^4.6.0",
20
- "why-is-node-running": "^2.2.0"
15
+ "husky": "^8.0.1",
16
+ "sonic-boom": "^2.8.0",
17
+ "standard": "^17.0.0",
18
+ "tap": "^16.2.0",
19
+ "ts-node": "^10.8.0",
20
+ "typescript": "^4.7.2",
21
+ "why-is-node-running": "^2.2.2"
21
22
  },
22
23
  "scripts": {
23
24
  "test": "standard && npm run transpile && tap test/*.test.*js && tap --ts test/*.test.*ts",
package/test/base.test.js CHANGED
@@ -248,7 +248,7 @@ test('pass down MessagePorts', async function (t) {
248
248
  })
249
249
 
250
250
  test('destroy does not error', function (t) {
251
- t.plan(3)
251
+ t.plan(5)
252
252
 
253
253
  const dest = file()
254
254
  const stream = new ThreadStream({
@@ -267,5 +267,7 @@ test('destroy does not error', function (t) {
267
267
  stream.flush((err) => {
268
268
  t.equal(err.message, 'the worker has exited')
269
269
  })
270
+ t.doesNotThrow(() => stream.flushSync())
271
+ t.doesNotThrow(() => stream.end())
270
272
  })
271
273
  })
package/test/ts.test.ts CHANGED
@@ -6,12 +6,6 @@ import { file } from './helper.js'
6
6
 
7
7
 
8
8
  test('typescript module', function (t) {
9
- if (process.platform === 'win32') {
10
- // TODO: Implement .ts files loading support for Windows
11
- t.plan(0)
12
- return
13
- }
14
-
15
9
  t.plan(5)
16
10
 
17
11
  const dest = file()