source: node_modules/ramda/es/repeat.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 900 bytes
RevLine 
[d24f17c]1import _curry2 from "./internal/_curry2.js";
2import always from "./always.js";
3import times from "./times.js";
4/**
5 * Returns a fixed list of size `n` containing a specified identical value.
6 *
7 * @func
8 * @memberOf R
9 * @since v0.1.1
10 * @category List
11 * @sig a -> n -> [a]
12 * @param {*} value The value to repeat.
13 * @param {Number} n The desired size of the output list.
14 * @return {Array} A new array containing `n` `value`s.
15 * @see R.times
16 * @example
17 *
18 * R.repeat('hi', 5); //=> ['hi', 'hi', 'hi', 'hi', 'hi']
19 *
20 * const obj = {};
21 * const repeatedObjs = R.repeat(obj, 5); //=> [{}, {}, {}, {}, {}]
22 * repeatedObjs[0] === repeatedObjs[1]; //=> true
23 * @symb R.repeat(a, 0) = []
24 * @symb R.repeat(a, 1) = [a]
25 * @symb R.repeat(a, 2) = [a, a]
26 */
27
28var repeat =
29/*#__PURE__*/
30_curry2(function repeat(value, n) {
31 return times(always(value), n);
32});
33
34export default repeat;
Note: See TracBrowser for help on using the repository browser.