source: node_modules/ramda/src/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: 956 bytes
Line 
1var _curry2 =
2/*#__PURE__*/
3require("./internal/_curry2.js");
4
5var always =
6/*#__PURE__*/
7require("./always.js");
8
9var times =
10/*#__PURE__*/
11require("./times.js");
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;
Note: See TracBrowser for help on using the repository browser.