JSPM

  • Created
  • Published
  • Downloads 54
  • Score
    100M100P100Q74279F
  • 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 forEach = require('@extra-array/for-each');
// forEach(<array>, <called function>, [this], [begin=0], [end])
// - <called function>(<value>, <index>, <array>)

forEach([['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
forEach([1, 2, 3, 4], (v) => console.log(v), null, 1);
// 2
// 3
// 4
forEach([1, 2, 3, 4], (v) => console.log(v), null, 1, 3);
// 2
// 3

With extra-array try Array.forEach() instead.

extra-array