Skip to content

Commit 7c681a9

Browse files
committed
Use naturalCompare
1 parent bab406c commit 7c681a9

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

scripts/update-data-npm.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const validateNpmPackageName = require('validate-npm-package-name')
1010
const constants = require('@socketsecurity/registry/lib/constants')
1111
const { pFilter } = require('@socketsecurity/registry/lib/promises')
1212
const { confirm } = require('@socketsecurity/registry/lib/prompts')
13+
const { naturalCompare } = require('@socketsecurity/registry/lib/sorts')
1314
const { Spinner } = require('@socketsecurity/registry/lib/spinner')
1415

1516
const { abortSignal } = constants
@@ -20,11 +21,6 @@ const npmDataPath = path.join(dataPath, 'npm')
2021
const npmBuiltinNamesJsonPath = path.join(npmDataPath, 'builtin-names.json')
2122
const npmLegacyNamesJsonPath = path.join(npmDataPath, 'legacy-names.json')
2223

23-
const { compare: alphanumericComparator } = new Intl.Collator(undefined, {
24-
numeric: true,
25-
sensitivity: 'base'
26-
})
27-
2824
void (async () => {
2925
if (
3026
!(await confirm({
@@ -35,7 +31,7 @@ void (async () => {
3531
return
3632
}
3733
const spinner = new Spinner().start()
38-
const builtinNames = Module.builtinModules.toSorted(alphanumericComparator)
34+
const builtinNames = Module.builtinModules.toSorted(naturalCompare)
3935
const allThePackageNames = [
4036
...new Set([
4137
// Load the 43.1MB names.json file of '[email protected]'
@@ -53,7 +49,7 @@ void (async () => {
5349
// Instead let registry.npmjs.org be our source of truth to whether a
5450
// package exists or not.
5551
.filter(n => !validateNpmPackageName(n).validForNewPackages)
56-
.sort(alphanumericComparator)
52+
.sort(naturalCompare)
5753
const seenNames = new Set()
5854
const invalidNames = new Set()
5955
const legacyNames =

0 commit comments

Comments
 (0)