
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
[![NPM version][npm-image]][npm-url] [![build status][ci-image]][ci-url] [![npm download][download-image]][download-url]
Ework.
Execute your tasks on another thread or in parallel, with a simple to use and cross-platform (Node.js >=10 and modern browsers) API.
$ npm i ework
import { Ework } from 'ework';
async function run() {
const worker = new Ework((value) => value ** 2);
const value = await worker.execute(6); // 36
const values = await worker.map([1, 2, 3]); // [1, 4, 9]
await worker.terminate();
}
run().catch((e) => {
console.error(e);
process.exit(1);
});
new Ework(executor[, options])executorMust be a function or async function. It will receive the argument passed to
execute(). The code of this function will be passed to the worker, but not
its context, so it shouldn't use variables from its surrounding scope.
optionsAn object with the following optional properties:
init: Function
Initialization function that will be executed after spawning the worker and
before sending jobs to it. If the function returns a Promise, it will be awaited.initData: any
Optional data passed to the init function of each spawned worker.numWorkers: number
Number of workers to spawn. If this option is specified, maxWorkers and
minFreeThreds will be ignored.maxWorkers: number (Default: number of logical CPUs)
Maximum number of workers that will be spawned. This number must be at least
one and is only taken into account if smaller than the total number of CPUs.minFreeThreads: number (Default: 1)
Minimum number of CPU threads that will be kept free.
Along with maxWorkers, this will determine the number of workers that will
be spawned. If there is only one CPU, this option is ignored and one worker
will be spawned.Ework#execute(value)Run the executor on one of the free workers with the passed value. Returns a Promise that will be resolved with the value returned from the executor. If no worker is free, the call is added to a FIFO queue.
Ework#map(iterable)Send each value of the iterable to the executor. Once every value was processed, resolves with an array of results.
Ework#terminateTerminate all the spawned workers. This must be called to cleanup if the ework instance won't be used anymore.
FAQs
[![NPM version][npm-image]][npm-url] [![build status][ci-image]][ci-url] [![npm download][download-image]][download-url]
We found that ework demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.