Skip to main content

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

NameType
Sourceextends Flattenable
Pathextends string
ValueValue

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

NameType
Sourceextends Flattenable
Pathextends string | number | symbol
ValueValue

Parameters

NameType
pathPath
valueValue

Returns

fn

▸ (source): Set<Source, Path, Value>

Parameters
NameType
sourceSource
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

NameType
Sourceextends Flattenable
Pathextends string | number | symbol
ValueValue

Parameters

NameType
sourceSource
pathPath
valueValue

Returns

Set<Source, Path, Value>