Variable: joinAsync()
constjoinAsync: {(separator): (asyncIterable) =>Promise<string>; (separator,asyncIterable):Promise<string>; }
Defined in: collections.d.ts:483
Returns a promise that resolves to the string concatenation of the values of
asyncIterable, separated by separator.
Like Array.prototype.join, but for async iterables, except it does not
treat null, undefined, or [] specially.
Call Signature
(
separator): (asyncIterable) =>Promise<string>
Parameters
separator
string
Returns
(
asyncIterable):Promise<string>
Parameters
asyncIterable
AsyncIterable<unknown>
Returns
Promise<string>
Call Signature
(
separator,asyncIterable):Promise<string>
Parameters
separator
string
asyncIterable
AsyncIterable<unknown>
Returns
Promise<string>
Example
import { asAsync, joinAsync, mapAsync, pipe } from 'lfi'
const API_URL = `https://api.dictionaryapi.dev/api/v2/entries/en`
console.log(
await pipe(
asAsync([`sloth`, `lazy`, `sleep`]),
mapAsync(async word => {
const response = await fetch(`${API_URL}/${word}`)
return (await response.json())[0].phonetic
}),
joinAsync(`, `),
),
)
//=> /slɑθ/, /ˈleɪzi/, /sliːp/
Since
v0.0.1