Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andregarvin/asmany
https://github.com/andregarvin/asmany
Last synced: 2 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/andregarvin/asmany
- Owner: andreGarvin
- Created: 2018-01-04T07:42:33.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-17T22:31:52.000Z (over 6 years ago)
- Last Synced: 2024-11-07T06:09:00.355Z (8 days 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) // 8asmany((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
```