Registry / serialization / component-each

component-each

JSON →
library0.2.6jsnpmunverified

The `component-each` package provides a highly generalized utility function for iterating over arrays, objects, and strings. It was developed as part of the 'Component' project, an early modularity solution for JavaScript that predates modern package managers like npm for front-end assets. This library allows a single `each` function to handle different data types by inspecting their structure, making it a flexible but less performant alternative to native `forEach` or `for...in` loops. Its current stable version is 0.2.6, and it has not seen updates since 2013, indicating it is no longer actively maintained. Its primary differentiator was its role within the now largely superseded 'Component' ecosystem, rather than its unique iteration features which are now standard or handled more efficiently by native JavaScript or modern utility libraries like Lodash.

npm install component-each
INSTALL
IMPORT
SIG · COMPONENT-EACH
C
component-each
serializationjavascriptv0.2.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

each
const each = require('component-each');
import each from 'component-each';
This package is CommonJS-only and was designed for the 'Component' build tool ecosystem, not modern ESM environments. It does not ship with TypeScript definitions.
each
const each = require('component-each'); // Usage: each([1, 2, 3], (num, i) => console.log(num, i));
import { each } from 'component-each';
The default export is the `each` function. There are no named exports.

Demonstrates the universal `each` function iterating over arrays, objects, and strings with a callback.

const each = require('component-each'); console.log('--- Iterating an array ---'); each([1, 2, 3], (num, i) => { console.log(`Array item at index ${i}: ${num}`); }); const config = { name: 'example', version: '1.0.0', env: 'development' }; console.log('\n--- Iterating an object ---'); each(config, (key, value) => { console.log(`Object property '${key}': ${value}`); }); console.log('\n--- Iterating a string ---'); each('hello', (char, i) => { console.log(`String character at index ${i}: '${char}'`); });
Debug
Known issues
breakingThis package is part of the 'Component' project ecosystem, which has been largely superseded by modern Node.js module systems (CommonJS/ESM) and build tools (npm, webpack, Rollup). It is not directly compatible with standard npm workflows without specific configuration or polyfills.
fix
Consider using native array methods (`forEach`, `for...of`), `Object.keys().forEach()`, or a modern utility library (e.g., Lodash's `_.forEach`) for iteration. If absolutely necessary, you may need to use a CommonJS transpiler or bundler.
affects: all
gotchaThe package is unmaintained since 2013. There will be no bug fixes, security updates, or new features. It may not work correctly with newer JavaScript runtimes or language features.
fix
Avoid using this package in new projects. For existing projects, consider migrating to maintained alternatives to prevent potential security vulnerabilities or compatibility issues.
affects: all
gotchaPerformance of this generic `each` function may be lower than native iteration methods (e.g., `Array.prototype.forEach`, `for...of` loops, `Object.keys().forEach()`), especially for large collections, due to its internal type checking and abstraction layer.
fix
Prefer native JavaScript iteration methods when possible for better performance and readability.
affects: all
gotchaThis library does not provide TypeScript declarations and is not designed for TypeScript environments. Using it in a TypeScript project will require manual type declarations or `@ts-ignore` directives.
fix
If using TypeScript, implement custom iteration logic or use a modern utility library that provides built-in TypeScript support.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'component-each'
The package was designed for the 'Component' build tool, not direct npm installation or standard Node.js module resolution without a bundler.
fix
Ensure `component-each` is properly installed and bundled by your build system. For modern projects, it's strongly recommended to replace it with native iteration or a modern utility library.
TypeError: each is not a function
Attempting to import `each` using ESM `import` syntax (`import each from 'component-each'`) instead of CommonJS `require`.
fix
Change your import statement to `const each = require('component-each');`.
Upgrade
Version history
0.2.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
component-each — npm install component-each · libregistry