Socket
Socket
Sign inDemoInstall

jest-worker

Package Overview
Dependencies
9
Maintainers
1
Versions
170
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 21.3.0-beta.1 to 21.3.0-beta.2

2

package.json
{
"name": "jest-worker",
"version": "21.3.0-beta.1",
"version": "21.3.0-beta.2",
"repository": {

@@ -5,0 +5,0 @@ "type": "git",

@@ -17,3 +17,27 @@ # jest-worker

## Example
This example covers the minmal usage:
### File `parent.js`
```javascript
import Worker from 'jest-worker';
async function main() {
const worker = new Worker(require.resolve('./worker'));
const result = await worker.hello('Alice'); // "Hello, Alice"
}
main();
```
### File `worker.js`
```javascript
export function hello(param) {
return 'Hello, ' + param;
}
```
## API

@@ -43,3 +67,3 @@

### `computeWorkerKey: (method: string, ...args: Array<any>) => ?string` (optional)
#### `computeWorkerKey: (method: string, ...args: Array<any>) => ?string` (optional)

@@ -72,29 +96,4 @@ Every time a method exposed via the API is called, `computeWorkerKey` is also called in order to bound the call to a worker. This is useful for workers that are able to cache the result or part of it. You bound calls to a worker by making `computeWorkerKey` return the same identifier for all different calls. If you do not want to bind the call to any worker, return `null`.

# More examples
## Minimal example
This example covers the minmal usage:
### File `parent.js`
```javascript
import Worker from 'jest-worker';
async function main() {
const worker = new Worker(require.resolve('./worker'));
const result = await worker.hello('Alice'); // "Hello, Alice"
}
main();
```
### File `worker.js`
```javascript
export function hello(param) {
return 'Hello, ' + param;
}
```
## Standard usage

@@ -110,6 +109,5 @@

async function main() {
const myWorker = new Worker({
const myWorker = new Worker(require.resolve('./worker'), {
exposedMethods: ['foo', 'bar'],
numWorkers: 4,
workerPath: require.resolve('./worker'),
});

@@ -149,6 +147,4 @@

async function main() {
const myWorker = new Worker({
const myWorker = new Worker(require.resolve('./worker'), {
computeWorkerKey: (method, filename) => filename,
exposedMethods: ['foo', 'bar'],
workerPath: require.resolve('./worker'),
});

@@ -155,0 +151,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc