Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "array/async-map"

Index

Functions

Functions

asyncMap

  • asyncMap<T, U>(array: T[], mapper: function): Promise<U[]>
  • Maps an array asynchronously


    Example:

    import { asyncMap } "@thalesrc/js-utils/array";
    
    const array = [1, 2, 3];
    
    asyncMap(array, async value => {
     return await addOneAfterASecond(value);
    }).then(result => {
     console.log(result); // [2, 3, 4]
    });

    Example as Array Prototype:

    import "@thalesrc/js-utils/array/proto/async-map";
    
    const array = [1, 2, 3];
    
    const result = await array.asyncMap(async value => await addOneAfterASecond(value));
    // [2, 3, 4]

    Type parameters

    • T

    • U

    Parameters

    • array: T[]

      Array to map

    • mapper: function

      Callback async function to map the array

        • (value: T, index: number, array: T[]): Promise<U>
        • Parameters

          • value: T
          • index: number
          • array: T[]

          Returns Promise<U>

    Returns Promise<U[]>

    A promise contains asynchronusly mapped array result

Generated using TypeDoc