@typeberry/convert 0.9.0-59ce083 → 0.9.0-6850f84
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.js +10 -4
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -8832,9 +8832,11 @@ class SortedArray {
|
|
|
8832
8832
|
removeOne(v) {
|
|
8833
8833
|
const findIdx = this.binarySearch(v);
|
|
8834
8834
|
if (findIdx.isEqual) {
|
|
8835
|
-
// remove the element
|
|
8836
|
-
this.array.splice(findIdx.idx, 1);
|
|
8835
|
+
// remove the element and return the stored one
|
|
8836
|
+
const [removed] = this.array.splice(findIdx.idx, 1);
|
|
8837
|
+
return removed;
|
|
8837
8838
|
}
|
|
8839
|
+
return undefined;
|
|
8838
8840
|
}
|
|
8839
8841
|
has(v) {
|
|
8840
8842
|
return this.binarySearch(v).isEqual;
|
|
@@ -8989,8 +8991,12 @@ class SortedSet extends SortedArray {
|
|
|
8989
8991
|
*/
|
|
8990
8992
|
replace(v) {
|
|
8991
8993
|
const findIdx = this.binarySearch(v);
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
+
if (findIdx.isEqual) {
|
|
8995
|
+
const [displaced] = this.array.splice(findIdx.idx, 1, v);
|
|
8996
|
+
return displaced;
|
|
8997
|
+
}
|
|
8998
|
+
this.array.splice(findIdx.idx, 0, v);
|
|
8999
|
+
return undefined;
|
|
8994
9000
|
}
|
|
8995
9001
|
/** Create a new SortedSet from two sorted collections. */
|
|
8996
9002
|
static fromTwoSortedCollections(first, second) {
|