source: node_modules/ramda/es/modify.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.1 KB
Line 
1import _curry3 from "./internal/_curry3.js";
2import modifyPath from "./modifyPath.js";
3/**
4 * Creates a copy of the passed object by applying an `fn` function to the given `prop` property.
5 *
6 * The function will not be invoked, and the object will not change
7 * if its corresponding property does not exist in the object.
8 * All non-primitive properties are copied to the new object by reference.
9 *
10 * @func
11 * @memberOf R
12 * @since v0.28.0
13 * @category Object
14 * @sig Idx -> (v -> v) -> {k: v} -> {k: v}
15 * @param {String|Number} prop The property to be modified.
16 * @param {Function} fn The function to apply to the property.
17 * @param {Object} object The object to be transformed.
18 * @return {Object} The transformed object.
19 * @example
20 *
21 * const person = {name: 'James', age: 20, pets: ['dog', 'cat']};
22 * R.modify('age', R.add(1), person); //=> {name: 'James', age: 21, pets: ['dog', 'cat']}
23 * R.modify('pets', R.append('turtle'), person); //=> {name: 'James', age: 20, pets: ['dog', 'cat', 'turtle']}
24 */
25
26var modify =
27/*#__PURE__*/
28_curry3(function modify(prop, fn, object) {
29 return modifyPath([prop], fn, object);
30});
31
32export default modify;
Note: See TracBrowser for help on using the repository browser.