We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 977f48e commit 2eabb36Copy full SHA for 2eabb36
src/strings.js
@@ -5,7 +5,14 @@
5
// > When comparing large numbers of strings, such as in sorting large arrays,
6
// > it is better to create an Intl.Collator object and use the function provided
7
// > by its compare() method.
8
-const { compare: localeCompare } = new Intl.Collator()
+let _localeCompare
9
+function localeCompare(x, y) {
10
+ if (_localeCompare === undefined) {
11
+ // Lazily call new Intl.Collator() because in Node it can take 10-14ms.
12
+ _localeCompare = new Intl.Collator().compare
13
+ }
14
+ return _localeCompare(x, y)
15
+}
16
17
// This regexp is valid as of 2024-08-01.
18
// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
0 commit comments