bare-module-traverse 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +2 -2
- package/index.js +17 -13
- package/package.json +1 -1
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -580,24 +580,28 @@ exports.patternMatches = function* patternMatches(pattern, parentURL, matches, o
|
|
|
580
580
|
return matches
|
|
581
581
|
}
|
|
582
582
|
|
|
583
|
-
function addURL(
|
|
584
|
-
|
|
585
|
-
|
|
583
|
+
function addURL(collection, url) {
|
|
584
|
+
if (Array.isArray(collection)) {
|
|
585
|
+
let lo = 0
|
|
586
|
+
let hi = collection.length - 1
|
|
586
587
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
588
|
+
while (lo <= hi) {
|
|
589
|
+
const mid = lo + ((hi - lo) >> 1)
|
|
590
|
+
const found = collection[mid]
|
|
590
591
|
|
|
591
|
-
|
|
592
|
+
if (found.href === url.href) return
|
|
592
593
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
594
|
+
if (found.href < url.href) {
|
|
595
|
+
lo = mid + 1
|
|
596
|
+
} else {
|
|
597
|
+
hi = mid - 1
|
|
598
|
+
}
|
|
597
599
|
}
|
|
598
|
-
}
|
|
599
600
|
|
|
600
|
-
|
|
601
|
+
collection.splice(lo, 0, url)
|
|
602
|
+
} else {
|
|
603
|
+
collection.add(url.href)
|
|
604
|
+
}
|
|
601
605
|
}
|
|
602
606
|
|
|
603
607
|
function removeURL(array, url) {
|