ramda-adjunct
Version:
Ramda Adjunct is the most popular and most comprehensive set of utilities for use with Ramda, providing a variety of useful, well tested functions with excellent documentation.
37 lines (32 loc) • 1.19 kB
JavaScript
exports.__esModule = true;
exports["default"] = void 0;
var _ramda = require("ramda");
var _flattenPath = _interopRequireDefault(require("./flattenPath"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
/**
* Flattens a property so that its fields are spread out into the provided object.
* It's like {@link RA.spreadProp|spreadProp}, but preserves object under the property path.
*
* @func flattenProp
* @memberOf RA
* @since {@link https://char0n.github.io/ramda-adjunct/1.19.0|v1.19.0}
* @category Object
* @typedef Idx = String | Int
* @sig [Idx] -> {k: v} -> {k: v}
* @param {!string|number} prop The property to flatten
* @param {!Object} obj The provided object
* @return {!Object} The flattened object
* @see {@link RA.flattenPath|flattenPath}, {@link RA.spreadProp|spreadProp}
* @example
*
* RA.flattenProp(
* 'b',
* { a: 1, b: { c: 3, d: 4 } }
* ); // => { a: 1, c: 3, d: 4, b: { c: 3, d: 4 } };
*/
var flattenProp = (0, _ramda.curry)(function (prop, obj) {
return (0, _flattenPath["default"])((0, _ramda.of)(prop), obj);
});
var _default = flattenProp;
exports["default"] = _default;
;