import { Tuple } from '../../primitive/Tuple'; import { Length } from '../Length'; import { Push } from '../Push'; /** * * Type that takes an array, a value, and a start and end index and returns an array with the specified value in the specified range * * 튜플, 값, 시작과 끝 인덱스를 받아 지정된 범위에 지정된 값을 가진 튜플을 반환하는 타입 * * @params T - Array to be filled / 채워질 튜플 * * @params N - Value to fill / 채울 값 * * @params Start - Start index / 시작 인덱스 * * @params End - End index / 끝 인덱스 * * @returns Array with the specified value in the specified range / 지정된 범위에 지정된 값을 가진 튜플 * * @example * type cases = [ * Expect, []>>, * Expect, []>>, * Expect, [1, 2, 3]>>, * Expect, [1, 2, 3]>>, * Expect, [0, 0, 0]>>, * Expect, [true, true, true]>>, * Expect, [true, 2, 3]>>, * Expect, [1, true, true]>>, * Expect, [1, 2, 3]>>, * Expect, [1, 2, 3]>>, * Expect, [true, true, true]>>, * ]; * * @link https://www.utilscript.site/docs/usage-array/fill * */ export type Fill, Result extends Tuple = [], InRange extends boolean = false> = T extends readonly [infer First, ...infer Rest] ? Start extends End ? T : Length extends Start ? Fill, true> : InRange extends true ? Length extends End ? Fill, false> : Fill, true> : Fill, false> : Result;