https://github.com/andregarvin/asmany
https://github.com/andregarvin/asmany
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/andregarvin/asmany
- Owner: andreGarvin
- Created: 2018-01-04T07:42:33.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-17T22:31:52.000Z (almost 8 years ago)
- Last Synced: 2025-02-12T16:17:37.498Z (over 1 year ago)
- Language: JavaScript
- Size: 30.3 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# asmany: simple function repeats a certain task on some data given as many times as you to.
* I create this module/function because it name was taken on npm and create this function time to time.
```bash
npm i asmany -S
```
```js
const asmany = require('asmany')
/*
The callback function returns a begin ran returns two things.
- data: the mutated data being changed.
- i: the count/number of how many times it ran
ex: asmany(data, i) => ..., 1, 'blah')
*/
asmany((data) => data + 1, 5, 3) // 8
asmany((data, i) => {
if (i === 1) {
return {
cat: 'meow'
}
} else {
return {
dog: 'woof'
}
}
}, 2, {}) // { cat: 'meow', dog: 'woof' }
const uuid = require('uuid')
const accessToken = asmany((data) => uuid().split('-').join(''), 5, '') // Really long uuid string
```