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

macrotask

v3.0.0

Published

A cross browser macrotask library

Readme

Macrotask Build Status

npm install macrotask

macrotask is a macrotask library based on immediate, and is almost identical except that immediate is a microtask, the difference as stated by Dominic here

The setImmediate API, as specified, gives you access to the environment's task queue, sometimes known as its "macrotask" queue. This is crucially different from the microtask queue used by web features such as MutationObserver, language features such as promises and Object.observe, and Node.js features such as process.nextTick. Each go-around of the macrotask queue yields back to the event loop once all queued tasks have been processed, even if the macrotask itself queued more macrotasks. Whereas, the microtask queue will continue executing any queued microtasks until it is exhausted.

In practice, what this means is that if you call setImmediate inside of another task queued with setImmediate, you will yield back to the event loop and any I/O or rendering tasks that need to take place between those calls, instead of executing the queued task as soon as possible.

The standard as it eventually got codified was that macrotasks were supposed to only get a single task from the queue per cycle instead of emptying the queue and cycling event loop before calling any recursive tasks.

This library ends up splitting the difference by tacking advantage of requestIdleCallback when available to run one or more tasks from the queue depending on how long they take, for environments that don't have requestIdleCallback we give ourselves a time limit of 10ms after which we will cycle the event loop before executing more tasks. At least one task will always be executed per loop.

npm install --save macrotask

provides 2 methods, run and clear, they work just like setImmediate does where run enqueues a task

const task = macrotask.run(function (a, b) {
  console.log(a, b);
}, 'hello', 'there');
// prints hello there

and clear cancels it

const task = macrotask.run(function (a, b) {
  console.log(a, b);
}, 'hello', 'there');
macrotask.clear(task);
// does not print anything

you can use it via a number of different methods:

// commonjs style in node or browserify
const macrotask = require('macrotask');

// es6 style with rollup or babel
import macrotask from 'macrotask';
// or
import {run, clear} from 'macrotask';

or you can just drop the macrotask.js or macrotask.min.js scripts from the root directory of the repo.