Nuclear Powered Marshmallows

    just-merge
    TypeScript icon, indicating that this package has built-in type declarations

    1.2.0 • Public • Published

    just-merge

    Part of a library of zero-dependency npm modules that do just do one thing.
    Guilt-free utilities for every occasion.

    Try it now

    Shallow assign. Like just-extend but without deep copy option.

    import merge from 'just-merge';
    
    let obj = {a: 3, b: 5};
    merge(obj, {a: 4, c: 8}); // {a: 4, b: 5, c: 8}
    obj; // {a: 4, b: 5, c: 8}
    
    let obj = {a: 3, b: 5};
    merge({}, obj, {a: 4, c: 8}); // {a: 4, b: 5, c: 8}
    obj; // {a: 3, b: 5}
    
    let arr = [1, 2, 3];
    let obj = {a: 3, b: 5};
    merge(obj, {c: arr}); // {a: 3, b: 5, c: [1, 2, 3]}
    arr.push[4];
    obj; // {a: 3, b: 5, c: [1, 2, 3, 4]}
    
    merge({a: 4, b: 5}); // {a: 4, b: 5}
    merge(3, {a: 4, b: 5}); // throws
    merge({a: 4, b: 5}, 3); // throws
    merge({a: 4, b: 5}, {b: 4, c: 5}, 'c'); // throws

    Install

    npm i just-merge

    DownloadsWeekly Downloads

    553

    Version

    1.2.0

    License

    MIT

    Unpacked Size

    4.52 kB

    Total Files

    6

    Last publish

    Collaborators

    • angus-c