simple-deep-assign

A very simple alternative of Object.assign() that recursively copies objects' elements to a target object. Recursion is only applied to a pure object. The other types of elements are just replaced with source elements.

Usage no npm install needed!

<script type="module">
  import simpleDeepAssign from 'https://cdn.skypack.dev/simple-deep-assign';
</script>

README

simple-deep-assign

Codecov master

A very simple alternative of Object.assign() that recursively copies objects' elements to a target object. Recursion is only applied to a pure object. The other types of elements are just replaced with source elements.

Install

$ npm i simple-deep-assign

Usage

import deepAssign from 'simple-deep-assign';

const target = { a: 'a' };
deepAssign(target, { b: 'b' }, { c: [ 1, 2 ] }, { d: { a: 'a' } }, { d: { b: 'b' } });

target; // { a: 'a', b: 'b', c: [ 1, 2 ], d: { a: 'a', b: 'b' } }

API Document

https://ygoto3.github.io/simple-deep-assign/function/index.html#static-function-simpleDeepAssign