Skip to content

mvoorberg/x-assign

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

x-assign

An improved Object.assign that will merge nested objects and concatenate arrays.

Coverage Status Build Status

Installation

$ npm install x-assign

Usage

const XAssign = require("x-assign");

const objA = {
  car: ["vroom"],
  pear: "green",
  banana: { yellow: "$0.69", brown: "$0.39" },
};
const objB = {
  car: ["beep", "crash"],
  cat: "meow",
  cow: "moo",
  banana: { green: "$0.89", yellow: "$0.56 sale!" },
};
const objC = {
  duck: {says: "quack"},
};

const result = XAssign.assign(objA, objB, objC);

console.log(result); 
{
      car: ["vroom", "beep", crash],
      pear: "green",
      banana: { green: "$0.89", yellow: "$0.56 sale!", brown: "$0.39"  },
      cat: "meow",
      cow: "moo",
      duck: {says: "quack"},
 }

See more examples in the tests!

Need Support?

x-assign is a software development project by BinaryOps Software Inc.

About

A better Object.assign, used for combining options that need to support merging of nested properties and concatenated arrays.

Resources

License

Stars

Watchers

Forks

Packages

No packages published