Registry / database / broadband

broadband

JSON →
library1.1.0jsnpmunverified

Process MongoDB query cursor results in parallel with a configurable concurrency limit, without loading all results into memory. Current stable version is 1.1.0 (supports both MongoDB 2 and 3). Released on GitHub, updated as needed (last change added support for cursor `next` method alongside `nextObject`). Unlike async.eachLimit, this package streams results from a cursor rather than requiring an in-memory array. Works with any object that has a `nextObject` method.

npm install broadband
INSTALL
IMPORT
SIG · BROADBAND
B
broadband
databasejavascriptv1.1.0
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.

broadband
const broadband = require('broadband')
import broadband from 'broadband'
Package does not ship with ES module support; must use CommonJS require.
broadband
const broadband = require('broadband')
const { broadband } = require('broadband')
The default export is a function, not a named export.
broadband
const broadband = require('broadband')
const broadband = require('broadband').default
No .default property; package uses module.exports directly.

Demonstrates basic usage with MongoDB cursor: parallel processing limit of 8, error handling, and cleanup.

const broadband = require('broadband'); const mongoClient = require('mongodb').MongoClient; mongoClient.connect('mongodb://localhost:27017', async (err, client) => { if (err) throw err; const db = client.db('mydb'); const cursor = db.collection('images').find({}); broadband(cursor, 8, (doc, callback) => { // Process up to 8 documents in parallel console.log('Processing:', doc._id); callback(null); }, (err) => { if (err) console.error(err); client.close(); console.log('All done'); }); });
Debug
Known issues
gotchabroadband expects the cursor to have a `nextObject` method (or `next` for MongoDB 3). If using a newer MongoDB driver, `nextObject` is deprecated; use `next` instead.
fix
Ensure your cursor provides either `nextObject` or `next` method. broadband checks for both.
affects: >=1.1.0
breakingbroadband version 1.0.0 updated lodash dependency to address npm audit warnings. If you rely on lodash globally, you may need to update your own dependency.
fix
None required unless you have a direct lodash dependency; simply update broadband.
affects: >=1.0.0
gotchaIf the cursor throws or returns an error, broadband stops processing new items but waits for outstanding callbacks. The final callback is invoked with the first error encountered, not all errors.
fix
Handle errors in the final callback; do not assume all callbacks completed successfully.
affects: >=0.1.0
deprecatedbroadband's reliance on `nextObject` is deprecated in MongoDB Node.js driver v3.x; use `next` instead. Version 1.1.0 adds support for both.
fix
Upgrade to broadband 1.1.0 or later, which supports cursor `next` method.
affects: >=1.1.0
gotchabroadband does not support Promises or async/await natively; it uses callback-style. Wrapping in a promise is required for async usage.
fix
Wrap broadband call in a Promise manually or use util.promisify.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: cursor.nextObject is not a function
Using MongoDB Node.js driver v3 or later where cursor.nextObject is removed; broadband before 1.1.0 only checks for nextObject.
fix
Update broadband to >=1.1.0 which also checks for cursor.next.
broadband is not a function
Incorrect import pattern: using ES6 import or destructured require on a CommonJS default export.
fix
Use const broadband = require('broadband');
Cannot read property 'length' of undefined
Passing a cursor that is already exhausted or null to broadband.
fix
Ensure the cursor is valid and has results; check for null cursor.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
lodashrequiredUsed for utility functions; noted in changelog that dependency was updated to satisfy npm audit.
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources