{"id":10522,"library":"async-iterators","title":"Utility Functions for Callback-based Async Iterators","description":"This package provides utility functions like `forEach`, `map`, and `filter` for a specific, custom, callback-based asynchronous iterator pattern. In this library's context, an async iterator is defined as an object with a `next(cb)` method, where `cb` is a `function(err, value)` callback. The `next` method should return the next item from an underlying data source, calling `cb(null, undefined)` when no more data is available. Published in 2013, its current and only stable version is 0.2.2. The library targets legacy Node.js versions (>=0.10) and significantly predates the native ECMAScript `Symbol.asyncIterator` and `for-await-of` syntax, which were standardized in ES2018 and natively supported in Node.js 10.x. As it has seen no updates in over a decade, it is considered abandoned and fundamentally incompatible with modern asynchronous programming paradigms without extensive re-engineering or wrappers.","status":"abandoned","version":"0.2.2","language":"javascript","source_language":"en","source_url":"https://github.com/mirkokiefer/async-iterators","tags":["javascript"],"install":[{"cmd":"npm install async-iterators","lang":"bash","label":"npm"},{"cmd":"yarn add async-iterators","lang":"bash","label":"yarn"},{"cmd":"pnpm add async-iterators","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only and does not support ES modules. The default export is an object containing all utility functions.","wrong":"import * as iterators from 'async-iterators'","symbol":"iterators","correct":"const iterators = require('async-iterators')"},{"note":"Individual functions can be destructured from the CommonJS `require` result, but direct ESM imports are not supported.","wrong":"import { forEach } from 'async-iterators'","symbol":"forEach","correct":"const { forEach } = require('async-iterators')"},{"note":"This package exports an object with properties; individual functions are accessed via dot notation or CommonJS destructuring.","wrong":"import { map } from 'async-iterators'","symbol":"map","correct":"const map = require('async-iterators').map"}],"quickstart":{"code":"const iterators = require('async-iterators');\n\n// A dummy async iterator following the package's callback-based pattern\nfunction createExampleIterator() {\n  let i = 0;\n  const data = [10, 20, 30, 40, 50];\n  return {\n    next: function(cb) {\n      if (i < data.length) {\n        setTimeout(() => {\n          cb(null, data[i]);\n          i++;\n        }, 50);\n      } else {\n        cb(null, undefined); // Signal end of iteration\n      }\n    }\n  };\n}\n\nconst myIterator = createExampleIterator();\n\nconsole.log('Starting iteration...');\niterators.forEach(myIterator, function(err, data) {\n  if (err) {\n    console.error('Error:', err);\n    return;\n  }\n  if (data !== undefined) {\n    console.log('Received data:', data);\n  }\n}, function() {\n  console.log('End of iteration.');\n});","lang":"javascript","description":"Demonstrates the use of `forEach` with a custom callback-based async iterator, logging each item and an 'end' message."},"warnings":[{"fix":"Migrate to native async iterators and modern async/await patterns, or use a contemporary library that provides similar utilities for `AsyncIterable`.","message":"This package uses a custom callback-based async iterator pattern that is fundamentally different from the native ECMAScript `Symbol.asyncIterator` protocol (ES2018). It is not compatible with `for-await-of` loops or modern Promise-based async/await syntax.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Avoid using this package in modern Node.js projects. Consider `data-async-iterators` or `buffered-async-iterable` for modern async iterable utilities.","message":"The package was last updated over a decade ago (version 0.2.2 published in 2013) and targets Node.js versions >=0.10. It is highly unlikely to be compatible with current Node.js runtimes (e.g., Node.js 16+ or 20+) without significant environment setup or polyfills for ancient Node.js APIs.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"In an ESM project, you would need to use `const iterators = require('async-iterators')` within a CommonJS wrapper, or refactor to use a modern ESM-compatible async utility library.","message":"This library is CommonJS-only and does not support ES Modules (`import`/`export` syntax). Attempting to import it directly in an ESM context will result in errors.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure you are using CommonJS `require` syntax: `const iterators = require('async-iterators');`.","cause":"Attempting to use `async-iterators` in an ES module context with `import` syntax, or the variable holding the `require` result is not named `iterators` or correctly destructured.","error":"TypeError: iterators.forEach is not a function"},{"fix":"This package is not compatible with ES module projects. You must either convert your project to CommonJS or choose a modern async iterator library that supports ES modules.","cause":"Trying to use `require` in a JavaScript file explicitly defined as an ES module (e.g., via `\"type\": \"module\"` in `package.json` or `.mjs` extension).","error":"ReferenceError: require is not defined in ES module scope"}],"ecosystem":"npm"}