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

universal-worker

v0.1.0

Published

Worker that Works in All Environments, including Internet Explorer.

Readme

:warning: this library is under active development and breaking changes are expected


universal-worker: beta

Worker that Works in All Environments, including Internet Explorer.

install

npm install universal-worker

features

  • Converts import to require for NodeJS Worker Threads
  • Works in Internet Explorer with Frame Worker
  • Automatically Wrap Files with Worker Events
  • Works with Webpack
  • Supports Data URLs and File URLs
  • Use Web Worker API in NodeJS

limitations

  • No Support for importScripts outside the Browser
  • import syntax runs as is without fallback conversion, in the browser

supported API

usage

loading

You can load the universal-worker in several ways:

CommonJS Require

const { Worker } = require("universal-worker");

JavaScript Modules

import { Worker } from "universal-worker";

Script Tag in the Browser

When you load universal worker via a script tag, it will check if Worker is fully supported (including transfers). If not, it will polyfill Worker with a "FrameWorker" that fakes a Web Worker by running the worker script in an iframe.

<script src="https://unpkg.com/universal-worker"></script>

creating the worker

const worker = new Worker("./path/to/worker.js");

inside the worker.js file

You can define your worker in three different ways: (1) events, (2) module.exports = function, and (3) export default function

using Web Worker Events

You can define your worker using Web Worker events. When run on NodeJS, universal-worker will automatically polyfill these web worker events, so your worker script will automatically use the worker_threads API without having to create a separate worker file.

onmessage = event => {
  const { data } = event;
  const result = Math.pow(data, 2);
  const transferList = undefined;
  postMessage(result, transferList);
};

using module.exports

If you don't define an onmessage event in your worker script, universal-worker will automatically look for module.exports and assume that a message should be sent as an argument to this function.

module.exports = data => Math.pow(data, 2);

using export default function

If you export your function using, export syntax, universal-worker will automatically pass a message onto the default export

export default function square (data) {
  return Math.pow(data, 2);
});