UNPKG

1.1 kBTypeScriptView Raw
1import { Assign as OAssign } from '../Object/Assign';
2import { List } from './List';
3import { Depth } from '../Object/_Internal';
4import { BuiltIn } from '../Misc/BuiltIn';
5import { Cast } from '../Any/Cast';
6/**
7 * Assign a list of [[List]] into `L` with [[Merge]]. Merges from left to
8 * right, first items get overridden by the next ones (last-in overrides).
9 * @param L to assign to
10 * @param Ls to assign
11 * @param depth (?=`'flat'`) 'deep' to do it deeply
12 * @param ignore (?=`BuiltIn`) types not to merge
13 * @param fill (?=`undefined`) types of `O` to be replaced with ones of `O1`
14 * @returns [[Object]]
15 * @example
16 * ```ts
17 * import {L} from 'ts-toolbelt'
18 *
19 * type test0 = Assign<[1, 2, 3], [[2, 1]]> // [2, 1, 3]
20 * type test1 = Assign<[], [[1, 2, 3, 4], [2, 4, 6]]> // [2, 4, 6, 4]
21 * type test2 = Assign<[0, 0, 0, 0, 0], [[0, 1], [0, 2, 0, 4?]]> // [0, 2, 0, 0 | 4, 0]
22 * ```
23 */
24export declare type Assign<L extends List, Ls extends List<List>, depth extends Depth = 'flat', ignore extends object = BuiltIn, fill extends any = never> = Cast<OAssign<L, Ls, depth, ignore, fill>, List>;