1.6.16 • Published 1 year ago

parallel-promises v1.6.16

Weekly downloads
3
License
MIT
Repository
github
Last release
1 year 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.16

1 year ago

1.6.15

2 years ago

1.6.14

2 years ago

1.6.13

2 years ago

1.6.12

3 years ago

1.6.11

3 years ago

1.6.10

3 years ago

1.6.9

3 years ago

1.6.8

3 years ago

1.6.7

3 years ago

1.6.6

4 years ago

1.6.5

4 years ago

1.6.4

4 years ago

1.6.3

4 years ago

1.6.2

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.3

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago