Nearly Past Midnight

    union-merge

    1.0.3 • Public • Published

    union-merge

    NPM Version

    Deeply merging unstructured data.

    Installation

    npm i union-merge -S

    usage

     
    const unionMerge = require('union-merge');
     
    let target = {
        name: 'Tom',
        age: '30',
        orders: [
            {orderId: 20180104, price: 200, title: 'a', phone: 1234},
            {orderId: 20180105, price: 200, title: 'a'}
        ]
    };
     
    let source = {
        name: 'Tom',
        age: 31,
        orders: [
            {orderId: 20180104, price: 200, title: 'a'},
            {orderId: 20180105, price: 220, title: 'a', phone: 1234, email: '1@1.com'},
            {orderId: 20180106, price: 200, title: 'a'},
            {orderId: 20180107, price: 200, title: 'a', phone: 1234},
        ]
    };
     
    let result = unionMerge(target, source, ['orderId']);
     
    /*
     
    {
        name: 'Tom',
        age: 31,
        orders: [
            {orderId: 20180104, price: 200, title: 'a', phone: 1234},
            {orderId: 20180105, price: 220, title: 'a', phone: 1234, email: '1@1.com'},
            {orderId: 20180106, price: 200, title: 'a'},
            {orderId: 20180107, price: 200, title: 'a', phone: 1234},
        ]
    }
      
    */
     

    Tests

    no scripts

    Contributing

    ...

    Keywords

    none

    Install

    npm i union-merge

    DownloadsWeekly Downloads

    1

    Version

    1.0.3

    License

    MIT

    Last publish

    Collaborators

    • cooperhsiung