swc/bundler/tests/.cache/deno/48814d77cdb52ba4ae4ba9d5dcb8163d57fb6b3c.ts
강동윤 bbaf619f63
fix(bundler): Fix bugs (#1437)
swc_bundler:
 - [x] Fix wrapped esms. (denoland/deno#9307)
 - [x] Make test secure.
2021-03-02 17:33:03 +09:00

46 lines
1.2 KiB
TypeScript

// Loaded from https://deno.land/x/ramda@v0.27.2/source/times.js
import _curry2 from './internal/_curry2.js';
/**
* Calls an input function `n` times, returning an array containing the results
* of those function calls.
*
* `fn` is passed one argument: The current value of `n`, which begins at `0`
* and is gradually incremented to `n - 1`.
*
* @func
* @memberOf R
* @since v0.2.3
* @category List
* @sig (Number -> a) -> Number -> [a]
* @param {Function} fn The function to invoke. Passed one argument, the current value of `n`.
* @param {Number} n A value between `0` and `n - 1`. Increments after each function call.
* @return {Array} An array containing the return values of all calls to `fn`.
* @see R.repeat
* @example
*
* R.times(R.identity, 5); //=> [0, 1, 2, 3, 4]
* @symb R.times(f, 0) = []
* @symb R.times(f, 1) = [f(0)]
* @symb R.times(f, 2) = [f(0), f(1)]
*/
var times = _curry2(function times(fn, n) {
var len = Number(n);
var idx = 0;
var list;
if (len < 0 || isNaN(len)) {
throw new RangeError('n must be a non-negative number');
}
list = new Array(len);
while (idx < len) {
list[idx] = fn(idx);
idx += 1;
}
return list;
});
export default times;