source: node_modules/ramda-adjunct/lib/flattenProp.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
Line 
1"use strict";
2
3exports.__esModule = true;
4exports["default"] = void 0;
5var _ramda = require("ramda");
6var _flattenPath = _interopRequireDefault(require("./flattenPath"));
7function _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 */
29var flattenProp = (0, _ramda.curry)(function (prop, obj) {
30 return (0, _flattenPath["default"])((0, _ramda.of)(Array, prop), obj);
31});
32var _default = flattenProp;
33exports["default"] = _default;
Note: See TracBrowser for help on using the repository browser.