{"id":44438,"library":"buffered-queue","title":"buffered-queue","description":"A simple, zero-dependency Node.js module that buffers items (objects, strings, numbers) until a maximum size is reached or a flush interval expires. Current stable version is 1.0.1. It is a small, flexible utility for batching operations with a configurable custom result function. Unlike more complex message queues, buffered-queue focuses on a minimal API with events and basic options, suitable for lightweight in-process buffering. Updates are infrequent, but the module is stable and has no known issues. It is primarily used in Node.js environments and does not support ESM natively, relying on CommonJS require().","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"git://github.com/tobilg/buffered-queue","tags":["javascript","buffer","buffered","queue","recurring","interval","timeout","batch","simple"],"install":[{"cmd":"npm install buffered-queue","lang":"bash","label":"npm"},{"cmd":"yarn add buffered-queue","lang":"bash","label":"yarn"},{"cmd":"pnpm add buffered-queue","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package does not export ESM; use CommonJS require().","wrong":"import Queue from 'buffered-queue';","symbol":"Queue","correct":"const Queue = require('buffered-queue');"},{"note":"The export is the constructor itself, not a named property.","wrong":"const Queue = require('buffered-queue').Queue;","symbol":"Queue","correct":"const { default: Queue } = require('buffered-queue');"}],"quickstart":{"code":"const Queue = require('buffered-queue');\nconst q = new Queue('myqueue', {\n  size: 3,\n  flushTimeout: 5000,\n  verbose: true,\n  customResultFunction: function(items) {\n    return items.join(', ');\n  }\n});\nq.on('flush', function(data, name) {\n  console.log('Flush:', data, 'from', name);\n});\nq.add('item1');\nq.add('item2');\nq.add('item3');","lang":"javascript","description":"Creates a buffered queue with size 3 and 5s timeout, adds three items, and logs the flush event with processed data."},"warnings":[{"fix":"Always provide a name string as first argument, even if empty: new Queue('', {...})","message":"Queue constructor expects two arguments: name (string) and options (object). Passing only options as first argument will cause a TypeError.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure customResultFunction returns an array (or the desired data structure).","message":"customResultFunction if provided must return an array-like or the data passed to the flush event will be undefined or malformed.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Review customResultFunction output to match expected format for flush event handling.","message":"The 'flush' event callback receives data and name, but if customResultFunction returns a non-array, data may be inconsistent with typical usage.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.1':32 'api':60 'basic':64 'batch':40,110 'buffer':2,12,54,72,104,105 'buffered-queu':1,53 'commonj':101 'complex':50 'configur':44 'current':28 'custom':45 'depend':8 'environ':92 'esm':97 'event':62 'expir':27 'flexibl':37 'flush':25 'focus':56 'function':47 'in-process':69 'infrequ':75 'interv':26,108 'issu':85 'item':13 'javascript':103 'known':84 'lightweight':68 'maximum':19 'messag':51 'minim':59 'modul':10,78 'nativ':98 'node.js':9,91 'number':16 'object':14 'oper':41 'option':65 'primarili':88 'process':71 'queue':3,52,55,106 'reach':22 'recur':107 'reli':99 'requir':102 'result':46 'simpl':5,111 'size':20 'small':36 'stabl':29,80 'string':15 'suitabl':66 'support':96 'timeout':109 'unlik':48 'updat':73 'use':89 'util':38 'version':30 'zero':7 'zero-depend':6","created_at":"2026-06-07T12:50:07.774590+00:00","updated_at":"2026-06-07T12:50:07.774590+00:00","problems":[{"fix":"Use require('buffered-queue') instead of import.","cause":"Using ESM import syntax with a CommonJS-only module.","error":"TypeError: Queue is not a constructor"},{"fix":"Ensure the Queue constructor is called with new and the returned object is assigned.","cause":"Calling q.on() before creating a queue (e.g., on an undefined variable).","error":"TypeError: Cannot read properties of undefined (reading 'on')"}],"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/tobilg/buffered-queue","github":"git://github.com/tobilg/buffered-queue","docs":null,"changelog":null,"pypi":null,"npm":"buffered-queue","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"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}}