source: node_modules/ramda/es/update.js@ d24f17c

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

Initial commit

  • Property mode set to 100644
File size: 1.0 KB
Line 
1import _curry3 from "./internal/_curry3.js";
2import adjust from "./adjust.js";
3import always from "./always.js";
4/**
5 * Returns a new copy of the array with the element at the provided index
6 * replaced with the given value.
7 *
8 * @func
9 * @memberOf R
10 * @since v0.14.0
11 * @category List
12 * @sig Number -> a -> [a] -> [a]
13 * @param {Number} idx The index to update.
14 * @param {*} x The value to exist at the given index of the returned array.
15 * @param {Array|Arguments} list The source array-like object to be updated.
16 * @return {Array} A copy of `list` with the value at index `idx` replaced with `x`.
17 * @see R.adjust
18 * @example
19 *
20 * R.update(1, '_', ['a', 'b', 'c']); //=> ['a', '_', 'c']
21 * R.update(-1, '_', ['a', 'b', 'c']); //=> ['a', 'b', '_']
22 * @symb R.update(-1, a, [b, c]) = [b, a]
23 * @symb R.update(0, a, [b, c]) = [a, c]
24 * @symb R.update(1, a, [b, c]) = [b, a]
25 */
26
27var update =
28/*#__PURE__*/
29_curry3(function update(idx, x, list) {
30 return adjust(idx, always(x), list);
31});
32
33export default update;
Note: See TracBrowser for help on using the repository browser.