Skip to content

Commit 8905037

Browse files
committed
1 parent ac8eb39 commit 8905037

File tree

10 files changed

+365
-350
lines changed

10 files changed

+365
-350
lines changed

lib/utils/verify-signatures.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const fetch = require('npm-registry-fetch')
22
const localeCompare = require('@isaacs/string-locale-compare')('en')
33
const npa = require('npm-package-arg')
44
const pacote = require('pacote')
5-
const pMap = require('p-map')
65
const tufClient = require('@sigstore/tuf')
76
const { log, output } = require('proc-log')
87

@@ -26,6 +25,7 @@ class VerifySignatures {
2625

2726
async run () {
2827
const start = process.hrtime.bigint()
28+
const { default: pMap } = await import('p-map')
2929

3030
// Find all deps in tree
3131
const { edges, registries } = this.getEdgesOut(this.tree.inventory.values(), this.filterSet)

node_modules/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
!/cacache/node_modules/chownr
6262
!/cacache/node_modules/minizlib
6363
!/cacache/node_modules/mkdirp
64-
!/cacache/node_modules/p-map
6564
!/cacache/node_modules/tar
6665
!/cacache/node_modules/yallist
6766
!/chalk
@@ -160,6 +159,7 @@
160159
!/node-gyp/node_modules/make-fetch-happen
161160
!/node-gyp/node_modules/minipass-fetch
162161
!/node-gyp/node_modules/nopt
162+
!/node-gyp/node_modules/p-map
163163
!/node-gyp/node_modules/proc-log
164164
!/node-gyp/node_modules/ssri
165165
!/node-gyp/node_modules/unique-filename

node_modules/cacache/node_modules/p-map/index.js

-269
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
'use strict';
2+
const AggregateError = require('aggregate-error');
3+
4+
module.exports = async (
5+
iterable,
6+
mapper,
7+
{
8+
concurrency = Infinity,
9+
stopOnError = true
10+
} = {}
11+
) => {
12+
return new Promise((resolve, reject) => {
13+
if (typeof mapper !== 'function') {
14+
throw new TypeError('Mapper function is required');
15+
}
16+
17+
if (!((Number.isSafeInteger(concurrency) || concurrency === Infinity) && concurrency >= 1)) {
18+
throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
19+
}
20+
21+
const result = [];
22+
const errors = [];
23+
const iterator = iterable[Symbol.iterator]();
24+
let isRejected = false;
25+
let isIterableDone = false;
26+
let resolvingCount = 0;
27+
let currentIndex = 0;
28+
29+
const next = () => {
30+
if (isRejected) {
31+
return;
32+
}
33+
34+
const nextItem = iterator.next();
35+
const index = currentIndex;
36+
currentIndex++;
37+
38+
if (nextItem.done) {
39+
isIterableDone = true;
40+
41+
if (resolvingCount === 0) {
42+
if (!stopOnError && errors.length !== 0) {
43+
reject(new AggregateError(errors));
44+
} else {
45+
resolve(result);
46+
}
47+
}
48+
49+
return;
50+
}
51+
52+
resolvingCount++;
53+
54+
(async () => {
55+
try {
56+
const element = await nextItem.value;
57+
result[index] = await mapper(element, index);
58+
resolvingCount--;
59+
next();
60+
} catch (error) {
61+
if (stopOnError) {
62+
isRejected = true;
63+
reject(error);
64+
} else {
65+
errors.push(error);
66+
resolvingCount--;
67+
next();
68+
}
69+
}
70+
})();
71+
};
72+
73+
for (let i = 0; i < concurrency; i++) {
74+
next();
75+
76+
if (isIterableDone) {
77+
break;
78+
}
79+
}
80+
});
81+
};

0 commit comments

Comments
 (0)