Skip to main content

Function: noneAsync()

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

Example

import { noneAsync, asAsync, pipe } from 'lfi'

const API_URL = `https://api.dictionaryapi.dev/api/v2/entries/en`
const getPartsOfSpeech = async word => {
const response = await fetch(`${API_URL}/${word}`)
const [{ meanings }] = await response.json()
return meanings.map(meaning => meaning.partOfSpeech)
}

console.log(
await pipe(
asAsync([`sloth`, `lazy`, `sleep`]),
noneAsync(async word => (await getPartsOfSpeech(word)).includes(`noun`)),
),
)
//=> false

console.log(
await pipe(
asAsync([`sloth`, `lazy`, `sleep`]),
noneAsync(async word => (await getPartsOfSpeech(word)).includes(`adverb`)),
),
)
//=> true
Playground

Since

v0.0.1

Call Signature

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

Type Parameters

Value

Parameters

fn

(value) => unknown

Returns

Function

Parameters

asyncIterable

AsyncIterable<Value, any, any>

Returns

Promise<boolean>

Defined in

predicates.d.ts:322

Call Signature

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

Type Parameters

Value

Parameters

fn

(value) => unknown

asyncIterable

AsyncIterable<Value, any, any>

Returns

Promise<boolean>

Defined in

predicates.d.ts:322