Registry / http-networking / iterall

iterall

JSON →
library1.3.0jsnpmunverified

Iterall is a minimalist, zero-dependency utility library designed to enable the use of JavaScript Iterables and AsyncIterables across all JavaScript environments, including older versions of Internet Explorer. It provides crucial helpers for libraries that wish to accept various iterable inputs (like Arrays, Maps, Sets, NodeLists, TypedArrays, or custom data structures) instead of being limited to only Arrays. The current stable version is 1.3.0, and the project maintains a steady release cadence with improvements to TypeScript definitions and async iterator support. Its key differentiators include its tiny footprint (under 1KB gzipped), its 'library for libraries' approach, and its robust compatibility with both modern and legacy JavaScript runtimes through its intelligent fallback mechanism for `Symbol.iterator`.

npm install iterall
INSTALL
IMPORT
SIG · ITERALL
I
iterall
http-networkingjavascriptv1.3.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

isCollection
✓ import { isCollection } from 'iterall';
✗ const isCollection = require('iterall').isCollection;
For ESM, use named imports. For CommonJS, use require. Since v1.2.0, `.mjs` files are published for better ESM compatibility and tree-shaking.
forEach
✓ import { forEach } from 'iterall';
✗ const forEach = require('iterall').forEach;
This utility allows iterating over any Iterable or Array-like structure, even in environments without native Symbol.iterator.
forAwaitEach
✓ import { forAwaitEach } from 'iterall';
✗ const forAwaitEach = require('iterall').forAwaitEach;
Introduced in v1.1.0, this function provides a universal way to iterate over AsyncIterables, returning a Promise. Ensure you are on v1.1.3 or higher for critical bug fixes.

Demonstrates how to use `isCollection` to check for iterable/array-like structures and `forEach` for synchronous iteration, along with `forAwaitEach` for handling asynchronous iterables, all compatible across environments.

import { isCollection, forEach, forAwaitEach } from 'iterall'; // Example 1: Handling various synchronous collections function processCollection(data) { if (isCollection(data)) { forEach(data, (item, index) => { console.log(`Sync Item ${index}: ${item}`); }); console.log('Finished synchronous iteration.'); } else { console.log('Input is not a recognized collection.'); } } processCollection([1, 2, 3]); processCollection(new Set(['a', 'b'])); // Example 2: Handling asynchronous iterables async function* asyncGenerator() { yield 'hello'; await new Promise(resolve => setTimeout(resolve, 100)); yield 'world'; } async function processAsyncIterable(asyncData) { console.log('Starting asynchronous iteration...'); await forAwaitEach(asyncData, (item, index) => { console.log(`Async Item ${index}: ${item}`); }); console.log('Finished asynchronous iteration.'); } processAsyncIterable(asyncGenerator());
Debug
Known issues
gotchaIterall's primary value is in providing polyfills and fallbacks for Iteration Protocols in older JavaScript environments (pre-ES2015 or limited browser support). If you are strictly targeting modern ES2015+ environments that fully support `Symbol.iterator`, you might be able to use native iteration directly without `iterall`.
fix
Assess your target environment compatibility. If only modern ES environments are targeted, native `for...of` loops and `Array.from` might suffice. Otherwise, `iterall` is beneficial for broader compatibility.
affects: >=1.0.0
gotchaFor optimal tree-shaking and better ESM compatibility with bundlers like Rollup or Webpack, `iterall` has published `.mjs` files since `v1.2.0`. Ensure your build configuration is set up to resolve `.mjs` files correctly, especially in dual CommonJS/ESM setups.
fix
Check your bundler configuration (e.g., `resolve.extensions` in Webpack) to ensure `.mjs` is included. For Node.js, ensure your `package.json` specifies `type: 'module'` or uses `.mjs` extensions for ESM files.
affects: >=1.2.0
gotchaEarly versions of `forAwaitEach` (before v1.1.2) had a memory leak issue, and v1.1.2 introduced a fix for this. Subsequently, v1.1.3 fixed an issue where errors within `forAwaitEach` were not caught.
fix
If using `forAwaitEach` for asynchronous iteration, ensure your project depends on `iterall` version `1.1.3` or newer to avoid memory leaks and unhandled promise rejections.
affects: >=1.1.0 <1.1.3
Errors
Common errors & fixes
TypeError: 'Symbol.iterator' is not defined
Attempting to iterate over a custom object or non-native iterable in an older JavaScript environment without leveraging `iterall`'s polyfill utilities, leading to the absence of the `Symbol.iterator` global.
fix
Use `iterall.forEach(myIterable, callback)` or `iterall.isIterable(myIterable)` to ensure compatibility across all environments, as `iterall` handles the fallback to `@@iterator`.
SyntaxError: Cannot use import statement outside a module
Using `import ... from 'iterall'` syntax in a Node.js environment configured for CommonJS (e.g., without `"type": "module"` in `package.json` or a transpiler like Babel).
fix
Change your import statements to CommonJS `require` syntax: `const { forEach } = require('iterall');` or configure your Node.js project or build pipeline to support ESM.
Module not found: Error: Can't resolve 'iterall'
A bundler (like Webpack) is failing to resolve the `iterall` package, potentially due to incorrect pathing or module resolution configuration, especially concerning its `.mjs` files.
fix
Verify `iterall` is correctly installed in `node_modules`. If using a bundler, ensure its configuration supports resolving `.mjs` files (e.g., `resolve.extensions` in Webpack should include `'.mjs'`).
Upgrade
Version history
1.3.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
iterall — npm install iterall · libregistry