Skip to content

Commit

Permalink
deps: p-map@7.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Dec 6, 2024
1 parent ac8eb39 commit 8905037
Show file tree
Hide file tree
Showing 10 changed files with 365 additions and 350 deletions.
2 changes: 1 addition & 1 deletion lib/utils/verify-signatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const fetch = require('npm-registry-fetch')
const localeCompare = require('@isaacs/string-locale-compare')('en')
const npa = require('npm-package-arg')
const pacote = require('pacote')
const pMap = require('p-map')
const tufClient = require('@sigstore/tuf')
const { log, output } = require('proc-log')

Expand All @@ -26,6 +25,7 @@ class VerifySignatures {

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

// Find all deps in tree
const { edges, registries } = this.getEdgesOut(this.tree.inventory.values(), this.filterSet)
Expand Down
2 changes: 1 addition & 1 deletion node_modules/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
!/cacache/node_modules/chownr
!/cacache/node_modules/minizlib
!/cacache/node_modules/mkdirp
!/cacache/node_modules/p-map
!/cacache/node_modules/tar
!/cacache/node_modules/yallist
!/chalk
Expand Down Expand Up @@ -160,6 +159,7 @@
!/node-gyp/node_modules/make-fetch-happen
!/node-gyp/node_modules/minipass-fetch
!/node-gyp/node_modules/nopt
!/node-gyp/node_modules/p-map
!/node-gyp/node_modules/proc-log
!/node-gyp/node_modules/ssri
!/node-gyp/node_modules/unique-filename
Expand Down
269 changes: 0 additions & 269 deletions node_modules/cacache/node_modules/p-map/index.js

This file was deleted.

81 changes: 81 additions & 0 deletions node_modules/node-gyp/node_modules/p-map/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
'use strict';
const AggregateError = require('aggregate-error');

module.exports = async (
iterable,
mapper,
{
concurrency = Infinity,
stopOnError = true
} = {}
) => {
return new Promise((resolve, reject) => {
if (typeof mapper !== 'function') {
throw new TypeError('Mapper function is required');
}

if (!((Number.isSafeInteger(concurrency) || concurrency === Infinity) && concurrency >= 1)) {
throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${concurrency}\` (${typeof concurrency})`);
}

const result = [];
const errors = [];
const iterator = iterable[Symbol.iterator]();
let isRejected = false;
let isIterableDone = false;
let resolvingCount = 0;
let currentIndex = 0;

const next = () => {
if (isRejected) {
return;
}

const nextItem = iterator.next();
const index = currentIndex;
currentIndex++;

if (nextItem.done) {
isIterableDone = true;

if (resolvingCount === 0) {
if (!stopOnError && errors.length !== 0) {
reject(new AggregateError(errors));
} else {
resolve(result);
}
}

return;
}

resolvingCount++;

(async () => {
try {
const element = await nextItem.value;
result[index] = await mapper(element, index);
resolvingCount--;
next();
} catch (error) {
if (stopOnError) {
isRejected = true;
reject(error);
} else {
errors.push(error);
resolvingCount--;
next();
}
}
})();
};

for (let i = 0; i < concurrency; i++) {
next();

if (isIterableDone) {
break;
}
}
});
};
Loading

0 comments on commit 8905037

Please sign in to comment.