@rushstack/node-core-library
Advanced tools
Comparing version 3.53.1 to 3.53.2
@@ -82,5 +82,10 @@ "use strict"; | ||
comparer = Sort.compareByValue) { | ||
let isFirst = true; | ||
let previous = undefined; | ||
for (const element of collection) { | ||
if (comparer(previous, element) > 0) { | ||
if (isFirst) { | ||
// Don't start by comparing against undefined. | ||
isFirst = false; | ||
} | ||
else if (comparer(previous, element) > 0) { | ||
return false; | ||
@@ -107,6 +112,11 @@ } | ||
comparer = Sort.compareByValue) { | ||
let isFirst = true; | ||
let previousKey = undefined; | ||
for (const element of collection) { | ||
const key = keySelector(element); | ||
if (comparer(previousKey, key) > 0) { | ||
if (isFirst) { | ||
// Don't start by comparing against undefined. | ||
isFirst = false; | ||
} | ||
else if (comparer(previousKey, key) > 0) { | ||
return false; | ||
@@ -135,7 +145,7 @@ } | ||
static sortMapKeys(map, keyComparer = Sort.compareByValue) { | ||
const pairs = Array.from(map.entries()); | ||
// Sorting a map is expensive, so first check whether it's already sorted. | ||
if (Sort.isSortedBy(pairs, (x) => x[0], keyComparer)) { | ||
if (Sort.isSorted(map.keys(), keyComparer)) { | ||
return; | ||
} | ||
const pairs = Array.from(map.entries()); | ||
Sort.sortBy(pairs, (x) => x[0], keyComparer); | ||
@@ -142,0 +152,0 @@ map.clear(); |
{ | ||
"name": "@rushstack/node-core-library", | ||
"version": "3.53.1", | ||
"version": "3.53.2", | ||
"description": "Core libraries that every NodeJS toolchain project should use", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1034431
13597