concurrent_promise

Parallel processing module for JavaScript that can specify the number of concurrent executions.

이 스크립트는 직접 설치해서 쓰는 게 아닙니다. 다른 스크립트가 메타 명령 // @require https://update.greasyfork.org/scripts/398566/785036/concurrent_promise.js(으)로 포함하여 쓰는 라이브러리입니다.

질문, 리뷰하거나, 이 스크립트를 신고하세요.
개발자
風柳@furyutei
버전
0.0.1.20200327101858
생성
2020-03-24
갱신
2020-03-27
라이선스
없음

js-concurrent_promise

  • License: The MIT license
  • Copyright (c) 2020 furyu @furyutei
  • Target: Browser(Google Chrome, Firefox), Node.js

Parallel processing module for JavaScript that can specify the number of concurrent executions.

Module

Usage

let result_info = await concurrent_promise.execute(
        promise_function_array, // Array of functions that return Promise (Note: it's not Promise itself)
        max_concurrent_worker // Max concurrent Promise number (default: 10)
    );
//  result_info = {
//      promise_results : <Array of results for each Promise>,
//      success_list : <Array of successful Promise results>,
//      failure_list : <Array of failed Promise results>,
//  }

Trial

Browser

Open the test page in your browser and follow the instructions to run it.

Node.js

Install

$ cd js-concurrent_promise
$ yarn install

Examples

$ node -i
// [load modules]
const { concurrentPromise, concurrent_promise, test } = require( './test/node_test.js' );

// [run]
//   test.run( target_module, promise_number, max_concurrent_worker );

// target_module = concurrentPromise: simple version (run Promise.all with each max_concurrent_worker)
test.run( concurrentPromise, 100, 10 );

// target_module = concurrent_promise: efficiency improvement version
test.run( concurrent_promise, 100, 10 );

// [cancel]
test.cancel();

Performance Comparison of Parallel Processing

Performance Comparison of Parallel Processing in JavaScript