Single object extension
pObj.extend(target, source, [option])
target: The target object — what to apply the sources’ properties to, which is returned after it is modified.
source: The source object — objects containing the properties you want to apply.
output [optional]: an optional object to define the option of extension.
the target object
Multiple objects extension
pObj.extends(target, sources, [option])
target: The target object — what to apply the sources’ properties to, which is returned after it is modified.
sources: The source objects — array of objects containing the properties you want to apply.
output [optional]: an optional object to define the option of extension.
the target object
tidy: if tidy = 1, undefined value in object will be ignored, 2 null value will be ignored
mergeArr: if mergeArr equal to true,
simple extend example
const target = {
foo: {
a: 1,
b: 2
}
}
const source = {
foo: {
b: 1,
c: 1
}
}
const output = pObj.extend(target, source)
// output = { foo: {a: 1, b: 1, c: 1}}
multiple extends example
const target = {
foo: {
a: 1,
b: 2
}
}
const source1 = {
foo: {
c: 1
}
}
const source2 = {
foo: {
b: 3,
e: 3
}
}
const output = pObj.extend(target, [source1, soruce2])
// output = { foo: {a: 1, b: 3, c: 1, e: 3}}