UNPKG

typedash

Version:

modern, type-safe collection of utility functions

55 lines (54 loc) 1.72 kB
import { t as Many } from "./Many-bCNxekD7.cjs"; import { t as Maybe } from "./Maybe-BVpZiDsE.cjs"; //#region src/functions/isArray/isArray.d.ts declare const isArray: IsArray; interface IsArray { /** * The same as `Array.isArray` but with a better type guard. * @param value The value to check. * @returns `true` if the value is an array, `false` otherwise. * @example * ```ts * isArray([1, 2, 3]) // true * isArray('foo') // false * ``` */ <T>(value: Maybe<ArrayElement<T>[]>): value is NonNullable<typeof value>; /** * The same as `Array.isArray` but with a better type guard. * @param value The value to check. * @returns `true` if the value is an array, `false` otherwise. * @example * ```ts * isArray([1, 2, 3]) // true * isArray('foo') // false * ``` */ <T>(value: Maybe<readonly ArrayElement<T>[]>): value is NonNullable<typeof value>; /** * The same as `Array.isArray` but with a better type guard. * @param value The value to check. * @returns `true` if the value is an array, `false` otherwise. * @example * ```ts * isArray([1, 2, 3]) // true * isArray('foo') // false * ``` */ <T>(value: Maybe<Many<T>>): value is NonNullable<readonly T[]>; /** * The same as `Array.isArray` but with a better type guard. * @param value The value to check. * @returns `true` if the value is an array, `false` otherwise. * @example * ```ts * isArray([1, 2, 3]) // true * isArray('foo') // false * ``` */ <T>(value: unknown): value is readonly T[]; } type ArrayElement<T> = T extends ReadonlyArray<infer U> ? U : never; //#endregion export { isArray as t }; //# sourceMappingURL=isArray-OI9nLS_c.d.cts.map