Home

Awesome

<p align="center"> <img alt="aigle" src="https://raw.githubusercontent.com/suguru03/aigle/gh-pages/images/logo.png" width=500 /> </p> <p align="center"> <a href="https://www.npmjs.com/package/aigle"><img alt="npm" src="https://img.shields.io/npm/v/aigle.svg" /></a> <a href="https://circleci.com/gh/suguru03/aigle/tree/master"><img alt="CircleCI Status" src="https://img.shields.io/circleci/project/github/suguru03/aigle/master.svg" /></a> <a href="https://codecov.io/gh/suguru03/aigle"><img alt="Coverage Status" src="https://img.shields.io/codecov/c/github/suguru03/aigle/master.svg" /></a> </p>

Aigle is an ideal promise library which is faster and more efficient than other libraries. On top of being an impressive benchmark exercise, it is a production-ready library that implements the Promise A+ standard.

Also it has a lot of async style functions, you can start using Promise easily.

Usage

Node.js

npm install --save aigle
const Aigle = require('aigle');
const each = require('aigle/each');

TypeScript

import Aigle from 'aigle';
import { Aigle } from 'aigle';

Async/Await

global.Promise = Aigle;
async function getUsers(ids) {
  const users = await Promise.map(ids, getUser);
  const targets = await Promise.filter(users, filterUser);
  return targets;
}

async function getUsers(ids) {
  return await Promise.map(ids, getUser).filter(filterUser);
}

Convert synchronous functions to asynchronous functions

Aigle.mixin(require('lodash'));

return Aigle.map([1.1, 1.4, 2.2], (n) => Aigle.delay(10, n * 2)) // [2.2, 2.8, 4.4]
  .uniqBy((n) => Aigle.delay(10, Math.floor(n))) // [2.2, 4.4]
  .sum() // 6.6
  .times() // [0, 1, 2, 3, 4, 5];
  .then((value) => console.log(value)); // [0, 1, 2, 3, 4, 5];

browser

Recommend to use webpack, browserify, Rollup or any bundling tool.

or prebuilt scripts from here.

This will expose to global as window.Promise.

<script src="dist/aigle.min.js"></script>
window.Promise;

Functions

Core

prototype functions

class functions

Collections

prototype functions

class functions

Control flow

prototype functions

class functions

Utils

prototype functions

class functions

Debug

class functions