Icard/angular-clarity-master(work.../node_modules/ramda/es/modify.js

32 lines
1.1 KiB
JavaScript

import _curry3 from "./internal/_curry3.js";
import modifyPath from "./modifyPath.js";
/**
* Creates a copy of the passed object by applying an `fn` function to the given `prop` property.
*
* The function will not be invoked, and the object will not change
* if its corresponding property does not exist in the object.
* All non-primitive properties are copied to the new object by reference.
*
* @func
* @memberOf R
* @since v0.28.0
* @category Object
* @sig Idx -> (v -> v) -> {k: v} -> {k: v}
* @param {String|Number} prop The property to be modified.
* @param {Function} fn The function to apply to the property.
* @param {Object} object The object to be transformed.
* @return {Object} The transformed object.
* @example
*
* const person = {name: 'James', age: 20, pets: ['dog', 'cat']};
* R.modify('age', R.add(1), person); //=> {name: 'James', age: 21, pets: ['dog', 'cat']}
* R.modify('pets', R.append('turtle'), person); //=> {name: 'James', age: 20, pets: ['dog', 'cat', 'turtle']}
*/
var modify =
/*#__PURE__*/
_curry3(function modify(prop, fn, object) {
return modifyPath([prop], fn, object);
});
export default modify;