asyncMap
La fonction asyncMap() transforme chaque élément d'un générateur en appliquant une fonction de transformation asynchrone. Retourne un générateur asynchrone avec les valeurs transformées.
Exemple interactif
Syntaxe
Signature classique
typescript
function asyncMap<
const GenericInput extends unknown,
const GenericOutput extends unknown,
>(
iterator: AsyncIterable<GenericInput> | Iterable<GenericInput>,
theFunction: (arg: GenericInput, params: AsyncGeneratorMapParams) => Promise<GenericOutput>
): AsyncGenerator<GenericOutput, unknown, unknown>Signature currifiée
typescript
function asyncMap<
const GenericInput extends unknown,
const GenericOutput extends unknown,
>(
theFunction: (arg: GenericInput, params: AsyncGeneratorMapParams) => Promise<GenericOutput>
): (iterator: AsyncIterable<GenericInput> | Iterable<GenericInput>) => AsyncGenerator<GenericOutput, unknown, unknown>Paramètres
iterator: Le générateur (synchrone ou asynchrone) à transformertheFunction: Fonction asynchrone de transformation qui reçoit :arg: L'élément courantparams.index: L'index de l'élément
Valeur de retour
Un AsyncGenerator émettant les valeurs transformées.
Voir aussi
map- Version synchrone de asyncMapasyncFilter- Filtre avec une fonction asynchroneasyncReduce- Réduit avec une fonction asynchrone
