Component Each Iteration Utility

0.2.6 · abandoned · verified Sun Apr 19

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.

Common errors

Warnings

Install

Imports

Quickstart

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}'`);
});

view raw JSON →