Security News
Internet Archive Hacked, 31 Million Record Compromised
The Internet Archive's "Wayback Machine" has been hacked and defaced, with 31 millions records compromised.
jest-worker
Advanced tools
The jest-worker npm package is a module designed to make it easy to move heavy processing tasks to child processes, thus enabling better use of multi-core systems and improving the performance of Node.js applications. It is primarily used to parallelize work across processes and manage communication between the main thread and worker threads.
Creating a Worker Pool
This feature allows you to create a pool of workers that can execute functions from a specified module file. The 'heavyTask.js' module would export the functions that you want to run on separate threads.
const { Worker } = require('jest-worker');
const worker = new Worker(require.resolve('./heavyTask.js'));
const result = await worker.myHeavyTask(args);
Sending and Receiving Data
With jest-worker, you can send data to worker threads for processing and receive the processed data back in the main thread. The 'dataProcessor.js' module would contain the 'processData' function that handles the data processing logic.
const { Worker } = require('jest-worker');
const worker = new Worker(require.resolve('./dataProcessor.js'));
const processedData = await worker.processData(rawData);
Ending Worker Processes
This feature allows you to properly shut down the worker processes once you're done with them, freeing up system resources.
const { Worker } = require('jest-worker');
const worker = new Worker(require.resolve('./task.js'));
// ... use the worker
await worker.end();
The 'workerpool' package is similar to 'jest-worker' in that it also allows you to offload tasks to a pool of workers. It provides a different API and additional features like timeouts and the ability to cancel tasks.
The 'threads' package is another alternative that offers a high-level abstraction for working with Web Workers or Node's Worker Threads. It has a different API design and supports transferable objects for efficient data transfer.
The 'tiny-worker' package is a minimalistic implementation of the Web Workers API for Node.js. It is lightweight and simple to use but does not offer the same level of functionality or control over worker management as 'jest-worker'.
jest 20.0.0
--projects
option to run one instance of Jest in multiple projects at the same time. (#3400)expect
matchers through .resolves
and .rejects
. (#3068)expect.hasAssertions()
function similar to expect.assertions()
. (#3379)this.equals
function exposed to custom matchers. (#3469)valid-expect
lint rule in eslint-plugin-jest
. (#3067)@jest-environment
in the docblock. (#2859)reporters
in the configuration. (#3349)jest-editor-support
into a separate jest-test-typescript-parser
package. (#2973)babel-jest
to look up the babel
field in package.json
as a fallback.jest-editor-support
's parser to not crash on incomplete ASTs. (#3259)jest-resolve
to use is-builtin-module
instead of resolve.isCore
. (#2997)jest-snapshot
to normalize line endings in the serialize
function. (#3002)--silent
flag. (#3003)notify
option not taking precedence over config option. (#3340)jest-editor-support
. (#3344)undefined
. (#3354)expect
. (#3306)expect.assertions
error. (#3033)jest-file-exists
. (#3105)Config
type. (#3366)jest-file-exists
. (#3101)FAQs
Module for executing heavy tasks under forked processes in parallel, by providing a `Promise` based interface, minimum overhead, and bound workers.
The npm package jest-worker receives a total of 51,574,114 weekly downloads. As such, jest-worker popularity was classified as popular.
We found that jest-worker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Internet Archive's "Wayback Machine" has been hacked and defaced, with 31 millions records compromised.
Security News
TC39 is meeting in Tokyo this week and they have approved nearly a dozen proposals to advance to the next stages.
Security News
Our threat research team breaks down two malicious npm packages designed to exploit developer trust, steal your data, and destroy data on your machine.