Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

asyncro

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asyncro

Asynchronous Array Utilities (for await)

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
154K
decreased by-23.91%
Maintainers
1
Weekly downloads
 
Created

What is asyncro?

The asyncro npm package provides utilities for working with asynchronous code in JavaScript, making it easier to manage and control asynchronous operations. It offers a variety of functions to handle promises and async/await patterns more effectively.

What are asyncro's main functionalities?

map

The `map` function allows you to apply an asynchronous function to each item in an array and returns a promise that resolves when all the operations are complete. This is useful for performing parallel asynchronous operations on array elements.

const asyncro = require('asyncro');

async function example() {
  const numbers = [1, 2, 3, 4, 5];
  const results = await asyncro.map(numbers, async (num) => {
    return num * 2;
  });
  console.log(results); // [2, 4, 6, 8, 10]
}
example();

series

The `series` function executes an array of asynchronous functions in series, meaning one after the other. It returns a promise that resolves with an array of results once all functions have completed. This is useful for tasks that need to be performed sequentially.

const asyncro = require('asyncro');

async function example() {
  const tasks = [
    async () => { return 1; },
    async () => { return 2; },
    async () => { return 3; }
  ];
  const results = await asyncro.series(tasks);
  console.log(results); // [1, 2, 3]
}
example();

parallel

The `parallel` function executes an array of asynchronous functions in parallel, meaning all at the same time. It returns a promise that resolves with an array of results once all functions have completed. This is useful for tasks that can be performed concurrently.

const asyncro = require('asyncro');

async function example() {
  const tasks = [
    async () => { return 1; },
    async () => { return 2; },
    async () => { return 3; }
  ];
  const results = await asyncro.parallel(tasks);
  console.log(results); // [1, 2, 3]
}
example();

Other packages similar to asyncro

Keywords

FAQs

Package last updated on 22 Jan 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc