recursive-assign
v0.2.0
Published
recursive assign
Downloads
7
Readme
recursive-assign
just recursive assign
use
npm i recursive-assign
const extend = require('recursive-assign')
const { equal } = require('assert')
let a = {
x: '3',
y: true,
z: {
ff: 'as',
gg: 0,
hh: {
kl: 'sa'
},
ll: 'sdf',
arr: [7],
func: 'sd'
}
}
let b = {
x: 6,
y: false,
z: {
ff: 'as8',
gg: 56,
jj: 'asd',
hh: {
kl: (ori) => ori + '5', //use function to change original value
hhg: 'sdf'
},
arr: '90',
func: () => {
return () => 'safds' //change to a function
}
}
}
extend(a, b)
equal(a.x, 6)
equal(a.y, false)
equal(a.z.ff, 'as8')
equal(a.z.hh.kl, 'sa5')
equal(a.z.ll, 'sdf')
equal(a.z.hh.hhg, 'sdf')
equal(a.z.arr, '90')
equal(a.z.func(), 'safds')
License
MIT