Skip to content

Commit

Permalink
docs: update README for jest-worker (#9788)
Browse files Browse the repository at this point in the history
* docs: update README for jest-worker

* docs: update CHANGELOG and documentation for JestPlatform
  • Loading branch information
ahnpnl committed Apr 16, 2020
1 parent da63789 commit 4010fdd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/JestPlatform.md
Expand Up @@ -119,7 +119,7 @@ You can read more about `jest-validate` in the [readme file](https://github.com/

## jest-worker

Module used for parallelization of tasks. Exports a class `Worker` that takes the path of Node.js module and lets you call the module's exported methods as if they were class methods, returning a promise that resolves when the specified method finishes its execution in a forked process.
Module used for parallelization of tasks. Exports a class `JestWorker` that takes the path of Node.js module and lets you call the module's exported methods as if they were class methods, returning a promise that resolves when the specified method finishes its execution in a forked process.

### Example

Expand Down
18 changes: 9 additions & 9 deletions packages/jest-worker/README.md
Expand Up @@ -21,10 +21,10 @@ This example covers the minimal usage:
### File `parent.js`

```javascript
import Worker from 'jest-worker';
import JestWorker from 'jest-worker';

async function main() {
const worker = new Worker(require.resolve('./Worker'));
const worker = new JestWorker(require.resolve('./Worker'));
const result = await worker.hello('Alice'); // "Hello, Alice"
}

Expand All @@ -47,7 +47,7 @@ Since `worker_threads` are considered experimental in Node, you have to opt-in t

## API

The only exposed method is a constructor (`Worker`) that is initialized by passing the worker path, plus an options object.
The only exposed method is a constructor (`JestWorker`) that is initialized by passing the worker path, plus an options object.

### `workerPath: string` (required)

Expand Down Expand Up @@ -93,11 +93,11 @@ The arguments that will be passed to the `setup` method during initialization.

`jest-worker` will automatically detect if `worker_threads` are available, but will not use them unless passed `enableWorkerThreads: true`.

## Worker
## JestWorker

### Methods

The returned `Worker` instance has all the exposed methods, plus some additional ones to interact with the workers itself:
The returned `JestWorker` instance has all the exposed methods, plus some additional ones to interact with the workers itself:

#### `getStdout(): Readable`

Expand Down Expand Up @@ -139,10 +139,10 @@ This example covers the standard usage:
### File `parent.js`

```javascript
import Worker from 'jest-worker';
import JestWorker from 'jest-worker';

async function main() {
const myWorker = new Worker(require.resolve('./Worker'), {
const myWorker = new JestWorker(require.resolve('./Worker'), {
exposedMethods: ['foo', 'bar', 'getWorkerId'],
numWorkers: 4,
});
Expand Down Expand Up @@ -183,10 +183,10 @@ This example covers the usage with a `computeWorkerKey` method:
### File `parent.js`

```javascript
import Worker from 'jest-worker';
import JestWorker from 'jest-worker';

async function main() {
const myWorker = new Worker(require.resolve('./Worker'), {
const myWorker = new JestWorker(require.resolve('./Worker'), {
computeWorkerKey: (method, filename) => filename,
});

Expand Down

0 comments on commit 4010fdd

Please sign in to comment.