nav tabs on admin dashboard
This commit is contained in:
44
node_modules/p-limit/index.js
generated
vendored
44
node_modules/p-limit/index.js
generated
vendored
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
const pTry = require('p-try');
|
||||
|
||||
module.exports = concurrency => {
|
||||
const pLimit = concurrency => {
|
||||
if (concurrency < 1) {
|
||||
throw new TypeError('Expected `concurrency` to be a number from 1 and up');
|
||||
}
|
||||
@@ -17,26 +17,36 @@ module.exports = concurrency => {
|
||||
}
|
||||
};
|
||||
|
||||
return fn => new Promise((resolve, reject) => {
|
||||
const run = () => {
|
||||
activeCount++;
|
||||
const run = (fn, resolve, ...args) => {
|
||||
activeCount++;
|
||||
|
||||
pTry(fn).then(
|
||||
val => {
|
||||
resolve(val);
|
||||
next();
|
||||
},
|
||||
err => {
|
||||
reject(err);
|
||||
next();
|
||||
}
|
||||
);
|
||||
};
|
||||
const result = pTry(fn, ...args);
|
||||
|
||||
resolve(result);
|
||||
|
||||
result.then(next, next);
|
||||
};
|
||||
|
||||
const enqueue = (fn, resolve, ...args) => {
|
||||
if (activeCount < concurrency) {
|
||||
run();
|
||||
run(fn, resolve, ...args);
|
||||
} else {
|
||||
queue.push(run);
|
||||
queue.push(run.bind(null, fn, resolve, ...args));
|
||||
}
|
||||
};
|
||||
|
||||
const generator = (fn, ...args) => new Promise(resolve => enqueue(fn, resolve, ...args));
|
||||
Object.defineProperties(generator, {
|
||||
activeCount: {
|
||||
get: () => activeCount
|
||||
},
|
||||
pendingCount: {
|
||||
get: () => queue.length
|
||||
}
|
||||
});
|
||||
|
||||
return generator;
|
||||
};
|
||||
|
||||
module.exports = pLimit;
|
||||
module.exports.default = pLimit;
|
||||
|
||||
Reference in New Issue
Block a user