Function: objCopy()
objCopy<
Key,InValue,OutValue,IgnoredKey>(input,output?,ignoreKeys?,override?,recursive?):Record<PropertyKey,unknown>
Defined in: packages/core/src/obj/objCopy.ts:41
Deep-copy an object to another object
Type Parameters
Key
Key extends PropertyKey
InValue
InValue
OutValue
OutValue
IgnoredKey
IgnoredKey extends PropertyKey
Parameters
input
Record<Key, InValue>
input object
output?
Record<PropertyKey, OutValue>
ignoreKeys?
(optional) input peroperties to be ignored. Prevents output's property to be overriden.
For child object properties use "." (dot) separated path.
Eg: "child.grandchild1" where input is { child: { grandchild1: 1, grandchild2: 2 }}
Set<IgnoredKey> | IgnoredKey[]
override?
(optional) whether to allow override output properties. This will only be used if output object is provided and has own property. Accepted values:
true: input property will override output propertyfalse: no overriding if output contains the property. Even if the property value isundefined."empty": only allow overriding output property if it's value is empty by using isEmpty.function: decide whether to override on a per property basis.
Function Arguments: 1. key: current property name/key 2. outputValue: output property value 3. inputValue: input property value
Default: false
boolean | "empty" | (key, outputValue, inputValue) => boolean
recursive?
boolean = true
Returns
Record<PropertyKey, unknown>
copied and/or merged object