Package Exports
- array-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 (array-each) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
array-each 
Loop over each item in an array and call the given function on every element.
Install with npm
npm i array-each --save
Usage
var each = require('array-each');
var result = [];
each(['a', 'b', 'c'], function (ele) {
result.push(ele + ele);
});
console.log(result);
//=> ['aa', 'bb', 'cc']
Return false
to "break" early:
var result = [];
each(['a', 'b', 'c'], function (ele) {
if (ele === 'b') return false;
result.push(ele + ele);
});
console.log(result);
//=> ['aa']
API
.each
Loop over each item in an array and call the given function on every element.
array
{Array}fn
{Function}thisArg
{Object}: Optionally pass athisArg
to be used as the context in which to call the function.returns
: {Array}
each(['a', 'b', 'c'], function (ele) {
return ele + ele;
});
//=> ['aa', 'bb', 'cc']
each(['a', 'b', 'c'], function (ele, i) {
return i + ele;
});
//=> ['0a', '1b', '2c']
Related projects
- arr-filter: Faster alternative to javascript's native filter method.
- arr-diff: Returns an array with only the unique values from the first array, by excluding all values from additional arrays using strict equality for comparisons.
- arr-map: Faster, node.js focused alternative to JavaScript's native array map.
- arr-flatten: Recursively flatten an array or arrays. This is the fastest implementation of array flatten.
- array-unique: Return an array free of duplicate values. Fastest ES5 implementation.
- array-intersection: Return an array with the unique values present in all given arrays using strict equality for comparisons.
Running tests
Install dev dependencies:
npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Author
Jon Schlinkert
License
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license
This file was generated by verb-cli on April 19, 2015.