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

turnlet

v0.1.1

Published

A tiny TypeScript library for chunking array work to improve Interaction to Next Paint (INP).

Readme

Turnlet

Small turns. Responsive interfaces.

A tiny TypeScript library for chunking array work to improve Interaction to Next Paint (INP).

Turnlet yields between small chunks so the browser can handle input and paint. Two functions, stable ordering, cancellation, and no runtime dependencies.

Inside a browser turn

Chrome DevTools recording of a real search across 50,000 products, using forEachInChunks with a 5 ms budget:

Chrome DevTools Performance panel showing Turnlet’s short input handler, separate search tasks, and INP breakdown

A local recording at 4× CPU slowdown, zoomed to the interaction; individual timings vary. Blocking comparison and downloadable traces · Controlled case study

Install

npm install turnlet

ESM-only, with TypeScript declarations and no runtime dependencies.

Usage

import { mapInChunks, forEachInChunks } from 'turnlet';

const doubled = await mapInChunks([2, 4], (value) => value * 2);
// [4, 8]

let total = 0;
await forEachInChunks([2, 4], (value) => {
  total += value;
});
// total === 6

mapInChunks returns a complete, ordered array. forEachInChunks resolves with void, without allocating a mapped output array. Callbacks receive (item, index) and must be synchronous.

Options

| Option | Default | Meaning | | ---------- | ------- | ---------------------------------------------------------------- | | budgetMs | 5 | Approximate chunk budget; finite, greater than 0, and at most 50 | | signal | None | AbortSignal for cooperative cancellation |

Non-empty operations yield before the first callback. The scheduler uses native scheduler.yield() when available and a timer fallback otherwise.

Cancellation

import { mapInChunks } from 'turnlet';

const controller = new AbortController();
const reason = new Error('Superseded');
const operation = mapInChunks([1], (value) => value, {
  signal: controller.signal,
});
controller.abort(reason);

try {
  await operation;
} catch (error) {
  if (error !== reason) throw error;
}

Rejection preserves the original abort reason or callback error. A rejected map does not expose a partial result. For replaceable work, also guard the final render against stale requests; see the validation recipe.

Limits

  • Work stays on the main thread. A running callback cannot be interrupted.
  • One expensive callback can exceed the budget; completed side effects are not rolled back.
  • Input must be a dense array. Do not mutate it or relevant item contents until settlement.
  • Async callbacks and thenable results are unsupported.
  • Small workloads may favor a plain loop. There is no guaranteed INP score or shared budget across operations.

ESM-only, with TypeScript declarations and no runtime dependencies. Browser behavior is tested in Chromium, Firefox, and WebKit; minimum browser versions are not specified.

API guide · Exact contract · Case study · Release checklist

MIT © Valeriia Radchenko