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

funcmt

v0.1.0

Published

Run a plain function on a [`worker_threads`](https://nodejs.org/api/worker_threads.html) worker by serializing it with `fn.toString()` — no separate worker file to write and maintain.

Readme

funcmt

Run a plain function on a worker_threads worker by serializing it with fn.toString() — no separate worker file to write and maintain.

The catch with fn.toString() is that the worker has no idea where the function originally lived, so any require(...) / import(...) inside it — relative paths or bare package names — breaks. funcmt parses the function's source with the TypeScript compiler API and rewrites those specifiers to absolute paths before shipping the function off, so they resolve correctly regardless of the worker's own location.

Install

npm install funcmt

typescript (^5) is a peer dependency — funcmt uses its compiler API to parse function source. Requires Node.js >=22.

Usage

import { runInWorker } from "funcmt";

function heavyWork(n: number) {
  const { fib } = require("./fib"); // resolved to an absolute path before running
  return fib(n);
}

const result = await runInWorker(heavyWork, [40], import.meta.url);

fromFile (the third argument — import.meta.url or __filename) anchors any relative specifiers found inside fn.

API

runInWorker(fn, args, fromFile)

Runs fn(...args) on a new worker thread and resolves with its return value (or rejects with whatever it throws).

  • fn — a plain function, arrow, or async function. Object/class method shorthand (foo() {}) doesn't stringify to a valid standalone expression and isn't supported.
  • args — arguments passed to fn inside the worker.
  • fromFile — the file fn was written in, used to resolve its relative/bare specifiers.

rewriteSpecifiersToAbsolute(code, fromFile)

The lower-level primitive runInWorker is built on. Parses code, finds every require(...), dynamic import(...), and static import/export module specifier, and rewrites each one to an absolute location resolved from fromFile:

  • require(...) specifiers become raw absolute filesystem paths.
  • import(...) / import ... from specifiers become file:// URLs — Node's ESM loader doesn't accept a bare Windows-style absolute path.
  • Node builtins (node:fs, path, ...) and specifiers that can't be resolved (e.g. a variable instead of a string literal) are left untouched.

Limitations

  • Only functions whose toString() is a valid standalone expression can be run — no object/class method shorthand.
  • Specifiers must be string literals; require(someVariable) can't be statically rewritten.
  • No built-in worker pool, timeout, or cancellation — runInWorker spawns one worker per call.

Development

See .github/CONTRIBUTING.md.

License

MIT