Skip to content

Commit

Permalink
refactor: remove zipWith when resolving dependencies of importers (pn…
Browse files Browse the repository at this point in the history
…pm#7927)

* refactor: avoid zipWith when resolving dependencies of importers

Instead of creating two separate arrays and zipping them together, the
initial map here can create the pairs array directly.

I'm not expecting any behavior changes in this commit other than
slightly improved readability and performance.

* refactor: resolve dependencies

---------

Co-authored-by: Zoltan Kochan <[email protected]>
  • Loading branch information
gluxon and zkochan authored Apr 15, 2024
1 parent 73b241d commit db7aee8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pkg-manager/resolve-dependencies/src/resolveDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,16 +403,16 @@ async function resolveDependenciesOfImporters (
ctx: ResolutionContext,
importers: ImporterToResolve[]
): Promise<ResolveDependenciesOfImportersResult> {
const extendedWantedDepsByImporters = importers.map(({ wantedDependencies, options }) => getDepsToResolve(wantedDependencies, ctx.wantedLockfile, {
preferredDependencies: options.preferredDependencies,
prefix: options.prefix,
proceed: options.proceed || ctx.forceFullResolution,
registries: ctx.registries,
resolvedDependencies: options.resolvedDependencies,
}))
const pickLowestVersion = ctx.resolutionMode === 'time-based' || ctx.resolutionMode === 'lowest-direct'
const resolveResults = await Promise.all(
zipWith(async (extendedWantedDeps, importer) => {
importers.map(async (importer) => {
const extendedWantedDeps = getDepsToResolve(importer.wantedDependencies, ctx.wantedLockfile, {
preferredDependencies: importer.options.preferredDependencies,
prefix: importer.options.prefix,
proceed: importer.options.proceed || ctx.forceFullResolution,
registries: ctx.registries,
resolvedDependencies: importer.options.resolvedDependencies,
})
const postponedResolutionsQueue: PostponedResolutionFunction[] = []
const postponedPeersResolutionQueue: PostponedPeersResolutionFunction[] = []
const pkgAddresses: PkgAddress[] = []
Expand Down Expand Up @@ -443,7 +443,7 @@ async function resolveDependenciesOfImporters (
}

return { pkgAddresses, postponedResolutionsQueue, postponedPeersResolutionQueue }
}, extendedWantedDepsByImporters, importers)
})
)
let publishedBy: Date | undefined
let time: Record<string, string> | undefined
Expand Down

0 comments on commit db7aee8

Please sign in to comment.