Skip to main content

Function: allAsync()

Returns a promise that resolves to true if fn returns a truthy value or a promise that resolves to a truthy value for all values of asyncIterable. Otherwise returns a promise that resolves to false.

Like Array.prototype.every, but for async iterables.

Example

console.log(
await pipe(
asAsync([`sloth`, `more sloth`, `even more sloth`]),
allAsync(string => string.length > 8),
),
)
//=> false

allAsync(fn)

allAsync<Value>(fn): (asyncIterable) => Promise<boolean>

Returns a promise that resolves to true if fn returns a truthy value or a promise that resolves to a truthy value for all values of asyncIterable. Otherwise returns a promise that resolves to false.

Like Array.prototype.every, but for async iterables.

Type Parameters

Value

Parameters

fn

Returns

Function

Parameters

asyncIterable: AsyncIterable<Value, any, any>

Returns

Promise<boolean>

Example

console.log(
await pipe(
asAsync([`sloth`, `more sloth`, `even more sloth`]),
allAsync(string => string.length > 8),
),
)
//=> false

Defined in

predicates.d.ts:73

allAsync(fn, asyncIterable)

allAsync<Value>(fn, asyncIterable): Promise<boolean>

Returns a promise that resolves to true if fn returns a truthy value or a promise that resolves to a truthy value for all values of asyncIterable. Otherwise returns a promise that resolves to false.

Like Array.prototype.every, but for async iterables.

Type Parameters

Value

Parameters

fn

asyncIterable: AsyncIterable<Value, any, any>

Returns

Promise<boolean>

Example

console.log(
await pipe(
asAsync([`sloth`, `more sloth`, `even more sloth`]),
allAsync(string => string.length > 8),
),
)
//=> false

Defined in

predicates.d.ts:73