thread-stream 0.11.0 → 0.12.1
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/workflows/ci.yml +3 -3
- package/.github/workflows/package-manager-ci.yml +59 -0
- package/.taprc +2 -0
- package/README.md +22 -0
- package/index.js +293 -210
- package/lib/worker.js +25 -1
- package/package.json +5 -3
- package/test/base.test.js +38 -102
- package/test/close-on-gc.js +8 -10
- package/test/commonjs-fallback.test.js +29 -0
- package/test/create-and-exit.js +5 -7
- package/test/end.test.js +22 -38
- package/test/esm.test.mjs +8 -36
- package/test/helper.js +8 -1
- package/test/multibyte-chars.test.mjs +6 -10
- package/test/string-limit.test.js +36 -0
- package/test/thread-management.test.js +5 -5
package/.github/workflows/ci.yml
CHANGED
|
@@ -19,10 +19,10 @@ jobs:
|
|
|
19
19
|
|
|
20
20
|
steps:
|
|
21
21
|
|
|
22
|
-
- uses: actions/checkout@v2.3.
|
|
22
|
+
- uses: actions/checkout@v2.3.5
|
|
23
23
|
|
|
24
24
|
- name: Use Node.js
|
|
25
|
-
uses: actions/setup-node@v2.
|
|
25
|
+
uses: actions/setup-node@v2.4.1
|
|
26
26
|
with:
|
|
27
27
|
node-version: ${{ matrix.node-version }}
|
|
28
28
|
|
|
@@ -55,6 +55,6 @@ jobs:
|
|
|
55
55
|
needs: test
|
|
56
56
|
runs-on: ubuntu-latest
|
|
57
57
|
steps:
|
|
58
|
-
- uses: fastify/github-action-merge-dependabot@v2.
|
|
58
|
+
- uses: fastify/github-action-merge-dependabot@v2.4.0
|
|
59
59
|
with:
|
|
60
60
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
name: package-manager-ci
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
paths-ignore:
|
|
5
|
+
- 'docs/**'
|
|
6
|
+
- '*.md'
|
|
7
|
+
pull_request:
|
|
8
|
+
paths-ignore:
|
|
9
|
+
- 'docs/**'
|
|
10
|
+
- '*.md'
|
|
11
|
+
jobs:
|
|
12
|
+
pnpm:
|
|
13
|
+
name: pnpm package manager on ${{ matrix.node-version }} ${{ matrix.os }}
|
|
14
|
+
runs-on: ${{ matrix.os }}
|
|
15
|
+
strategy:
|
|
16
|
+
matrix:
|
|
17
|
+
os: [macOS-latest, windows-latest]
|
|
18
|
+
node-version: [12, 14, 16]
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v2.3.5
|
|
21
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
22
|
+
uses: actions/setup-node@v2.4.1
|
|
23
|
+
with:
|
|
24
|
+
node-version: ${{ matrix.node-version }}
|
|
25
|
+
- name: Use pnpm
|
|
26
|
+
uses: pnpm/action-setup@v2.0.1
|
|
27
|
+
with:
|
|
28
|
+
version: ^6.0.0
|
|
29
|
+
- name: Install dependancies
|
|
30
|
+
run: pnpm install
|
|
31
|
+
- name: Tests
|
|
32
|
+
run: pnpm run test:ci
|
|
33
|
+
|
|
34
|
+
yarn-pnp:
|
|
35
|
+
name: yarn-pnp package manager on ${{ matrix.node-version }} ${{ matrix.os }}
|
|
36
|
+
runs-on: ${{ matrix.os }}
|
|
37
|
+
strategy:
|
|
38
|
+
matrix:
|
|
39
|
+
os: [macOS-latest]
|
|
40
|
+
node-version: [12, 14, 16]
|
|
41
|
+
steps:
|
|
42
|
+
- uses: actions/checkout@v2.3.5
|
|
43
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
44
|
+
uses: actions/setup-node@v2.4.1
|
|
45
|
+
with:
|
|
46
|
+
node-version: ${{ matrix.node-version }}
|
|
47
|
+
- name: Use yarn
|
|
48
|
+
run: |
|
|
49
|
+
npm install -g yarn
|
|
50
|
+
yarn set version berry
|
|
51
|
+
echo "nodeLinker: pnp" >> .yarnrc.yml
|
|
52
|
+
echo "pnpMode: loose" >> .yarnrc.yml
|
|
53
|
+
yarn add -D pino-elasticsearch@^6.0.0
|
|
54
|
+
yarn install
|
|
55
|
+
env:
|
|
56
|
+
# needed due the yarn.lock file in repository's .gitignore
|
|
57
|
+
YARN_ENABLE_IMMUTABLE_INSTALLS: false
|
|
58
|
+
- name: Tests
|
|
59
|
+
run: yarn run test:yarn
|
package/.taprc
ADDED
package/README.md
CHANGED
|
@@ -64,6 +64,28 @@ flag your stream classes.
|
|
|
64
64
|
|
|
65
65
|
The underlining worker is automatically closed if the stream is garbage collected.
|
|
66
66
|
|
|
67
|
+
|
|
68
|
+
### External modules
|
|
69
|
+
|
|
70
|
+
You may use this module within compatible external modules, that exports the `worker.js` interface.
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
const ThreadStream = require('thread-stream')
|
|
74
|
+
|
|
75
|
+
const modulePath = require.resolve('pino-elasticsearch')
|
|
76
|
+
|
|
77
|
+
const stream = new ThreadStream({
|
|
78
|
+
filename: modulePath,
|
|
79
|
+
workerData: { node: 'http://localhost:9200' }
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
stream.write('log to elasticsearch!')
|
|
83
|
+
stream.flushSync()
|
|
84
|
+
stream.end()
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
This module works with `yarn` in PnP (plug'n play) mode too!
|
|
88
|
+
|
|
67
89
|
## License
|
|
68
90
|
|
|
69
91
|
MIT
|