Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-worker

Package Overview
Dependencies
Maintainers
5
Versions
171
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-worker

Module for executing heavy tasks under forked processes in parallel, by providing a `Promise` based interface, minimum overhead, and bound workers.

  • 30.0.0-alpha.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
59M
increased by2.73%
Maintainers
5
Weekly downloads
 
Created

What is jest-worker?

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.

What are jest-worker's main functionalities?

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();

Other packages similar to jest-worker

FAQs

Package last updated on 16 Nov 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc