UNPKG

snyk-nodejs-lockfile-parser

Version:
22 lines 909 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.cMap = cMap; const pMap = require("p-map"); const event_loop_spinner_1 = require("event-loop-spinner"); /** Run a function each element in an array, with some level of concurrency. * * Defaults to a small, finite concurrency, so as to not to "overload" the database * connection pool or the http client, both of which have small, internal limits. * * Can be used with async functions that don't yield; will yield for you, if necessary. */ async function cMap(input, mapper, options) { const concurrency = options?.concurrency ?? 6; return await pMap(input, async (from) => { if (event_loop_spinner_1.eventLoopSpinner.isStarving()) { await event_loop_spinner_1.eventLoopSpinner.spin(); } return await mapper(from); }, { concurrency }); } //# sourceMappingURL=c-map.js.map