UNPKG

ts-prime

Version:

A utility library for JavaScript and Typescript.

32 lines 900 B
/** * Gets the first element of `array`. * Note: In `pipe`, use `first()` form instead of `first`. Otherwise, the inferred type is lost. * @param array the array * @signature * P.first(array) * @example * P.first([1, 2, 3]) // => 1 * P.first([]) // => undefined * P.pipe( * [1, 2, 4, 8, 16], * P.filter(x => x > 3), * P.first(), * x => x + 1 * ); // => 5 * * @category Array, Pipe */ export declare function first<T>(array: readonly T[]): T | undefined; export declare function first<T>(): (array: readonly T[]) => T | undefined; export declare function first<T>(defaultValue: T): (array: readonly T[]) => T; export declare namespace first { function lazy<T>(): (value: T) => { done: boolean; hasNext: boolean; next: T; }; namespace lazy { const single = true; } } //# sourceMappingURL=first.d.ts.map