@techor/extend
TypeScript icon, indicating that this package has built-in type declarations

3.0.23 • Public • Published

Deeply extend objects ~400B

NPM Version NPM Version NPM package ( download / month ) Follow @mastercorg Github release actions


  • Untainted input sources
  • Deeply extend
  • Return the extended result
  • Common extensions for configuration and options

Getting Started

npm install @techor/extend

Usage

import extend from '@techor/extend'

extend({ a: 1, b:2 }, { b: null, c:3 })
// { a:1, b: null, c:3 }

Overview

expect(
    extend(
        {
            a: 1,
            b: 2,
            d: {
                a: 1,
                b: [],
                c: { test1: 123, test2: 321 }
            },
            f: 5,
            g: 123,
            i: 321,
            j: [1, 2]
        },
        {
            b: 3,
            c: 5,
            d: {
                b: { first: 'one', second: 'two' },
                c: { test2: 222 }
            },
            e: { one: 1, two: 2 },
            f: [],
            g: (void 0),
            h: /abc/g,
            i: null,
            j: [3, 4]
        }
    )
)
    .toEqual({
        a: 1,
        b: 3,
        d:
        {
            a: 1,
            b: { first: 'one', second: 'two' },
            c: { test1: 123, test2: 222 }
        },
        f: [],
        g: undefined,
        c: 5,
        e: { one: 1, two: 2 },
        h: /abc/g,
        i: null,
        j: [3, 4]
    })

Inspiration


NPM Version

Package Sidebar

Install

npm i @techor/extend

Homepage

aron.tw

Weekly Downloads

677

Version

3.0.23

License

MIT

Unpacked Size

13.5 kB

Total Files

5

Last publish

Collaborators

  • 1aron