Skip to content

Commit

Permalink
perf: simplify!
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Aug 5, 2022
1 parent 75938e8 commit 1be0b12
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function readPackageJson (
export function resolveAliases (_aliases: Record<string, string>) {
// Sort aliases from specific to general (ie. fs/promises before fs)
const aliases = Object.fromEntries(Object.entries(_aliases).sort(([a], [b]) =>
scoreAlias(b) - scoreAlias(a)
(b.split('/').length - a.split('/').length) || (b.length - a.length)
))
// Resolve alias values in relation to each other
for (const key in aliases) {
Expand All @@ -150,8 +150,3 @@ export function resolveAliases (_aliases: Record<string, string>) {
}
return aliases
}

const scoreAlias = (alias: string) => {
const segments = alias.split('/')
return segments.length + (segments[segments.length - 1].length / 1000)
}

0 comments on commit 1be0b12

Please sign in to comment.