typedash
Version:
modern, type-safe collection of utility functions
55 lines (54 loc) • 1.72 kB
TypeScript
import { t as Many } from "./Many-CC3hL8UU.js";
import { t as Maybe } from "./Maybe-pvX1mStM.js";
//#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-B6U5ciAZ.d.ts.map