1 | "use strict";
|
---|
2 |
|
---|
3 | exports.__esModule = true;
|
---|
4 | exports["default"] = void 0;
|
---|
5 | var _ramda = require("ramda");
|
---|
6 | var _flattenPath = _interopRequireDefault(require("./flattenPath"));
|
---|
7 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
---|
8 | /**
|
---|
9 | * Flattens a property so that its fields are spread out into the provided object.
|
---|
10 | * It's like {@link RA.spreadProp|spreadProp}, but preserves object under the property path.
|
---|
11 | *
|
---|
12 | * @func flattenProp
|
---|
13 | * @memberOf RA
|
---|
14 | * @since {@link https://char0n.github.io/ramda-adjunct/1.19.0|v1.19.0}
|
---|
15 | * @category Object
|
---|
16 | * @typedef Idx = String | Int
|
---|
17 | * @sig [Idx] -> {k: v} -> {k: v}
|
---|
18 | * @param {!string|number} prop The property to flatten
|
---|
19 | * @param {!Object} obj The provided object
|
---|
20 | * @return {!Object} The flattened object
|
---|
21 | * @see {@link RA.flattenPath|flattenPath}, {@link RA.spreadProp|spreadProp}
|
---|
22 | * @example
|
---|
23 | *
|
---|
24 | * RA.flattenProp(
|
---|
25 | * 'b',
|
---|
26 | * { a: 1, b: { c: 3, d: 4 } }
|
---|
27 | * ); // => { a: 1, c: 3, d: 4, b: { c: 3, d: 4 } };
|
---|
28 | */
|
---|
29 | var flattenProp = (0, _ramda.curry)(function (prop, obj) {
|
---|
30 | return (0, _flattenPath["default"])((0, _ramda.of)(Array, prop), obj);
|
---|
31 | });
|
---|
32 | var _default = flattenProp;
|
---|
33 | exports["default"] = _default; |
---|