UNPKG

947 BJavaScriptView Raw
1var _curry2 =
2/*#__PURE__*/
3require("./internal/_curry2");
4
5var always =
6/*#__PURE__*/
7require("./always");
8
9var times =
10/*#__PURE__*/
11require("./times");
12/**
13 * Returns a fixed list of size `n` containing a specified identical value.
14 *
15 * @func
16 * @memberOf R
17 * @since v0.1.1
18 * @category List
19 * @sig a -> n -> [a]
20 * @param {*} value The value to repeat.
21 * @param {Number} n The desired size of the output list.
22 * @return {Array} A new array containing `n` `value`s.
23 * @see R.times
24 * @example
25 *
26 * R.repeat('hi', 5); //=> ['hi', 'hi', 'hi', 'hi', 'hi']
27 *
28 * const obj = {};
29 * const repeatedObjs = R.repeat(obj, 5); //=> [{}, {}, {}, {}, {}]
30 * repeatedObjs[0] === repeatedObjs[1]; //=> true
31 * @symb R.repeat(a, 0) = []
32 * @symb R.repeat(a, 1) = [a]
33 * @symb R.repeat(a, 2) = [a, a]
34 */
35
36
37var repeat =
38/*#__PURE__*/
39_curry2(function repeat(value, n) {
40 return times(always(value), n);
41});
42
43module.exports = repeat;
\No newline at end of file