Registry / testing / std-client-run-queue

std-client-run-queue

JSON →
library0.0.1jsnpmunverified

A TypeScript run queue that schedules and manages async tasks to minimize client-side interactivity disruptions. Current version 0.0.1, early development with frequent releases. Supports configurable max parallelism, work units, continuous work duration, priority levels, per-entry cancellation, and optional delay and never-cancel flags. Provides coordination hooks for React Native via InteractionManager. Differentiators include client-focus, customizable runAfterInteractions, stats tracking, and priority scheduling with fine-grained control over task execution order and cancellation.

npm install std-client-run-queue
INSTALL
IMPORT
SIG · STD-CLIENT-RUN-QUE
S
std-client-run-queue
testingjavascriptv0.0.1
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.

RunQueue
import { RunQueue } from 'std-client-run-queue'
const { RunQueue } = require('std-client-run-queue')
ESM-only; this package does not support CommonJS require()
CANCELED
import { CANCELED } from 'std-client-run-queue'
import CANCELED from 'std-client-run-queue'
CANCELED is a named export, not default
DEFAULT_PRIORITY
import { DEFAULT_PRIORITY } from 'std-client-run-queue'
Named constant for default priority value

Creates a RunQueue, schedules functions with different priorities and options, checks entry status, waits for results, and cancels all.

import { CANCELED, DEFAULT_PRIORITY, RunQueue } from 'std-client-run-queue'; const main = async () => { const q = new RunQueue('my-queue'); const doSomeWork = async () => { await new Promise((resolve) => setTimeout(resolve, Math.random() * 1000)); return Math.random(); }; const entry = q.schedule(DEFAULT_PRIORITY, 'my-function', doSomeWork); console.log('canceled', entry.wasCanceled()); console.log('completed', entry.wasCompleted()); console.log('started', entry.wasStarted()); const result = await entry.promise; if (result.ok) { console.log('success', result.details); } else if (result.details === CANCELED) { console.log('canceled'); } else { console.log('failure', result.details); } q.schedule(2, 'my-function', doSomeWork, { delayMSec: 1000 }); q.schedule(0, 'my-function', doSomeWork, { neverCancel: true }); q.schedule(1, 'my-function', doSomeWork); console.log('queue length', q.getQueueLength()); q.cancelAll(); }; main().catch(console.error);
Debug
Known issues
gotchaRunQueue constructor requires a non-empty string queueId.
fix
Pass a string identifier to new RunQueue('my-queue').
affects: >=0.0.0
deprecatedThe wasStarted() and wasCompleted() methods are deprecated; use the promise result instead.
fix
Check entry.promise result for ok/canceled/failure status.
affects: 0.0.1
gotchaThe setRunAfterInteractions function must be called before scheduling any entries to take effect.
fix
Invoke setRunAfterInteractions early in app initialization.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'schedule')
RunQueue instance not created or imported incorrectly.
fix
Ensure proper import: import { RunQueue } from 'std-client-run-queue' and instantiate with new RunQueue('id').
Error: CANCELED is not defined
CANCELED symbol imported incorrectly or not imported.
fix
Use import { CANCELED } from 'std-client-run-queue'.
TypeError: (intermediate value).runAfterInteractions is not a function
setRunAfterInteractions was called with an invalid function.
fix
Provide a function that accepts (id: string, func: () => void) and returns a cancel function.
Upgrade
Version history
0.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
std-client-run-queue — npm install std-client-run-queue · libregistry