Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on Apr 25, 2024 via pnpm

jest-worker 27.5.1

Module for executing heavy tasks under forked processes in parallel, by providing a `Promise` based interface, minimum overhead, and bound workers.
Package summary
Share
0
issues
1
license
6
MIT
Package created
3 Oct 2017
Version published
8 Feb 2022
Maintainers
5
Total deps
6
Direct deps
3
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
6 Packages, Including:
@types/node@20.12.7
has-flag@4.0.0
jest-worker@27.5.1
merge-stream@2.0.0
supports-color@8.1.1
undici-types@5.26.5
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

3
All Dependencies CSV
β“˜ This is a list of jest-worker 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
@types/node20.12.71.94 MBMIT
prod
merge-stream2.0.02.21 kBMIT
prod
supports-color8.1.13.64 kBMIT
prod

Visualizations

Frequently Asked Questions

What does jest-worker do?

"Jest-worker" is an npm module designed to execute heavy tasks under forked processes in parallel. It provides a Promise-based interface with minimum overhead and bound workers, thus ensuring efficiency. It enables the loading of a module in all forked processes by utilizing an absolute path of the module. This makes it possible to await all the methods exposed on the parent process as promises.

How do you use jest-worker?

Installation of this module requires running the command yarn add jest-worker in the terminal. After installation, create the worker file and the parent file. In the worker file, define the functions that the workers will execute. For instance, you can have a hello() function that takes a string parameter and returns a greeting. In the parent file, import jest-worker and create a new worker instance, passing the path of the worker file to the constructor. Then, call the hello() function on the worker instance, passing in a string as an argument. The function will return a promise, so make sure to await it. A basic usage example can look like this:

File parent.js

import {Worker as JestWorker} from 'jest-worker';

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

main();

File worker.js

export function hello(param) {
  return `Hello, ${param}`;
}

Where are the jest-worker docs?

The documentation for "jest-worker" can be found in its GitHub repo README file which is located at git+https://github.com/jestjs/jest.git. The README file provides comprehensive information on how to install and use the module, including basic and advanced usage examples. You'll find detailed descriptions of the module's API, including all the options you can pass to the JestWorker constructor. It also provides explanations of concepts like bound workers and worker IDs and how to setup and teardown the child process. The README file is detailed and practical, making it an excellent resource for JavaScript developers working with jest-worker.