source: node_modules/ramda-adjunct/lib/renameKeyWith.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.3 KB
RevLine 
[d24f17c]1"use strict";
2
3exports.__esModule = true;
4exports["default"] = void 0;
5var _ramda = require("ramda");
6var _renameKeysWith = _interopRequireDefault(require("./renameKeysWith"));
7function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8/**
9 * Creates a new object with the own properties of the provided object, but the
10 * key `key` renamed according to logic of renaming function.
11 *
12 * Keep in mind that in case the new key name already existed on the object,
13 * the behaviour is undefined and the result may vary between various JS engines!
14 *
15 * @func renameKeyWith
16 * @memberOf RA
17 * @since {@link https://char0n.github.io/ramda-adjunct/2.29.0|v2.29.0}
18 * @category Object
19 * @sig (k -> k) -> k -> {k: v} -> {k: v}
20 * @param {Function} fn Function that renames the keys
21 * @param {!string} key Key to rename
22 * @param {!Object} obj Provided object
23 * @return {!Object} New object with renamed key
24 * @see {@link RA.renameKeysWith|renameKeysWith}
25 * @example
26 *
27 * RA.renameKeyWith(R.concat('a'), 'A', { A: 1 }) //=> { aA: 1 }
28 */
29var renameKeyWith = (0, _ramda.curry)(function (fn, key, obj) {
30 return (0, _renameKeysWith["default"])((0, _ramda.when)((0, _ramda.equals)(key), fn), obj);
31});
32var _default = renameKeyWith;
33exports["default"] = _default;
Note: See TracBrowser for help on using the repository browser.