JSPM

array-each

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3995529
  • Score
    100M100P100Q199175F
  • License

Loop over each item in an array and call the given function on every element.

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 NPM version

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.

Params

  • array {Array}
  • fn {Function}
  • thisArg {Object}: Optionally pass a thisArg to be used as the context in which to call the function.
  • returns {Array}

Example

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']
  • 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… more
  • 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… more

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 28, 2015.