source: node_modules/ramda/src/assoc.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: 977 bytes
Line 
1var _curry3 =
2/*#__PURE__*/
3require("./internal/_curry3.js");
4
5var assocPath =
6/*#__PURE__*/
7require("./assocPath.js");
8/**
9 * Makes a shallow clone of an object, setting or overriding the specified
10 * property with the given value. Note that this copies and flattens prototype
11 * properties onto the new object as well. All non-primitive properties are
12 * copied by reference.
13 *
14 * @func
15 * @memberOf R
16 * @since v0.8.0
17 * @category Object
18 * @typedefn Idx = String | Int
19 * @sig Idx -> a -> {k: v} -> {k: v}
20 * @param {String|Number} prop The property name to set
21 * @param {*} val The new value
22 * @param {Object} obj The object to clone
23 * @return {Object} A new object equivalent to the original except for the changed property.
24 * @see R.dissoc, R.pick
25 * @example
26 *
27 * R.assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3}
28 */
29
30
31var assoc =
32/*#__PURE__*/
33_curry3(function assoc(prop, val, obj) {
34 return assocPath([prop], val, obj);
35});
36
37module.exports = assoc;
Note: See TracBrowser for help on using the repository browser.