Registry / devops / turnstile

turnstile

JSON →
library5.0.5jsnpmunverified

An evented event queue for Node.js, providing a cadence-based queue with event-driven control flow. Version 5.0.5 is the latest stable release. Turnstile offers a simple, lightweight queue implementation with pause/resume, concurrency control, and event hooks for start, finish, and drain. It differentiates itself from more complex job queues like Bull or Kue by focusing on simplicity and minimal dependencies, suitable for small to medium workloads.

npm install turnstile
INSTALL
IMPORT
SIG · TURNSTILE
T
turnstile
devopsjavascriptv5.0.5
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.

Queue
import { Queue } from 'turnstile'
const turnstile = require('turnstile'); new turnstile.Queue();
ESM-only since v5. Named export.
default
import turnstile from 'turnstile'
const turnstile = require('turnstile').default
Default export available but not the Queue constructor. Prefer named export.
Queue (type)
import type { Queue } from 'turnstile'
TypeScript users should import type for type-only usage.

Creates a queue with concurrency 2, enqueues three tasks, and processes them with event handlers.

import { Queue } from 'turnstile'; const queue = new Queue(2); // concurrency of 2 queue.on('start', (task) => { console.log(`Starting: ${task}`); }); queue.on('drain', () => { console.log('All tasks complete'); }); queue.enqueue('task1'); queue.enqueue('task2'); queue.enqueue('task3'); // process tasks queue.start(); queue.on('process', (task, done) => { console.log(`Processing: ${task}`); setTimeout(done, 1000); });
Debug
Known issues
breakingDrop of CommonJS require support in v5.
fix
Use ESM import syntax. If using require, stick to v4.
affects: >=5.0.0
deprecatedThe 'process' event is deprecated in v5 in favor of 'flush' event.
fix
Use 'flush' event instead of 'process'.
affects: >=5.0.0
gotchaConstructor expects integer concurrency; passing non-integer may fail silently.
fix
Ensure concurrency is an integer; parseInt or Math.floor before creating queue.
affects: >=4.0.0
gotchaCalling start() without listeners will cause immediate drain.
fix
Ensure you attach 'process' or 'flush' listener before calling start().
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: turnstile.Queue is not a constructor
Using CommonJS require incorrectly for ESM package.
fix
Use import { Queue } from 'turnstile' or require('turnstile').Queue.
Error: Concurrency must be a number
Passed non-number or NaN to Queue constructor.
fix
Ensure concurrency is a positive integer.
Queue is not initialized
Calling methods before calling start() after adding tasks.
fix
Call queue.start() after enqueuing tasks and attaching event listeners.
Upgrade
Version history
5.0.5latest on npm
Audit
Dependencies
brittleoptionalPeer dependency for testing; required for tap tests.
Agent activity
4 hits · last 30 days
node
4
Resources
turnstile — npm install turnstile · libregistry