Function: joinAsync()
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.
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
Call Signature
joinAsync(
separator
): (asyncIterable
) =>Promise
<string
>
Parameters
separator
string
Returns
Function
Parameters
asyncIterable
AsyncIterable
<unknown
, any
, any
>
Returns
Promise
<string
>
Defined in
Call Signature
joinAsync(
separator
,asyncIterable
):Promise
<string
>
Parameters
separator
string
asyncIterable
AsyncIterable
<unknown
, any
, any
>
Returns
Promise
<string
>