Registry / devops / asap
library2.0.6jsnpmunverified

A high-priority task queue for Node.js and browsers (version 2.0.6 stable; last release 2019+; no active development). Schedules callbacks to run as soon as possible, before yielding for I/O, reflow, or redrawing. Uses microtasks/nextTick/setTimeout depending on environment. Faster than setImmediate/process.nextTick but can block input events and animation. Includes `asap/raw` for even faster execution without error handling. Minimalist (~1KB) with no dependencies.

npm install asap
INSTALL
IMPORT
SIG · ASAP
A
asap
devopsjavascriptv2.0.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

asap
import asap from 'asap'
const { asap } = require('asap')
Default export; no named export. In CommonJS use `const asap = require('asap')`.
rawAsap
import rawAsap from 'asap/raw'
const rawAsap = require('asap').raw
Must import from the subpath 'asap/raw' which is a separate module.
asap (CommonJS require)
const asap = require('asap')
const asap = require('asap').default
In Node.js (CJS), the module exports directly the function, not an object with `default`.

Demonstrates scheduling a task to run as soon as possible, before any I/O or rendering.

import asap from 'asap'; asap(() => { console.log('This runs ASAP, before I/O or rendering.'); }); console.log('This runs synchronously first.');
Debug
Known issues
gotchaasap can block input events and animation; use requestAnimationFrame for rendering tasks.
fix
For animation-related tasks, replace asap with requestAnimationFrame: requestAnimationFrame(callback).
affects: <3.0
gotchaasap can cause infinite recursion without stack overflow; equivalent to infinite loop.
fix
Monitor with heart-beat signals or use `setImmediate` to break long processes: setImmediate(callback).
affects: <3.0
gotcharawAsap (asap/raw) does not handle exceptions; a thrown error will stall the queue.
fix
Use the default asap (which handles errors) or manually call rawAsap.requestFlush() after handling the error.
affects: <3.0
deprecatedasap/raw is unofficial and may change; prefer default asap for reliability.
fix
Use `asap` (default) instead of `asap/raw` to ensure error handling.
affects: <3.0
gotchaasap uses process.nextTick in Node.js, which may still yield for I/O in some versions.
fix
If you need true before-I/O execution, verify Node.js version or use a more recent microtask mechanism.
affects: <3.0
Errors
Common errors & fixes
TypeError: asap is not a function
Importing named export instead of default export in ES modules.
fix
Use `import asap from 'asap'` instead of `import { asap } from 'asap'`.
Cannot find module 'asap/raw'
Using 'asap/raw' in a bundler without proper module resolution.
fix
Ensure your bundler (Webpack, ESBuild) supports subpath exports. Or use `require('asap/raw')` in Node.js.
asap is not defined
Using `asap` without requiring it in CommonJS.
fix
Add `const asap = require('asap');` at the top.
Upgrade
Version history
2.0.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
14
OpenAI (training)
1
Resources
packageasap
asap — npm install asap · libregistry