PHP 8.2.30
Preview: index.js Size: 641 B
/opt/alt/alt-nodejs8/root/lib/node_modules/npm/node_modules/p-limit/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);
		}
	});
};

Directory Contents

Dirs: 0 × Files: 4

Name Size Perms Modified Actions
641 B lrw-r--r-- 2021-09-28 10:29:14
Edit Download
1.08 KB lrw-r--r-- 2021-09-28 10:29:14
Edit Download
1.82 KB lrw-r--r-- 2021-09-28 10:29:14
Edit Download
1.38 KB lrw-r--r-- 2021-09-28 10:29:14
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).