source: node_modules/ramda/src/modify.js

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: 1.2 KB
RevLine 
[d24f17c]1var _curry3 =
2/*#__PURE__*/
3require("./internal/_curry3.js");
4
5var modifyPath =
6/*#__PURE__*/
7require("./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
32var modify =
33/*#__PURE__*/
34_curry3(function modify(prop, fn, object) {
35 return modifyPath([prop], fn, object);
36});
37
38module.exports = modify;
Note: See TracBrowser for help on using the repository browser.