typescript-object-utils
Immutable object manipulation methods
Installation
Library can be installed via npm.
$ npm install typescript-object-utils
Examples
shallowEquals
import {shallowEquals} from "typescript-object-utils";
shallowEquals({a: 1, b: 2}, {a: 1, b: 2});
merge
import {merge} from "typescript-object-utils";
const x = {a: 1, b: 2};
const y = {b: 2, c: 3};
const r = merge(x, y); r;
const s = merge(x, x); s;
x === s;
shallowMerge
import {shallowMerge} from "typescript-object-utils";
const x = {a: 1, b: 2, c: 3};
const y = {c: 5, d: 4};
const z = {a: 1, b: 2};
const r = shallowMerge(x, y); r;
const s = shallowMerge(x, x); s;
x === s;
const t = shallowMerge(x, z); t;
x === t;
mergeDeep
import {mergeDeep} from "typescript-object-utils";
const x = {a: 1, b: {c: 3}};
const y = {b: {c: 3, d: 4}};
const z = {b: {c: 3}};
const r = mergeDeep(x, y); r;
const s = mergeDeep(x, z); s;
x === s;
shallowMergeDeep
import {shallowMergeDeep} from "typescript-object-utils";
const x = {a: 1, b: {c: 3}};
const y = {b: {c: 3, d: 4}};
const z = {b: {c: 3}};
const r = shallowMergeDeep(x, y); r;
const s = shallowMergeDeep(x, z); s;
x === s;