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

jsrunnable

v0.4.0

Published

A wrapper to make web workers easier to use like RPC and etc.

Downloads

17

Readme

JS Runnable

An easy way to do workers kinda??? I dunno, I just wanted to see if it would work.

Basic Usage:

var runner = new Runnable();
const myWorkerFunction = runner.add(() => console.log('hello from webworker'));
myWorkerFunction();

You can pass arguments:

var runner = new Runnable();
const myWorkerFunction = runner.add((a,b,c,d) => console.log('hello from webworker', a, b, c, d));
myWorkerFunction(1,2,3,4);

You can return results (as a promise):

var runner = new Runnable();
const myWorkerFunction = runner.add((a,b,c,d) => { return a + b + c + d; });
myWorkerFunction(1,2,3,4).then(result => console.log(result));

It can run on multiple workers:

var runner = new Runnable();
var workerCount = 4;
const myWorkerFunction = runner.add((a,b,c,d) => { return a + b + c + d; }, workerCount);
myWorkerFunction(1,2,3,4).then(result => console.log(result));
myWorkerFunction(4,4,4,4).then(result => console.log(result));

API:

new Runnable()

Create a new runnable to spin up workers, and be able to attach functions to them.

runnable.add([function], workerCount[number])

Attach a function to the runnable; It returns a wrapped function, that you can call to run the function on the web worker. This call will return a promise resolved with the result of the function call on the worker. The worker count can be anything, but will limit internally to the number of available threads.

Classes

Functions

Runnable

Runnable

Kind: global class

new Runnable()

Constructor

runnable.add(func) ⇒ function

Add functions to workers to call.

Kind: instance method of Runnable
Returns: function - A wrapped function that calls the worker and returns results in a promise.

| Param | Type | Description | | --- | --- | --- | | func | function | Function to assign to workers. |

Utils

Utilities for jsrunnable

Kind: global class

Utils.funcToString(func) ⇒ string

Stringifies a function

Kind: static method of Utils
Returns: string - Stringified function.

| Param | Type | Description | | --- | --- | --- | | func | function | Function to stringify. |

Utils.buildWorker(workerFunc) ⇒ Worker

Build a worker containing the given function.

Kind: static method of Utils
Returns: Worker - worker The worker.

| Param | Type | Description | | --- | --- | --- | | workerFunc | function | The function to build a worker for. |

Utils.functionToMessage(func) ⇒ Object

Turn a function into an object for sending to a worker.

Kind: static method of Utils
Returns: Object - Function message object.

| Param | Type | | --- | --- | | func | function |

Utils.randomId(prefix) ⇒ String

Returns a random id.

Kind: static method of Utils
Returns: String - A string id.

| Param | Type | Description | | --- | --- | --- | | prefix | String | A string to prefix the id with. |

worker()

worker

Kind: global function

worker~postResult(message, result)

Posts the result of a called worker function back to the main thread.

Kind: inner method of worker

| Param | Type | Description | | --- | --- | --- | | message | Object | Message object for function called. | | result | * | The result of the function call. |

worker~postError(message, err)

Post an error back to the main thread.

Kind: inner method of worker

| Param | Type | Description | | --- | --- | --- | | message | Object | the message which called | | err | Object | String | The error to post to main thread. |

worker~compile(message)

Create the function from the message object

Kind: inner method of worker

| Param | Type | Description | | --- | --- | --- | | message | Object | Message object from main thread. |

worker~call(message)

Call the function from the message object.

Kind: inner method of worker

| Param | Type | Description | | --- | --- | --- | | message | Object | Message object from main thread. |