-
-
Notifications
You must be signed in to change notification settings - Fork 148
/
Assign.ts
43 lines (40 loc) · 1.03 KB
/
Assign.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import {Iteration} from '../Iteration/Iteration'
import {IterationOf} from '../Iteration/IterationOf'
import {MergeFlat} from './Merge'
import {Pos} from '../Iteration/Pos'
import {Next} from '../Iteration/Next'
import {Length} from '../List/Length'
import {Cast} from '../Any/Cast'
import {List} from '../List/List'
/**
* @hidden
*/
type _Assign<O extends object, Os extends List<object>, I extends Iteration = IterationOf<'0'>> = {
0: _Assign<MergeFlat<Os[Pos<I>], O>, Os, Next<I>>
1: O
}[
Pos<I> extends Length<Os>
? 1
: 0
]
/**
* @hidden
*/
export type __Assign<O extends object, Os extends List<object>> =
_Assign<O, Os> extends infer X
? Cast<X, object>
: never
/** Assign a list of **`object`** into **`O`** with [[Merge]] (last-in overrides)
* @param O to assign to
* @param Os to assign
* @returns **`object`**
* @example
* ```ts
* ```
*/
export type Assign<O extends object, Os extends List<object>> =
O extends unknown
? Os extends unknown
? __Assign<O, Os>
: never
: never