head() function
Iterable/AsyncIterable の最初の要素を返します。
first という別のエイリアス関数があります。
Signature:
typescript
declare function head<T extends Iterable<unknown> | AsyncIterable<unknown>>(
iterable: T,
): HeadReturnType<T>;Example
ts
head([1, 2, 3, 4, 5]); // 1
// with pipe
pipe([1, 2, 3, 4, 5], head); // 1
await pipe(Promise.resolve([1, 2, 3, 4, 5]), head); // 1
// with toAsync
await pipe(
[Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)],
toAsync,
head,
); // 1