1 line
3.0 KiB
Plaintext
1 line
3.0 KiB
Plaintext
{"version":3,"file":"hasAtLeast-BfO0atOv.cjs","names":["purry"],"sources":["../src/hasAtLeast.ts"],"sourcesContent":["import type { IsNumericLiteral } from \"type-fest\";\nimport type { IterableContainer } from \"./internal/types/IterableContainer\";\nimport { purry } from \"./purry\";\nimport type { ArrayRequiredPrefix } from \"./internal/types/ArrayRequiredPrefix\";\n\n/**\n * Checks if the given array has at least the defined number of elements. When\n * the minimum used is a literal (e.g. `3`) the output is refined accordingly so\n * that those indices are defined when accessing the array even when using\n * typescript's 'noUncheckedIndexAccess'.\n *\n * @param data - The input array.\n * @param minimum - The minimum number of elements the array must have.\n * @returns True if the array's length is *at least* `minimum`. When `minimum`\n * is a literal value, the output is narrowed to ensure the first items are\n * guaranteed.\n * @signature\n * R.hasAtLeast(data, minimum)\n * @example\n * R.hasAtLeast([], 4); // => false\n *\n * const data: number[] = [1,2,3,4];\n * R.hasAtLeast(data, 1); // => true\n * data[0]; // 1, with type `number`\n * @dataFirst\n * @category Array\n */\nexport function hasAtLeast<T extends IterableContainer, N extends number>(\n data: IterableContainer | T,\n minimum: IsNumericLiteral<N> extends true ? N : never,\n): data is ArrayRequiredPrefix<T, N>;\nexport function hasAtLeast(data: IterableContainer, minimum: number): boolean;\n\n/**\n * Checks if the given array has at least the defined number of elements. When\n * the minimum used is a literal (e.g. `3`) the output is refined accordingly so\n * that those indices are defined when accessing the array even when using\n * typescript's 'noUncheckedIndexAccess'.\n *\n * @param minimum - The minimum number of elements the array must have.\n * @returns True if the array's length is *at least* `minimum`. When `minimum`\n * is a literal value, the output is narrowed to ensure the first items are\n * guaranteed.\n * @signature\n * R.hasAtLeast(minimum)(data)\n * @example\n * R.pipe([], R.hasAtLeast(4)); // => false\n *\n * const data = [[1,2], [3], [4,5]];\n * R.pipe(\n * data,\n * R.filter(R.hasAtLeast(2)),\n * R.map(([, second]) => second),\n * ); // => [2,5], with type `number[]`\n * @dataLast\n * @category Array\n */\nexport function hasAtLeast<N extends number>(\n minimum: IsNumericLiteral<N> extends true ? N : never,\n): <T extends IterableContainer>(\n data: IterableContainer | T,\n) => data is ArrayRequiredPrefix<T, N>;\nexport function hasAtLeast(\n minimum: number,\n): (data: IterableContainer) => boolean;\n\nexport function hasAtLeast(...args: readonly unknown[]): unknown {\n return purry(hasAtLeastImplementation, args);\n}\n\nconst hasAtLeastImplementation = (\n data: IterableContainer,\n minimum: number,\n): boolean => data.length >= minimum;\n"],"mappings":"wCAkEA,SAAgB,EAAW,GAAG,EAAmC,CAC/D,OAAOA,EAAAA,EAAM,EAA0B,EAAK,CAG9C,MAAM,GACJ,EACA,IACY,EAAK,QAAU"} |