npm.io
1.0.0 • Published 10 years ago

@f/times

Licence
MIT
Version
1.0.0
Deps
0
Vulns
0
Weekly
0

times

Build status Git tag NPM version Code style

Run a function n times and aggregate the results into an array

Installation

$ npm install @f/times

Usage

var times = require('@f/times')

times(3, identity) === [0, 1, 2]

API

times(n, fn)
  • n - The number of times to run fn(i)
  • fn - Receives a single argument, the current index. Also called with the same this context as times.

Returns: An array of the return values of fn.

License

MIT