Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
opt
/
alt
/
alt-nodejs11
/
root
/
lib
/
node_modules
/
npm
/
node_modules
/
p-limit
/
File Content:
index.js
'use strict'; const pTry = require('p-try'); module.exports = concurrency => { if (concurrency < 1) { throw new TypeError('Expected `concurrency` to be a number from 1 and up'); } const queue = []; let activeCount = 0; const next = () => { activeCount--; if (queue.length > 0) { queue.shift()(); } }; return fn => new Promise((resolve, reject) => { const run = () => { activeCount++; pTry(() => fn()).then( val => { resolve(val); next(); }, err => { reject(err); next(); } ); }; if (activeCount < concurrency) { run(); } else { queue.push(run); } }); };
Submit
FILE
FOLDER
Name
Size
Permission
Action
index.js
641 bytes
0644
license
1109 bytes
0644
package.json
1862 bytes
0644
readme.md
1418 bytes
0644
N4ST4R_ID | Naxtarrr