Module: Set
Type Aliases
Set
Ƭ Set<Source, Path, Value>: Source extends Record<string, unknown> ? Path extends `${number}.${infer Right}` ? Set<Source, Right, Value> : Path extends `${infer Left extends keyof Source}.${infer Right}` ? { [Key in keyof Source]: Key extends Exclude<keyof Source, Left> ? Source[Key] : Set<Exclude<Source[Left], undefined>, Right, Value> } : Path extends keyof Source ? { [Key in keyof Source]: Key extends Exclude<keyof Source, Path> ? Source[Key] : Value } : never : Source extends any[] ? Path extends `${infer Index extends number}.${infer Right}` ? Unshift<Source, Index, Set<Exclude<Source[Index], undefined>, Right, Value>> : Path extends `${infer Index extends number}` ? Unshift<Source, Index, Value> : never : never
Sets the Value type inside a nested object type Source by provided Path
written in dot-notation.
Type parameters
| Name | Type |
|---|---|
Source | extends Flattenable |
Path | extends string |
Value | Value |
Functions
set
▸ set<Source, Path, Value>(path, value): (source: Source) => Set<Source, Path, Value>
Sets the value inside a nested source object by provided path
written in dot-notation.
Type parameters
| Name | Type |
|---|---|
Source | extends Flattenable |
Path | extends string | number | symbol |
Value | Value |
Parameters
| Name | Type |
|---|---|
path | Path |
value | Value |
Returns
fn
▸ (source): Set<Source, Path, Value>
Parameters
| Name | Type |
|---|---|
source | Source |
Returns
Set<Source, Path, Value>
▸ set<Source, Path, Value>(source, path, value): Set<Source, Path, Value>
Sets the value inside a nested source object by provided path
written in dot-notation.
Type parameters
| Name | Type |
|---|---|
Source | extends Flattenable |
Path | extends string | number | symbol |
Value | Value |
Parameters
| Name | Type |
|---|---|
source | Source |
path | Path |
value | Value |
Returns
Set<Source, Path, Value>