Home Reference Source

ts_temp/object/assoc.js

import curryN from '../function/curryN';
/**
 * Makes a shallow clone of an object, setting or overriding the specified
 * property with the given value. All non-primitive properties are
 * copied by reference.
 *
 * @deprecated use object/propSet instead
 * @param {String} prop The property name to set
 * @param {*} val The new value
 * @param {Object} obj The object to clone
 * @return {Object} A new object equivalent to the original except for the changed property.
 * @example
 *
 *      assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3}
 */
export default curryN(3, (prop, val, obj = {}) => ({
    ...obj,
    [prop]: val,
}));