source: node_modules/ramda-adjunct/src/spreadProp.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: 841 bytes
Line 
1import { of, curry } from 'ramda';
2
3import spreadPath from './spreadPath';
4
5/**
6 * Spreads object under property onto provided object.
7 * It's like {@link RA.flattenProp|flattenProp}, but removes object under the property.
8 *
9 * @func spreadProp
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 spread
16 * @param {!Object} obj The provided object
17 * @return {!Object} The result of the spread
18 * @see {@link RA.spreadPath|spreadPath}, {@link RA.flattenProp|flattenProp}
19 * @example
20 *
21 * RA.spreadProp('b', { a: 1, b: { c: 3, d: 4 } }); // => { a: 1, c: 3, d: 4 };
22 */
23const spreadProp = curry((prop, obj) => spreadPath(of(Array, prop), obj));
24
25export default spreadProp;
Note: See TracBrowser for help on using the repository browser.