import type { Ary } from "."; import type { Args, Fn } from "../HKT"; import type { Nat } from "../Num"; import type { Extends, If, IsAny, Not } from "../helpers"; /** * Check if an {@link Ary} (i.e., `Array` or `ReadonlyArray`) is a fixed length one (i.e., the * `length` property is a number literal). * * Sig: `(a: Ary) => boolean` * * @example * ```typescript * type R1 = IsFixedLength; * // ^?: false * type R2 = IsFixedLength; * // ^?: false * type R3 = IsFixedLength<["foo", "bar"]>; * // ^?: true * type R4 = IsFixedLength; * // ^?: false * ``` */ export type IsFixedLength = If< IsAny, boolean, A extends { length: infer N } ? Not> : never >; /** * [Fn] Check if an {@link Ary} (i.e., `Array` or `ReadonlyArray`) is a fixed length one (i.e., the * `length` property is a number literal). * * Sig: `(a: Ary) => boolean` */ export default interface IsFixedLengthFn extends Fn<[Ary], boolean> { def: ([a]: Args) => IsFixedLength; }