/modern-async

A modern JavaScript tooling library for asynchronous operations using async/await, promises and async generators

Primary LanguageJavaScriptMIT LicenseMIT

modern-async Tweet

logo

GitHub Repo stars Website Node.js CI npm Coverage Status

A modern JavaScript tooling library for asynchronous operations using async/await, promises and async generators.

This library is a modernized alternative to a lot of libraries like Async.js that were created using the legacy callback style to handle asynchronous operations. Its goal is to be as complete as any of those libraries while being built from the very beginning with async/await and promises in mind.

See the documentation.

  • Exclusively uses async/await, promises and async generators in its code, tests and documentation.
  • Has low bundle size.
  • Has 100% code coverage.
  • Bundled for ESM modules, CommonJS and UMD.
  • Works in node >= 8 and in the vast majority of browsers (very old browser compatibility can be achieved using Babel and shims).
  • Has Typescript support.

Stargazers repo roster for @nicolas-van/modern-async

This project accepts feature requests !

The goal of modern-async is to be as complete as possible. I coded everything I missed in the past while developing, yet it's difficult to know what other people would really need. So if you would like some more feature the issue tracker is available. (Read also the contribution guide).

Installation

npm install --save modern-async

Or use jsDelivr to get the UMD version. The content of the library will be available under the modernAsync global variable.

Usage

import { map, sleep } from 'modern-async'

const array = [1, 2, 3]
const result = await map(array, async (v) => {
  await sleep(10)
  return v * 2
})
console.log(result)

See the documentation for the rest.

Changelog

The changelog.

Contribution Guide

The contribution guide

License

The license.