1 | "use strict";
|
---|
2 |
|
---|
3 | exports.__esModule = true;
|
---|
4 | exports["default"] = void 0;
|
---|
5 | var _ramda = require("ramda");
|
---|
6 | /**
|
---|
7 | * Creates a new object with the own properties of the provided object, but the
|
---|
8 | * keys renamed according to logic of renaming function.
|
---|
9 | *
|
---|
10 | * Keep in mind that in the case of keys conflict is behaviour undefined and
|
---|
11 | * the result may vary between various JS engines!
|
---|
12 | *
|
---|
13 | * @func renameKeysWith
|
---|
14 | * @memberOf RA
|
---|
15 | * @since {@link https://char0n.github.io/ramda-adjunct/1.5.0|v1.5.0}
|
---|
16 | * @category Object
|
---|
17 | * @sig (a -> b) -> {a: *} -> {b: *}
|
---|
18 | * @param {Function} fn Function that renames the keys
|
---|
19 | * @param {!Object} obj Provided object
|
---|
20 | * @return {!Object} New object with renamed keys
|
---|
21 | * @see {@link https://github.com/ramda/ramda/wiki/Cookbook#rename-keys-of-an-object-by-a-function|Ramda Cookbook}, {@link RA.renameKeys|renameKeys}
|
---|
22 | * @example
|
---|
23 | *
|
---|
24 | * RA.renameKeysWith(R.concat('a'), { A: 1, B: 2, C: 3 }) //=> { aA: 1, aB: 2, aC: 3 }
|
---|
25 | */
|
---|
26 | var renameKeysWith = (0, _ramda.curry)(function (fn, obj) {
|
---|
27 | return (0, _ramda.pipe)(_ramda.toPairs, (0, _ramda.map)((0, _ramda.over)((0, _ramda.lensIndex)(0), fn)), _ramda.fromPairs)(obj);
|
---|
28 | });
|
---|
29 | var _default = renameKeysWith;
|
---|
30 | exports["default"] = _default; |
---|