https://github.com/threepointone/times
functional times/map.
https://github.com/threepointone/times
Last synced: 2 months ago
JSON representation
functional times/map.
- Host: GitHub
- URL: https://github.com/threepointone/times
- Owner: threepointone
- Created: 2013-01-16T09:46:48.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-07-01T09:45:11.000Z (almost 12 years ago)
- Last Synced: 2025-01-25T08:11:30.964Z (4 months ago)
- Language: JavaScript
- Size: 172 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# times
functional times
## Installation
$ component install threepointone/times
## API
```jsvar times = require('times');
// run a function n times
times(5, function(i){
console.log('iteration', i+1)
});// generate an array
var arr = times(10, function(i){
return i*2;
});
console.log(arr);
// [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]// use as a .map replacement
var newArr = times(arr, function(i, el){
console.log('arr[', i, '] =', el);
return el*2;
});
console.log(newArr);
// [0, 4, 8, 12, 16, 20, 24, 28, 32, 36]// use as a .invoke replacement.
times(users, 'logout');
// users[0].logout(); users[1].logout(); and so on.// notbad.jpg
```
## Tests
install dependencies -
```
npm install
```
then
```
npm test
```[](https://travis-ci.org/threepointone/times)
## License
MIT