[d24f17c] | 1 | var _curry3 =
|
---|
| 2 | /*#__PURE__*/
|
---|
| 3 | require("./internal/_curry3.js");
|
---|
| 4 |
|
---|
| 5 | var modifyPath =
|
---|
| 6 | /*#__PURE__*/
|
---|
| 7 | require("./modifyPath.js");
|
---|
| 8 | /**
|
---|
| 9 | * Creates a copy of the passed object by applying an `fn` function to the given `prop` property.
|
---|
| 10 | *
|
---|
| 11 | * The function will not be invoked, and the object will not change
|
---|
| 12 | * if its corresponding property does not exist in the object.
|
---|
| 13 | * All non-primitive properties are copied to the new object by reference.
|
---|
| 14 | *
|
---|
| 15 | * @func
|
---|
| 16 | * @memberOf R
|
---|
| 17 | * @since v0.28.0
|
---|
| 18 | * @category Object
|
---|
| 19 | * @sig Idx -> (v -> v) -> {k: v} -> {k: v}
|
---|
| 20 | * @param {String|Number} prop The property to be modified.
|
---|
| 21 | * @param {Function} fn The function to apply to the property.
|
---|
| 22 | * @param {Object} object The object to be transformed.
|
---|
| 23 | * @return {Object} The transformed object.
|
---|
| 24 | * @example
|
---|
| 25 | *
|
---|
| 26 | * const person = {name: 'James', age: 20, pets: ['dog', 'cat']};
|
---|
| 27 | * R.modify('age', R.add(1), person); //=> {name: 'James', age: 21, pets: ['dog', 'cat']}
|
---|
| 28 | * R.modify('pets', R.append('turtle'), person); //=> {name: 'James', age: 20, pets: ['dog', 'cat', 'turtle']}
|
---|
| 29 | */
|
---|
| 30 |
|
---|
| 31 |
|
---|
| 32 | var modify =
|
---|
| 33 | /*#__PURE__*/
|
---|
| 34 | _curry3(function modify(prop, fn, object) {
|
---|
| 35 | return modifyPath([prop], fn, object);
|
---|
| 36 | });
|
---|
| 37 |
|
---|
| 38 | module.exports = modify; |
---|