source: node_modules/ramda-adjunct/es/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: 929 bytes
RevLine 
[d24f17c]1import { of, curry } from 'ramda';
2import flattenPath from './flattenPath';
3
4/**
5 * Flattens a property so that its fields are spread out into the provided object.
6 * It's like {@link RA.spreadProp|spreadProp}, but preserves object under the property path.
7 *
8 * @func flattenProp
9 * @memberOf RA
10 * @since {@link https://char0n.github.io/ramda-adjunct/1.19.0|v1.19.0}
11 * @category Object
12 * @typedef Idx = String | Int
13 * @sig [Idx] -> {k: v} -> {k: v}
14 * @param {!string|number} prop The property to flatten
15 * @param {!Object} obj The provided object
16 * @return {!Object} The flattened object
17 * @see {@link RA.flattenPath|flattenPath}, {@link RA.spreadProp|spreadProp}
18 * @example
19 *
20 * RA.flattenProp(
21 * 'b',
22 * { a: 1, b: { c: 3, d: 4 } }
23 * ); // => { a: 1, c: 3, d: 4, b: { c: 3, d: 4 } };
24 */
25var flattenProp = curry(function (prop, obj) {
26 return flattenPath(of(Array, prop), obj);
27});
28export default flattenProp;
Note: See TracBrowser for help on using the repository browser.