Skip to content

Commit

Permalink
fix: worker_threads API changes a lot
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Jul 13, 2021
1 parent 770364a commit 83399fc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Perform async work synchronously in Node.js using `worker_threads`, or `child_pr
- [Usage](#usage)
- [Install](#install)
- [API](#api)
- [`Node` compatibility](#node-compatibility)
- [Envs](#envs)
- [TypeScript](#typescript)
- [Benchmark](#benchmark)
Expand Down Expand Up @@ -72,10 +71,6 @@ You must make sure:
1. if `worker_threads` is enabled (by default), the `result` is serialized by [`Structured Clone Algorithm`](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm)
2. if `child_process` is used, the `result` is serialized by `JSON.stringify`

### `Node` compatibility

`worker_threads` is available from `Node 8.10` with flag `--experimental-worker` and only enabled by default from `Node 12.11`, so you may want to enable it by using `node --experimental-worker` or setting env `NODE_OPTIONS="--experimental-worker"` for better performance.

### Envs

1. `SYNCKIT_WORKER_THREADS`: whether or not enable `worker_threads`, it's enabled by default, set as `0` to disable
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ try {
} catch {
/* istanbul ignore next */
console.warn(
'`worker_threads` is not available in current environment,\nyou may want to enable it by using `node --experimental-worker` or setting env `NODE_OPTIONS="--experimental-worker"` for better performance',
'`worker_threads` is not available in current environment, `Node >= 12` is required',
)
}

Expand Down

0 comments on commit 83399fc

Please sign in to comment.