1.0.2 • Published 6 years ago

obj-deep-assign v1.0.2

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

Object Deep Assign

Object deep assign, recursive function.

Install

npm install obj-deep-assign
yarn add obj-deep-assign

Usage

import objDeepAssign from "obj-deep-assign";

Example Objects

const obj1 = {
  name: "John",
  age: 26,
  stats: {
    point: 43,
    energy: 10,
    title: "Newbie",
    skill: {
      js: 96,
      node: 74
    }
  }
};
const obj2 = {
  name: "John",
  age: 27,
  stats: {
    point: 83,
    energy: 90,
    title: "Master",
    skill: {
      js: 100,
      node: 97,
      react: 78
    }
  },
  avatar: "src/john.png"
};

Assign

const newObj = objDeepAssign(obj1, obj2);

console.log(newObj);

/*
{
  name: 'John',
  age: 27,
  stats: {
    point: 83, 
    energy: 90, 
    title: 'Master', 
    skill: { 
      js: 100, 
      node: 97, 
      react: 78 },
  },
  avatar: 'src/john.png',
};
*/