source: node_modules/es-toolkit/dist/array/limitAsync.js

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 513 bytes
Line 
1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5const semaphore = require('../promise/semaphore.js');
6
7function limitAsync(callback, concurrency) {
8 const semaphore$1 = new semaphore.Semaphore(concurrency);
9 return async function (...args) {
10 try {
11 await semaphore$1.acquire();
12 return await callback.apply(this, args);
13 }
14 finally {
15 semaphore$1.release();
16 }
17 };
18}
19
20exports.limitAsync = limitAsync;
Note: See TracBrowser for help on using the repository browser.