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