Function safeSet
- safeSet(
data: object,
accessor: string,
value: any,
options?: {
createMissing?: boolean;
operation?: "set" | "add" | "div" | "mult" | "set-undefined" | "sub";
},
): boolean Parameters
- data: object
An object to access entry data.
- accessor: string
A string describing the entries to access.
- value: any
A new value to set if an entry for accessor is found.
Optional
options: {
createMissing?: boolean;
operation?: "set" | "add" | "div" | "mult" | "set-undefined" | "sub";
}Options.
Optional
createMissing?: booleanIf
true
missing accessor entries will be created as objects automatically; default:false
.Optional
operation?: "set" | "add" | "div" | "mult" | "set-undefined" | "sub"Operation to perform including:
add
,div
,mult
,set
,set-undefined
,sub
; default:set
.
Returns boolean
True if successful.
- data: object
Provides a way to safely set an objects data / entries given an accessor string which describes the entries to walk. To access deeper entries into the object format the accessor string with
.
between entries to walk.