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