ArrayAsync
mapAsync
Section titled “mapAsync”let mapAsync: (array<'a>, ('a, int) => promise<'b>) => promise<array<'b>>
mapAsync
is a function that applies an asynchronous function to each element of an array, collecting the results in a new array.
@param arr - The input array.
@param fn - An asynchronous function that takes an element and its index as parameters and returns a promise.
@return A promise that resolves to a new array containing the results of applying fn
to each element of arr
.
src/ArrayAsync.res:8:5
forEachAsync
Section titled “forEachAsync”let forEachAsync: (array<'a>, ('a, int) => promise<unit>) => promise<unit>
forEachAsync
is a function that applies an asynchronous function to each element of an array, discarding the results.
@param arr - The input array.
@param fn - An asynchronous function that takes an element and its index as parameters and returns a promise.
@return A promise that resolves when all the promises returned by fn
have been fulfilled.
src/ArrayAsync.res:24:5
filterAsync
Section titled “filterAsync”let filterAsync: ( array<'a>, ('a, int) => promise<bool>,) => promise<array<'a>>
filterAsync
is a function that applies an asynchronous function to each element of an array, collecting the elements for which the promise returned by fn
resolves to true
.
@param arr - The input array.
@param fn - An asynchronous function that takes an element and its index as parameters and returns a promise.
@return A promise that resolves to a new array containing the elements of arr
for which the promise returned by fn
resolves to true
.
src/ArrayAsync.res:37:5
findAsync
Section titled “findAsync”let findAsync: ( array<'a>, ('a, int) => promise<bool>,) => promise<option<'a>>
findAsync
is a function that applies an asynchronous function to each element of an array, returning the first element for which the promise returned by fn
resolves to true
.
@param arr - The input array.
@param fn - An asynchronous function that takes an element and its index as parameters and returns a promise.
@return A promise that resolves to Some(element)
if the promise returned by fn
resolves to true
for any element, or None
if no such element is found.
src/ArrayAsync.res:60:5