import { GreaterThan } from '../../number/GreaterThan'; import { Tuple } from '../../primitive/Tuple'; import { Concat } from '../Concat'; import { Length } from '../Length'; import { Push } from '../Push'; type SpliceImpl = T extends readonly [infer First, ...infer Rest] ? Length extends Start ? Length extends Delete ? [...Acc, ...Insert, First, ...Rest] : SpliceImpl, Push> : Length extends number ? Length extends Delete ? [...Acc, ...Insert, First, ...Rest] : Length extends Start ? SpliceImpl, Push> : Length extends 0 ? SpliceImpl, Push, DeletedCount> : SpliceImpl, Push> : never : Concat; /** * * Type that removes elements from an array and optionally adds new elements * * 배열에서 요소를 제거하고 선택적으로 새 요소를 추가하는 타입 * * @param T The array type to work with / 작업할 배열 타입 * * @param Start The starting index to remove elements (default: 0) / 요소를 제거할 시작 인덱스 (기본값: 0) * * @param Delete The number of elements to remove (default: array length) / 제거할 요소의 수 (기본값: 배열의 길이) * * @param Insert Array of new elements to insert (default: empty array) / 삽입할 새 요소들의 배열 (기본값: 빈 배열) * * @example * * type cases = [ * Expect, [1, 3]>>, * Expect, [1]>>, * Expect, [1, 9, 10, 2, 3]>>, * ] * * @link https://www.utilscript.site/docs/usage-array/splice * */ export type Splice, Insert extends Tuple = []> = GreaterThan> extends true ? T : Start extends Length ? T : Delete extends 0 ? T : SpliceImpl; export {};