1.6.15 • Published 6 months ago

parallel-promises v1.6.15

Weekly downloads
3
License
MIT
Repository
github
Last release
6 months ago

ParallelPromises

Actions Status Coverage Status npm version npm.io License: MIT

ParallelPromises is an NPM package implemented in Typescript for executing a set of Promises with a given concurrency limit.

This project is inspired by https://itnext.io/node-js-handling-asynchronous-operations-in-parallel-69679dfae3fc

Table of Contents

Installation

Install it on your project

npm install --save parallel-promises

Usage

Usage with Typescript

import { customPromiseAll } from 'parallel-promises';

...

const concurrentLimit: number = 5;

const listOfPromises: ICustomPromise[] = [
      {
        name: 'GetSomething',
        function: this.operationWrapper.getSomethingFunction,
        thisArg: this.operationWrapper,
        args: ["firstParamForFunction",{ data: "Another param"}, ["more params..."]]
      },
      {
        name: 'CreateSomething',
        function: this.createSomething,
        thisArg: undefined,
        args: ["firstParamForFunction"]
      },
      {
        name: 'RefreshSomething',
        function: this.updateSomething,
      },
      ...
      ]

      customPromiseAll(listOfPromises, concurrentLimit).then((result: IAnyObject)=>{
          console.log(result);
          //{ GetSomething: { Response: ... }, CreateSomething: "{ Id: 8 }", RefreshSomething: "OK" , ...}
          ...
          // do whatever you want
      });

Usage with Javascript

const ParallelPromises = require('parallel-promises');

...

const concurrentLimit = 5;

const listOfPromises = [
      {
        name: 'GetSomething',
        function: this.operationWrapper.getSomethingFunction,
        thisArg: this.operationWrapper,
        args: ["firstParamForFunction",{ data: "Another param"}, ["more params..."]]
      },
      {
        name: 'CreateSomething',
        function: this.createSomething,
        thisArg: undefined,
        args: ["firstParamForFunction"]
      },
      {
        name: 'RefreshSomething',
        function: this.updateSomething,
      },
      ...
      ]

      ParallelPromises.customPromiseAll(listOfPromises, concurrentLimit).then((result)=>{
          console.log(result);
          //{ GetSomething: { Response: ... }, CreateSomething: "{ Id: 8 }", RefreshSomething: "OK" , ...}
          ...
          // do whatever you want
      });

Contributing

There is no plan regarding contributions in this project

Credits

This NPM package has been developed by:

Rafael Pernil Bronchalo - Developer

License

This project is licensed under the MIT License - see the LICENSE.md file for details

1.6.15

6 months ago

1.6.14

10 months ago

1.6.13

1 year ago

1.6.12

1 year ago

1.6.11

2 years ago

1.6.10

2 years ago

1.6.9

2 years ago

1.6.8

2 years ago

1.6.7

2 years ago

1.6.6

3 years ago

1.6.5

3 years ago

1.6.4

3 years ago

1.6.3

3 years ago

1.6.2

4 years ago

1.6.1

4 years ago

1.6.0

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago