Git Product home page Git Product logo

futurist's Introduction

Futurist

Build Status

Futurist helps executing promises with limited parallelism.

Install

# If you are using npm
npm install futurist

# If you are using yarn
yarn add futurist

Usage

const Futurist = require('futurist');

const futurist = new Futurist(2, 10000);

futurist.execute(() => fetch('http://example.com'))
    .then(console.log)
    .catch(console.error);

API

new Futurist(maxPendingPromises, timeout)

Create a new Futurist instance to execute promises.

Parameters

  1. maxPendingPromises: Number: Optional. Number of maximum parallel pending promises at any time (default: 5).
  2. timeout: Number: Optional. Timeout in ms before a request is rejected (default: 30000). The timeout at the time of promise execution, not when adding a promise.

Returns

The Futurist instance

futurist.execute(promiseCreator)

Add a new promise creator to be executed as soon as possible.

Parameters

  1. promiseCreator: Function: A function that returns the Promise to be executed.

Returns

A Promise that is resolved/rejected when the Promise returned by promiseCreator is resolved/rejected or rejected when resolution takes longer than the defined timeout.

futurist's People

Contributors

bfncs avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.