mergescheme
v1.0.2
Published
merge user old data to default scheme
Downloads
1
Readme
mergescheme
merge user old data to default scheme
最大限度保留 target 的类型,其中如果对象的 key 名字以_xxxx_
格式开始的数组被认为不可变长度对象,merge 时会强制同步到和 targe 一致的长度。
usage
import mergescheme from 'mergescheme'
const target = {
name: 'jake',
age: 22,
love: [1, 2],
_tabs_: [0, 0],
}
const source = {
name: 'kitty',
age: '60',
love: [3, 4],
_tabs_: [1, 2, 3, 4],
}
const result = mergescheme(target, source)
result = {
name: 'kitty',
age: 22,
love: [3, 4],
_tabs_: [1, 2]
}