@fingerartur/ts-merge-objects
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

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

Changelog

  • v1.1.0
    • merge accepts any number of objects now
  • v1.0.1
    • merge function

Readme

Keywords

Package Sidebar

Install

npm i @fingerartur/ts-merge-objects

Weekly Downloads

68

Version

1.1.0

License

ISC

Unpacked Size

4.45 kB

Total Files

10

Last publish

Collaborators

  • fingerartur