JSPM

  • Created
  • Published
  • Downloads 54
  • Score
    100M100P100Q74313F
  • License MIT

Call a function for each value in array, like Array.forEach().

Package Exports

  • @extra-array/for-each

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@extra-array/for-each) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Call a function for each value in array, like Array.forEach().

const forEachOf = require('@extra-array/for-each');
// forEachOf(<array>, <called function>, [this], [begin=0], [end])
// - <called function>(<value>, <index>, <array>)

forEachOf([['rohan', 'lotr'], ['arkham', 'batman']], (v) => {
  var typ = v[1]==='batman'? 'comic':'novel';
  console.log(v[0], v[1], typ);
});
// rohan lotr novel
// arkham batman comic
forEachOf([1, 2, 3, 4], (v) => console.log(v), null, 1);
// 2
// 3
// 4
forEachOf([1, 2, 3, 4], (v) => console.log(v), null, 1, 3);
// 2
// 3

extra-array