Skip to content

Commit

Permalink
deps: promise-call-limit@3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Jan 23, 2024
1 parent d3f1845 commit ec77e81
Show file tree
Hide file tree
Showing 9 changed files with 212 additions and 65 deletions.
87 changes: 87 additions & 0 deletions node_modules/promise-call-limit/dist/commonjs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.callLimit = void 0;
const os = __importStar(require("node:os"));
// availableParallelism available only since node v19, for older versions use
// cpus() cpus() can return an empty list if /proc is not mounted, use 1 in
// this case
/* c8 ignore start */
const defLimit = 'availableParallelism' in os
? Math.max(1, os.availableParallelism() - 1)
: Math.max(1, os.cpus().length - 1);
const callLimit = (queue, { limit = defLimit, rejectLate } = {}) => new Promise((res, rej) => {
let active = 0;
let current = 0;
const results = [];
// Whether or not we rejected, distinct from the rejection just in case the rejection itself is falsey
let rejected = false;
let rejection;
const reject = (er) => {
if (rejected)
return;
rejected = true;
rejection ??= er;
if (!rejectLate)
rej(rejection);
};
let resolved = false;
const resolve = () => {
if (resolved || active > 0)
return;
resolved = true;
res(results);
};
const run = () => {
const c = current++;
if (c >= queue.length)
return rejected ? reject() : resolve();
active++;
const step = queue[c];
/* c8 ignore start */
if (!step)
throw new Error('walked off queue');
/* c8 ignore stop */
results[c] = step()
.then(result => {
active--;
results[c] = result;
return result;
}, er => {
active--;
reject(er);
})
.then(result => {
if (rejected && active === 0)
return rej(rejection);
run();
return result;
});
};
for (let i = 0; i < limit; i++)
run();
});
exports.callLimit = callLimit;
//# sourceMappingURL=index.js.map
3 changes: 3 additions & 0 deletions node_modules/promise-call-limit/dist/commonjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
60 changes: 60 additions & 0 deletions node_modules/promise-call-limit/dist/esm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import * as os from 'node:os';
// availableParallelism available only since node v19, for older versions use
// cpus() cpus() can return an empty list if /proc is not mounted, use 1 in
// this case
/* c8 ignore start */
const defLimit = 'availableParallelism' in os
? Math.max(1, os.availableParallelism() - 1)
: Math.max(1, os.cpus().length - 1);
export const callLimit = (queue, { limit = defLimit, rejectLate } = {}) => new Promise((res, rej) => {
let active = 0;
let current = 0;
const results = [];
// Whether or not we rejected, distinct from the rejection just in case the rejection itself is falsey
let rejected = false;
let rejection;
const reject = (er) => {
if (rejected)
return;
rejected = true;
rejection ??= er;
if (!rejectLate)
rej(rejection);
};
let resolved = false;
const resolve = () => {
if (resolved || active > 0)
return;
resolved = true;
res(results);
};
const run = () => {
const c = current++;
if (c >= queue.length)
return rejected ? reject() : resolve();
active++;
const step = queue[c];
/* c8 ignore start */
if (!step)
throw new Error('walked off queue');
/* c8 ignore stop */
results[c] = step()
.then(result => {
active--;
results[c] = result;
return result;
}, er => {
active--;
reject(er);
})
.then(result => {
if (rejected && active === 0)
return rej(rejection);
run();
return result;
});
};
for (let i = 0; i < limit; i++)
run();
});
//# sourceMappingURL=index.js.map
3 changes: 3 additions & 0 deletions node_modules/promise-call-limit/dist/esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
52 changes: 0 additions & 52 deletions node_modules/promise-call-limit/index.js

This file was deleted.

51 changes: 44 additions & 7 deletions node_modules/promise-call-limit/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "promise-call-limit",
"version": "1.0.2",
"version": "3.0.1",
"files": [
"index.js"
"dist"
],
"description": "Call an array of promise-returning functions, restricting concurrency to a specified limit.",
"repository": {
Expand All @@ -12,18 +12,55 @@
"author": "Isaac Z. Schlueter <i@izs.me> (https://izs.me)",
"license": "ISC",
"scripts": {
"prepare": "tshy",
"pretest": "npm run prepare",
"snap": "tap",
"test": "tap",
"preversion": "npm test",
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags"
},
"tap": {
"check-coverage": true
},
"devDependencies": {
"tap": "^16.0.0"
"prettier": "^3.2.1",
"tap": "^18.6.1",
"tshy": "^1.8.2",
"format": "prettier --write . --loglevel warn --ignore-path ../../.prettierignore --cache",
"typedoc": "typedoc"
},
"prettier": {
"semi": false,
"printWidth": 70,
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"jsxSingleQuote": false,
"bracketSameLine": true,
"arrowParens": "avoid",
"endOfLine": "lf"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
}
},
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
},
"main": "./dist/commonjs/index.js",
"types": "./dist/commonjs/index.d.ts",
"type": "module"
}
17 changes: 13 additions & 4 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -8249,6 +8249,15 @@
"node": ">=8"
}
},
"node_modules/licensee/node_modules/promise-call-limit": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/promise-call-limit/-/promise-call-limit-1.0.2.tgz",
"integrity": "sha512-1vTUnfI2hzui8AEIixbdAJlFY4LFDXqQswy/2eOlThAscXCY4It8FdVuI0fMJGAB2aWGbdQf/gv0skKYXmdrHA==",
"dev": true,
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/licensee/node_modules/read-package-json": {
"version": "6.0.4",
"resolved": "https://registry.npmjs.org/read-package-json/-/read-package-json-6.0.4.tgz",
Expand Down Expand Up @@ -10940,9 +10949,9 @@
}
},
"node_modules/promise-call-limit": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/promise-call-limit/-/promise-call-limit-1.0.2.tgz",
"integrity": "sha512-1vTUnfI2hzui8AEIixbdAJlFY4LFDXqQswy/2eOlThAscXCY4It8FdVuI0fMJGAB2aWGbdQf/gv0skKYXmdrHA==",
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/promise-call-limit/-/promise-call-limit-3.0.1.tgz",
"integrity": "sha512-utl+0x8gIDasV5X+PI5qWEPqH6fJS0pFtQ/4gZ95xfEFb/89dmh+/b895TbFDBLiafBvxD/PGTKfvxl4kH/pQg==",
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
Expand Down Expand Up @@ -16045,7 +16054,7 @@
"parse-conflict-json": "^3.0.0",
"proc-log": "^3.0.0",
"promise-all-reject-late": "^1.0.0",
"promise-call-limit": "^1.0.2",
"promise-call-limit": "^3.0.1",
"read-package-json-fast": "^3.0.2",
"semver": "^7.3.7",
"ssri": "^10.0.5",
Expand Down
2 changes: 1 addition & 1 deletion workspaces/arborist/lib/arborist/rebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ module.exports = cls => class Builder extends cls {
: p)

process.emit('timeEnd', timer)
}), limit)
}), { limit })
process.emit('timeEnd', `build:run:${event}`)
}

Expand Down
2 changes: 1 addition & 1 deletion workspaces/arborist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"parse-conflict-json": "^3.0.0",
"proc-log": "^3.0.0",
"promise-all-reject-late": "^1.0.0",
"promise-call-limit": "^1.0.2",
"promise-call-limit": "^3.0.1",
"read-package-json-fast": "^3.0.2",
"semver": "^7.3.7",
"ssri": "^10.0.5",
Expand Down

0 comments on commit ec77e81

Please sign in to comment.