🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

array-map-async

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-map-async

Array.map with sequential processing async/await

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

Array.mapAsync

Array.map with sequential processing async/await

Installation:

Install the dependency

npm i array-map-async --save

Usage:

You need only import package and use Array like .map

import 'array-map-async';

//  sleep() demo function
const sleep = (milliseconds) => new Promise(resolve => setTimeout(() => { resolve() }, milliseconds));

(async () => {
    const results = await [1,2,3].mapAsync(async (item, index)=> {
        console.log("sleep 1s")
        await sleep(1000);  // or fetch/timer/any Promise
        console.log(item)
        return `#${item}`;
    });
    console.log(results);
})();


//  Results
//
//  sleep 1s
//  1
//
//  sleep 1s
//  2
//
//  sleep 1s
//  3
//
//  ["#1","#2","#3"]

Keywords

javascript

FAQs

Package last updated on 05 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts