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

poolcess

v1.2.1

Published

A Promise Child Process Pool

Readme

Description

Poolcess is a Promise Child Process Pool that allows for the safe execution of random Javascript code. It supports timeouts and task cancellation as well as passing/receiving context to/from the code.

The motivation behind this package is the need to force terminate executing code even if the event loop is blocked which is currently not possible with the worker threads. A performance benchmark hasn't been carried out yet to assess if a worker thread pool like Piscina is faster during execution when compared to a child process pool. Worker threads do allow for faster exchange of data as well as faster 'spawn' times but since Poolcess keeps the processes alive the differences should be negligible. Benchmarks and feedback are welcome as well as any issues/suggestions!

Features

  1. Isolated code execution.
  2. Cancellable code execution even with the event loop blocked on child process.
  3. Code execution timeout.
  4. Passing context/arguments to the code.
  5. Return values from code execution.

Installation

$ npm i poolcess

Usage

import { Poolcess } from 'poolcess';

// Start a pool with 10 child processes
const pool = new Poolcess(10);

// Execute an infinite loop with a timeout of 10s
let context: Record<string, unknown> = {}; // Hashmap Interface is exported by poolcess package
pool.execTask(
  randomUUID(), // A Task Id
  'while(1) console.log(1);', // The code to execute
  context, // Context to pass to the code.
  10000).catch((out) => console.log(out.error)); // Prints Timeout after 10s.

// Abort a task
let context: Record<string, unknown> = {};
const taskId = randomUUID();
pool.execTask(
  taskId, // A Task Id
  'console.log(1);', // The code to execute
  context, // Context to pass to the code.
  10000).catch((out) => console.log(out.error)); // Prints User Aborted.

pool.abortTask(taskId, TaskAbortReason.ABORT); // TaskAbortReason.ABORT or TaskAbortReason.TIMEOUT

// Passing/Receiving context
let context: Record<string, unknown> = {};
context.counter = 10;
context.output = 0;

const result = await pool.execTask(
  taskId, // A Task Id
  'for(let i=0;i<this.counter;i++) this.output++', // The code to execute
  context, // Context to pass to the code.
  10000).catch((out) => console.log(out.error)); // Prints Timeout.

console.log(result.output) // Prints 10

// Passing arguments to the code
// Comparing two strings
let context: Record<string, unknown> = {};
const args: Map<string, any> = new Map();
args.set('stringA', 'testargstring');
args.set('stringB', 'testargstring');
const result = await pool.execTask(
  randomUUID(),
  'if(stringA === stringB) ' +
    'this.outputs.result = true; else this.outputs.result = false',
  context, // Context is still required to save values as code return values are still not implemented
  10000,
  args,
);
console.log(result.output.result) // Prints true

// Sum two numbers
let context: Record<string, unknown> = {};
context.outputs = {};
const args: Map<string, any> = new Map();
args.set('varA', 2);
args.set('varB', 12);
const result = await pool.execTask(
  randomUUID(),
  'this.outputs.result = varA + varB',
  context, // Context is still required to save values as code return values are still not implemented
  10000,
  args,
);
console.log(result.output.result) // Prints 14

// Return the sum two numbers
let context: Record<string, unknown> = {};
context.return = null;
const args: Map<string, any> = new Map();
args.set('varA', 2);
args.set('varB', 12);
const result = await pool.execTask(
  randomUUID(),
  'return varA + varB',
  context, // Context is still required to save values as code return values are still not implemented
  10000,
  args,
);
console.log(result.output.result) // Prints 14

Clean up resources

Poolcess provides the method destroy() that will kill any active processes as well as remove/abort all pending/active tasks. No further actions are possible in the pool.

Test

# unit tests
$ npm run test

Build

$ npm run build