import { Extends } from '../../commonness/Extends'; import { If } from '../../commonness/If'; import { Tuple } from '../../primitive/Tuple'; import { Length } from '../Length'; import { Push } from '../Push'; /** * * Type that takes an array and a number and returns an array of arrays of the specified size * * 튜플과 숫자를 받아 지정된 크기의 튜플로 분할된 튜플을 반환하는 타입 * * @params A - Array to be chunked / 분할할 튜플 * * @params Split - Size of each chunk / 각 청크의 크기 * * @returns * Array of arrays of the specified size / 지정된 크기의 튜플로 분할된 튜플 * * @example * type cases = [ * Expect, []>>, * Expect, [[1], [2], [3]]>>, * Expect, [[1, 2], [3]]>>, * Expect, [[1, 2], [3, 4]]>>, * Expect, [[1, 2, 3, 4]]>>, * Expect, [[1, true], [2, false]]>>, * ]; * * @link * https://www.utilscript.site/docs/usage-array/chunk * */ export type Chunk = Split extends 0 ? A : A extends readonly [infer AF, ...infer AR] ? Length> extends Split ? Chunk>> : Chunk, R> : If, 0>, R, Push>;