Skip to main content

extendImmutable

Extend an object by appending all of the properties from each supplied object. When there are identical properties, the right-most property takes precedence. This function returns a immutable object reference which is basically a new combined copy of the supplied objects.

Signature

extendImmutable<T>(...objects: T[]): T

Parameters

NameTypeOptionalDescription
objectsT[]NoSpecifies the objects to extend the immutable object with.

Return value

Returns the extended immutable object.

Example

import { extendImmutable } from "@tripetto/builder";

const xyz = { a: 1, b: 2, c };

extendImmutable(xyz, { b: 3, d: 4 }, { d: 5 }); // Returns `{ a: 1, b: 3, d: 5 }` which is not a reference to `xyz`