Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ndhoule/map
Apply a function to a each element of a collection and return a new array of results.
https://github.com/ndhoule/map
Last synced: 13 days ago
JSON representation
Apply a function to a each element of a collection and return a new array of results.
- Host: GitHub
- URL: https://github.com/ndhoule/map
- Owner: ndhoule
- License: mit
- Created: 2015-02-27T18:22:17.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-05-02T20:30:48.000Z (over 8 years ago)
- Last Synced: 2024-09-24T04:22:37.525Z (about 2 months ago)
- Language: JavaScript
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE.md
Awesome Lists containing this project
README
# map [![CI][ci-badge]][ci-link]
Apply a function to a each element of a collection and return a new array of results.
## Installation
```sh
$ component install ndhoule/map
$ npm install @ndhoule/map
```## API
### map(iterator : Function, collection : Object|Array|string) => Array
Produce a new array by passing each value in the input `collection` through an `iterator` function and accumulating the results. The `iterator` is passed three arguments: `(value, index, collection)`.
```javascript
var square = function(x) { return x * x; };map(square, [1, 2, 3]);
//=> [1, 4, 9]
```## License
Released under the [MIT license](LICENSE.md).
[ci-link]: https://travis-ci.org/ndhoule/map
[ci-badge]: https://travis-ci.org/ndhoule/map.svg?branch=master