Skip to main content

assoc()

const assoc: <T>(obj) => <K>(prop) => (val) => T = associate

Sets the val of prop in obj. Returning a new, shallow copy of the object.

Sets the val of prop in obj. Returning a new, shallow copy of the object.

Type Parameters

T

T extends object

The type of the input object.

Parameters

obj

T

The object to set the value on.

Returns

<K>(prop): (val) => T

Type Parameters

K

K extends string | number | symbol = keyof T

Parameters

prop

K

Returns

(val): T

Parameters

val

T[K]

Returns

T

Example

associate(personStore)('address')({
city: 'Austin',
street: '987 Sample St',
});
// {
// // ...,
// city: 'Austin',
// street: '987 Sample St',
// }