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 🙏

© 2025 – Pkg Stats / Ryan Hefner

threadless

v0.0.6

Published

Threading for nodejs and the browser built on web workers

Downloads

12

Readme

threadless

Threading for nodejs and the browser built on web workers

build status

Installation

This module is installed via npm:

$ npm install threadless

Background

Javascript can handle high level of concurrency by using it's single-threaded event-loop. This works as long as you don't have CPU intensive operations that block the loop and make your user-interface or server non-responsive.

However, Web Workers (or spawning a child process in node.js) allow you to run in another process/thread. This module provides a standard interface for running parallel tasks in node.js or in the browser. The node.js implementation works on workerjs.

Example Usage

var Thread = require('threadless');

// create a function for background execution
// NB: The function can't bind to any closures because it will be serialized
// and run in a Web Worker
var thread = new Thread(function (n, cb) {
  // CPU intensive operation that would block the event loop
  function fibo(n) {
    return n > 1 ? fibo(n - 1) + fibo(n - 2) : 1;
  }

  cb(null, fibo(n));
});
// call the web worker thread with a value of 30
thread.run(30, function (err, result) {
  if (err) return done(err);
  expect(result).to.equal(1346269);
  done();
});

API

new Thread(fn)

Creates a new Thread instance based on the function passed in:

  • fn - The function that will be run in the background. Note that this function will get serialized so any closure references won't work. Any variables you want to pass through should go through the arguments.

thread.run([arg1, arg2,] cb)

Runs the function in another thread with the following arguments.

  • arguments - list of arguments that will be passed to the thread function. the arguments can be functions, but they will be serialized before being sent to the thread function (so no closure scope will be passed).
  • cb - the callback that will be called by the thread function. Ie. the function must be asynchronous.

thread.kill()

Kills the thread.