Skip to content

Latest commit

 

History

History
executable file
·
17 lines (12 loc) · 347 Bytes

readme.md

File metadata and controls

executable file
·
17 lines (12 loc) · 347 Bytes

Merge objects

Deep merge two objects

import { merge } from '@fingerartur/ts-merge-objects'

const obj1 = { a: 1, b: { name: 'Tom' }}
const obj2 = { b: { name: 'Jerry' }, c: 4 }
const result = merge(obj1, obj2)

// result:
// { a: 1, b: { name: 'Jerry' }, c: 4 }

Notes:

  • arrays get overwritten just like any other attribute