npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

simple-tasks

v1.0.2

Published

Easy way to dispatch your functions to a separate process making them truly async

Downloads

23

Readme

node-simple-tasks

Node.js module for executing functions in a separate process. Simple design depends only on Node.js core ensuring high compatibility with future versions.

Importing the module with require() creates a new worker process and returns it's task queue. Tasks are executed sequentially in same order they were scheduled. If you need more work queues, simply require() the module again.

Functions scheduled to the queue will run in the worker process context which is completely independent from the main thread. Functions and arguments are serialized to string when passed to the worker process, so you have to make sure that you only pass objects that can be serialized to string and back (functions can). Functions must be self-contained and only reference their own arguments. Arguments can be functions too, same restrinctions apply to them.

Installation

npm install simple-tasks

Usage

Each require('simple-stasks') call created a new worker thread and returns a task queue object for it:

class Queue

    method  push( function, arg1, arg2, ..., callback)

Schedules function to be called with arg1, arg2, ..., resultCallback arguments under worker process context. The callback function will be called when task is finished, it is a required argument (last argument of push() is always interpreted as callback), but you can pass null explicitly instead of it (see first example). The resultCallback argument which is always passed to function can be used to return data back to main thread: simply pass the data as the first argument and it will be delivered as callback first argument.

    method  stop()

Cancels all pending tasks and stops worker process.

Examples

var tasks = require('simple-tasks');

tasks.push(function() {
  console.log("This will be executed by a separate process!");
}, null);

If the function which will run in worker process calls any other user functions, they may be passed to it as arguments. The only limitation is that all arguments must be self-contained.

var tasks = require('simple-tasks');

function printArgument(arg) {
  console.log('argument: ' + arg);
}

function doStuff(printArgument) {
  printArgument('example');
}

tasks.push(doStuff, printArgument, function() {
  console.log('task finished');
});

You can use worker function callback argument for passing data back from the worker process to main. Apart from user provided arguments, the worker process will always pass result callback function to the worker thread. The callback takes one argument which will be passed back to main thread.

var tasks = require('simple-tasks');

function approximatePi(callback) {
  callback(3.1416);
}

tasks.push(approximatePi, function(pi) {
  console.log('The approximate value of Pi is: ' + pi);
});