
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
taskbatcher
Advanced tools
TaskBatcher is a utility that lets you easily run multiple tasks in a single batch. Partially inspired by Facebook's DataLoader
Install with npm
npm i --save taskbatcher
TaskBatcher uses the global Promise class, so use a polyfill or transpile with babel or tell everyone who uses your website to get a decent browser.
You'll need to provide a runTasksFn function when creating a new TaskBatcher.
import TaskBatcher from 'taskbatcher';
const taskBatcher = new TaskBatcher(keys => runTasks(keys))
The runTasksFn function takes on argument, [key], and should return a Promise that either resolves with [value | Error] or { [key]: value | Error, [key2]: value2 | Error }.
Then add tasks to the batcher using addTask. TaskBatcher will add your keys to a queue, and will run your runTasksFn function after a delay (default 50ms) since the last time the function was called (aka, it debounces). They delay's won't stack indefinitely, however, and will eventually run after the maxWait ( default 250ms) limit is reached.
taskBatcher.addTask(1).then(data => console.log(`Data received! ${data}`));
TaskBatcher was initially designed around making requests, but it ended up being generic enough to handle any sort of task. Here's how to use it to make api requests:
const getUsersByIds = async (ids) => fetch(`/users?id=${ids.join(',')}`).then(resp => resp.json());
const userFetcher = new TaskBatcher(getUsersByIds);
userFetcher.addTask(1).then(user => console.log(`Here's your user: ${user}`));
userFetcher.addTask(2).then(user => console.log(`Here's another user: ${user}`));
userFetcher.addTask(3).then(user => console.log(`And another user: ${user}`));
In the above example, only one request will be made (fetch('/users?id=1,2,3')).
In case you think it's weird to call addTask on userFetcher, feel free to rename the addTask function using the renameAddTaskTo option like so:
const userFetcher = new TaskBatcher(getUsersByIds, { renameAddTaskTo: 'fetch' });
userFetcher.fetch(1).then(user => console.log(`Here's your user: ${user}`));
Note Flow doesn't currently support indexable signature for class declarations, so if you're using flow, you should probably just not do this.
new TaskBatcher(runTasksFn, [, options])Create a new TaskBatcher given a task running function and options.
runTasksFn: A function which accepts an Array of keys, and returns a Promise which resolves to either an Array of values or a single object with key/value pairs.
options: An optional object of options:
addTask function to the given valueaddTask(key)Adds a key, returning a Promise for the value represented by that key.
FAQs
A utility that lets you easily run multiple tasks in a single batch
We found that taskbatcher demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.