1 | "use strict";
|
---|
2 |
|
---|
3 | exports.__esModule = true;
|
---|
4 | exports["default"] = void 0;
|
---|
5 | var _ramda = require("ramda");
|
---|
6 | var _renameKeysWith = _interopRequireDefault(require("./renameKeysWith"));
|
---|
7 | function _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 | */
|
---|
29 | var renameKeyWith = (0, _ramda.curry)(function (fn, key, obj) {
|
---|
30 | return (0, _renameKeysWith["default"])((0, _ramda.when)((0, _ramda.equals)(key), fn), obj);
|
---|
31 | });
|
---|
32 | var _default = renameKeyWith;
|
---|
33 | exports["default"] = _default; |
---|