{"id":46688,"library":"turnstile","title":"Turnstile","description":"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.","status":"active","version":"5.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/bigeasy/turnstile","tags":["javascript","cadence","queue","events"],"install":[{"cmd":"npm install turnstile","lang":"bash","label":"npm"},{"cmd":"yarn add turnstile","lang":"bash","label":"yarn"},{"cmd":"pnpm add turnstile","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for testing; required for tap tests.","package":"brittle","optional":true}],"imports":[{"note":"ESM-only since v5. Named export.","wrong":"const turnstile = require('turnstile'); new turnstile.Queue();","symbol":"Queue","correct":"import { Queue } from 'turnstile'"},{"note":"Default export available but not the Queue constructor. Prefer named export.","wrong":"const turnstile = require('turnstile').default","symbol":"default","correct":"import turnstile from 'turnstile'"},{"note":"TypeScript users should import type for type-only usage.","wrong":null,"symbol":"Queue (type)","correct":"import type { Queue } from 'turnstile'"}],"quickstart":{"code":"import { Queue } from 'turnstile';\n\nconst queue = new Queue(2); // concurrency of 2\n\nqueue.on('start', (task) => {\n  console.log(`Starting: ${task}`);\n});\n\nqueue.on('drain', () => {\n  console.log('All tasks complete');\n});\n\nqueue.enqueue('task1');\nqueue.enqueue('task2');\nqueue.enqueue('task3');\n\n// process tasks\nqueue.start();\n\nqueue.on('process', (task, done) => {\n  console.log(`Processing: ${task}`);\n  setTimeout(done, 1000);\n});","lang":"typescript","description":"Creates a queue with concurrency 2, enqueues three tasks, and processes them with event handlers."},"warnings":[{"fix":"Use ESM import syntax. If using require, stick to v4.","message":"Drop of CommonJS require support in v5.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Use 'flush' event instead of 'process'.","message":"The 'process' event is deprecated in v5 in favor of 'flush' event.","severity":"deprecated","affected_versions":">=5.0.0"},{"fix":"Ensure concurrency is an integer; parseInt or Math.floor before creating queue.","message":"Constructor expects integer concurrency; passing non-integer may fail silently.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"Ensure you attach 'process' or 'flush' listener before calling start().","message":"Calling start() without listeners will cause immediate drain.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'5.0.5':21 'base':12 'bull':55 'cadenc':11,72 'cadence-bas':10 'complex':51 'concurr':36 'control':18,37 'depend':64 'differenti':47 'drain':45 'driven':17 'event':3,4,16,39,74 'event-driven':15 'finish':43 'flow':19 'focus':59 'hook':40 'implement':33 'javascript':71 'job':52 'kue':57 'latest':24 'lightweight':31 'like':54 'medium':69 'minim':63 'node.js':7 'offer':28 'pause/resume':35 'provid':8 'queue':5,13,32,53,73 'releas':26 'simpl':30 'simplic':61 'small':67 'stabl':25 'start':42 'suitabl':65 'turnstil':1,27 'version':20 'workload':70","created_at":"2026-06-07T13:01:08.567225+00:00","updated_at":"2026-06-07T13:01:08.567225+00:00","problems":[{"fix":"Use import { Queue } from 'turnstile' or require('turnstile').Queue.","cause":"Using CommonJS require incorrectly for ESM package.","error":"TypeError: turnstile.Queue is not a constructor"},{"fix":"Ensure concurrency is a positive integer.","cause":"Passed non-number or NaN to Queue constructor.","error":"Error: Concurrency must be a number"},{"fix":"Call queue.start() after enqueuing tasks and attaching event listeners.","cause":"Calling methods before calling start() after adding tasks.","error":"Queue is not initialized"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/bigeasy/turnstile","github":"https://github.com/bigeasy/turnstile","docs":null,"changelog":null,"pypi":null,"npm":"turnstile","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}