New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

await-cycle

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

await-cycle

It accepts an array for enumeration and an async function, the result of which returns a promise. Calls a function on each element of the array, further code execution will wait until all functions return resolve

latest
npmnpm
Version
1.0.6
Version published
Maintainers
1
Created
Source

The function within which the cycle is executed is called in the asynchronous block. Accepts an async function that should return a promise. Will be resolve when all transferred functions are resolved. The transferred functions are called parallel!

Install

$ yarn add await-cycle or $ npm i await-cycle

Example Usage

const awaitCycle = require("await-cycle");
const arr = ["a", "b", "c", "d"];
const delay = (item, idx) => {
  return new Promise(resolve =>
    setTimeout(() => {
      console.log(`in item ${item} - ${idx}`);
      resolve();
    }, 500)
  );
};
(async () => {
  await awaitCycle(arr, (item, idx) => delay(item, idx));
  console.log("after!");
})();

Result

  in item a - 0
  in item b - 1
  in item c - 2
  in item d - 3
  after!

Keywords

asyncCycle

FAQs

Package last updated on 05 Nov 2019

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