Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from josdejong:master #3

Open
wants to merge 87 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
fb214aa
fix: worker termination before it's ready (#394)
Michsior14 Aug 17, 2023
04468a2
chore: update devDependencies
josdejong Aug 17, 2023
f65d816
chore: update semver in package-lock.json
josdejong Aug 17, 2023
4ad125d
chore: publish v6.4.1
josdejong Aug 17, 2023
c16ae27
chore: run CI tests on node.js 20 too
josdejong Aug 17, 2023
066820f
fix: properly timeout on worker termination (#395)
Michsior14 Aug 21, 2023
a35f8da
chore: publish v6.4.2
josdejong Aug 21, 2023
21da4d9
add the ability to pass options to web worker constructor (#400)
DonatJR Sep 13, 2023
604bd13
chore: update babel dev dependency
josdejong Sep 13, 2023
52ecc49
chore: publish v6.5.0
josdejong Sep 13, 2023
b846659
chore: stop testing on Node.js 16
josdejong Oct 11, 2023
fdccb72
fix: `workerThreadOpts` not working when `workerType: auto`, see #357
josdejong Oct 11, 2023
24a91a5
chore: update devDependencies
josdejong Oct 11, 2023
1fd94c4
chore: publish v6.5.1
josdejong Oct 11, 2023
82e9ee0
chore: replace Webpack setup with Rollup (#403)
KonghaYao Oct 25, 2023
8dcc0fc
chore: change version numbers of devDependencies to exact numbers
josdejong Oct 25, 2023
5f42eb1
chore: publish v7.0.0
josdejong Oct 25, 2023
438769e
fix: #56 document the return types of all methods
josdejong Oct 25, 2023
99ea396
chore: cleanup redundant gulpfile.js
josdejong Oct 25, 2023
ea5368c
fix: throw an error in case of unknown properties or inherited proper…
josdejong Oct 25, 2023
37ea11e
docs: add examples with Vite and Webpack5 (#408)
KonghaYao Oct 25, 2023
7c32f49
chore: publish v8.0.0
josdejong Oct 25, 2023
cac8a9d
docs: fix the release dates mentioned in HISTORY.md
josdejong Nov 8, 2023
aaf998d
Fix a typo (#409)
senicko Nov 16, 2023
9a64c07
chore: update devDependencies
josdejong Dec 6, 2023
e2fde03
Fix examples/embeddedWorker (#414)
tamuratak Dec 13, 2023
5fd5a92
Add an example for an inline worker with esbuild (#413)
tamuratak Dec 18, 2023
78b00f7
Generate types from JSDoc comments with TypeScript compiler. (#415)
tamuratak Dec 18, 2023
bea005b
fix: include the `types` folder in the npm package
josdejong Dec 18, 2023
629f11c
chore: update devDependencies
josdejong Dec 18, 2023
2d23e43
fix: solve TS warnings about undefined `WorkerOptions`
josdejong Dec 18, 2023
72d531f
chore: publish v9.0.0
josdejong Dec 18, 2023
8214e90
Export more types (#416)
joshkel Dec 18, 2023
8693022
chore: publish v9.0.1
josdejong Dec 18, 2023
66edf85
export the Proxy type, use workerpool's Promise` (#417)
tamuratak Dec 19, 2023
103b11a
chore: publish v9.0.2
josdejong Dec 19, 2023
09841f2
Unwrap promise types (#419)
joshkel Dec 20, 2023
9295847
chore: publish v9.0.3
josdejong Dec 20, 2023
f37cc7b
chore: minor edit for type tests (#420)
tamuratak Dec 21, 2023
6417eaf
Improve the logic of isNode(). (#421)
tamuratak Dec 22, 2023
90154d0
chore: publish v9.0.4
josdejong Dec 22, 2023
4dc9fcb
chore(deps-dev): bump follow-redirects in /examples/webpack5 (#424)
dependabot[bot] Jan 11, 2024
78fe8cc
feat: allow for capture of stdout/stderr from worker (#425)
cpendery Jan 18, 2024
772cd3a
chore: update devDependencies
josdejong Jan 18, 2024
37bd36b
chore: publish v9.1.0
josdejong Jan 18, 2024
a1d85d5
chore(deps-dev): bump vite from 5.0.5 to 5.0.12 in /examples/vite (#426)
dependabot[bot] Jan 24, 2024
2cf2788
chore(deps-dev): bump follow-redirects in /examples/webpack5 (#433)
dependabot[bot] Mar 18, 2024
05bb3fb
chore(deps-dev): bump webpack-dev-middleware in /examples/webpack5 (#…
dependabot[bot] Mar 27, 2024
93ad108
chore(deps-dev): bump express in /examples/webpack5 (#436)
dependabot[bot] Mar 27, 2024
6b0b1b0
chore(deps-dev): bump vite from 5.0.12 to 5.0.13 in /examples/vite (#…
dependabot[bot] Apr 4, 2024
aef7e7d
fix: events not emitted from offloaded functions (#439)
w1nklr Apr 6, 2024
3ea16ee
chore: update devDependencies
josdejong Apr 6, 2024
649b60d
chore: publish v9.1.1
josdejong Apr 6, 2024
54af056
chore: upgrade the github actions to v4
josdejong Apr 6, 2024
e633104
chore: update browser list description (see #446)
josdejong May 30, 2024
f01d519
make the built output compatible with older browsers (see #446)
josdejong Jun 4, 2024
2ca3d46
chore: update devDependencies
josdejong Jun 4, 2024
c0b3481
chore: test on Node.js 22
josdejong Jun 4, 2024
cff840f
chore: publish v9.1.2
josdejong Jun 4, 2024
77ec996
chore: update devDependencies
josdejong Jun 19, 2024
7c4582c
docs: clarify webpack5 setup with workerpool (#447) (#453)
im7mortal Jun 26, 2024
007a3d4
fix: transfer from worker (#455)
LeonidPolukhin Jun 28, 2024
fc0959d
chore: publish v9.1.3
josdejong Jun 28, 2024
cdb5861
chore: update webpack5 example to illustrate worker feedback (#456)
w1nklr Jul 24, 2024
0367df6
feat: add `Promise.finally()` (#388)
wmertens Aug 30, 2024
599365c
fix: vite example and enable app (#461)
datashaman Aug 30, 2024
009730d
chore(deps-dev): bump webpack in /examples/embeddedWorker (#462)
dependabot[bot] Aug 30, 2024
1fc4ba4
chore: update history
josdejong Aug 30, 2024
09f7178
chore(deps-dev): bump webpack in /examples/webpack5 (#463)
dependabot[bot] Aug 30, 2024
ade322f
chore(deps-dev): bump vite from 5.0.13 to 5.4.6 in /examples/vite (#466)
dependabot[bot] Sep 18, 2024
b7f9cae
chore(deps): bump body-parser and express in /examples/webpack5 (#467)
dependabot[bot] Sep 18, 2024
0d1506a
chore: update devDependencies
josdejong Sep 25, 2024
2061427
fix: promises returned by the `Promise.finally` callback not being ha…
josdejong Oct 2, 2024
e487987
chore: fix bundling broken after upgrading to `@rollup/plugin-commonj…
josdejong Oct 7, 2024
20d20db
feat: abort listener (#448)
joshLong145 Oct 11, 2024
b1885d3
chore: update devDependencies
josdejong Oct 11, 2024
efc2a70
chore: publish `v9.2.0`
josdejong Oct 11, 2024
31550be
docs: update the mentioned library size in the README.md
josdejong Oct 11, 2024
6cfc112
chore: remove `src/generated/embeddedWorker.js` from the repo (it's a…
josdejong Oct 11, 2024
4cf4d9d
chore(deps): bump cookie and express in /examples/webpack5 (#472)
dependabot[bot] Oct 11, 2024
d372249
chore(deps): bump rollup from 4.21.3 to 4.24.0 in /examples/vite (#473)
dependabot[bot] Oct 11, 2024
40b8ef5
chore: replace wrong usage of `assert(...)` with `assert.fail(...)`
josdejong Oct 15, 2024
783d669
chore: improve the `createPool` function in the tests
josdejong Oct 15, 2024
e9b7767
Merge remote-tracking branch 'origin/master'
josdejong Oct 15, 2024
6bf949e
docs: add Worker API Documentation (#474)
joshLong145 Oct 17, 2024
ea38666
feat: support events and std streams from an abort handler
joshLong145 Dec 12, 2024
100f512
chore: update HISTORY.md
josdejong Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: josdejong#56 document the return types of all methods
  • Loading branch information
josdejong committed Oct 25, 2023
commit 438769e464015e0e5cd0c6e7c8e0ad82a86f5b8c
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ The following options are available:

A worker pool contains the following functions:

- `Pool.exec(method: Function | string, params: Array | null [, options: Object]) : Promise.<*, Error>`<br>
- `Pool.exec(method: Function | string, params: Array | null [, options: Object]) : Promise<any, Error>`<br>
Execute a function on a worker with given arguments.

- When `method` is a string, a method with this name must exist at the worker and must be registered to make it accessible via the pool. The function will be executed on the worker with given parameters.
Expand All @@ -220,7 +220,7 @@ A worker pool contains the following functions:
- `on: (payload: any) => void`. An event listener, to handle events sent by the worker for this execution. See [Events](#events) for more details.
- `transfer: Object[]`. A list of transferable objects to send to the worker. Not supported by `process` worker type. See [example](./examples/transferableObjects.js) for usage.

- `Pool.proxy() : Promise.<Object, Error>`<br>
- `Pool.proxy() : Promise<Object, Error>`<br>
Create a proxy for the worker pool. The proxy contains a proxy for all methods available on the worker. All methods return promises resolving the methods result.

- `Pool.stats() : Object`<br>
Expand All @@ -238,20 +238,20 @@ A worker pool contains the following functions:
}
```

- `Pool.terminate([force: boolean [, timeout: number]])`
- `Pool.terminate([force: boolean [, timeout: number]]) : Promise<void, Error>`

If parameter `force` is false (default), workers will finish the tasks they are working on before terminating themselves. Any pending tasks will be rejected with an error 'Pool terminated'. When `force` is true, all workers are terminated immediately without finishing running tasks. If `timeout` is provided, worker will be forced to terminate when the timeout expires and the worker has not finished.

The function `Pool.exec` and the proxy functions all return a `Promise`. The promise has the following functions available:

- `Promise.then(fn: Function.<result: *>)`<br>
- `Promise.then(fn: Function<result: any>) : Promise<any, Error>`<br>
Get the result of the promise once resolve.
- `Promise.catch(fn: Function.<error: Error>)`<br>
- `Promise.catch(fn: Function<error: Error>) : Promise<any, Error>`<br>
Get the error of the promise when rejected.
- `Promise.cancel()`<br>
- `Promise.cancel() : Promise<any, Error>`<br>
A running task can be cancelled. The worker executing the task is enforced to terminate immediately.
The promise will be rejected with a `Promise.CancellationError`.
- `Promise.timeout(delay: number)`<br>
- `Promise.timeout(delay: number) : Promise<any, Error>`<br>
Cancel a running task when it is not resolved or rejected within given delay in milliseconds. The timer will start when the task is actually started, not when the task is created and queued.
The worker executing the task is enforced to terminate immediately.
The promise will be rejected with a `Promise.TimeoutError`.
Expand Down Expand Up @@ -323,13 +323,13 @@ const pool3 = workerpool.pool({ maxWorkers: 7 });

A worker is constructed as:

`workerpool.worker([methods: Object.<String, Function>] [, options: Object])`
`workerpool.worker([methods: Object<String, Function>] [, options: Object]) : void`

Argument `methods` is optional can can be an object with functions available in the worker. Registered functions will be available via the worker pool.

The following options are available:

- `onTerminate: ([code: number]) => Promise.<void> | void`. A callback that is called whenever a worker is being terminated. It can be used to release resources that might have been allocated for this specific worker. The difference with pool's `onTerminateWorker` is that this callback runs in the worker context, while `onTerminateWorker` is executed on the main thread.
- `onTerminate: ([code: number]) => Promise<void> | void`. A callback that is called whenever a worker is being terminated. It can be used to release resources that might have been allocated for this specific worker. The difference with pool's `onTerminateWorker` is that this callback runs in the worker context, while `onTerminateWorker` is executed on the main thread.


Example usage:
Expand Down Expand Up @@ -392,7 +392,7 @@ workerpool.worker({

You can send data back from workers to the pool while the task is being executed using the `workerEmit` function:

`workerEmit(payload: any)`
`workerEmit(payload: any) : unknown`

This function only works inside a worker **and** during a task.

Expand Down