Skip to main content

Variable: noneAsync

const noneAsync: PredicateAsync

Defined in: predicates.d.ts:322

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