directed-graph-typed 2.2.5 → 2.2.7
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/dist/cjs/index.cjs +8 -34
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs-legacy/index.cjs +8 -34
- package/dist/cjs-legacy/index.cjs.map +1 -1
- package/dist/esm/index.mjs +8 -34
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm-legacy/index.mjs +8 -34
- package/dist/esm-legacy/index.mjs.map +1 -1
- package/dist/types/data-structures/base/iterable-entry-base.d.ts +6 -0
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +14 -57
- package/dist/types/data-structures/binary-tree/bst.d.ts +46 -126
- package/dist/umd/directed-graph-typed.js +8 -31
- package/dist/umd/directed-graph-typed.js.map +1 -1
- package/dist/umd/directed-graph-typed.min.js +1 -1
- package/dist/umd/directed-graph-typed.min.js.map +1 -1
- package/package.json +2 -2
- package/src/common/index.ts +2 -4
- package/src/data-structures/base/iterable-entry-base.ts +9 -0
- package/src/data-structures/binary-tree/binary-tree.ts +67 -0
- package/src/data-structures/binary-tree/bst.ts +295 -89
|
@@ -25,38 +25,6 @@ var arrayRemove = /* @__PURE__ */ __name(function(array, predicate) {
|
|
|
25
25
|
}
|
|
26
26
|
return result;
|
|
27
27
|
}, "arrayRemove");
|
|
28
|
-
function isPrimitiveComparable(value) {
|
|
29
|
-
const valueType = typeof value;
|
|
30
|
-
if (valueType === "number") return true;
|
|
31
|
-
return valueType === "bigint" || valueType === "string" || valueType === "boolean";
|
|
32
|
-
}
|
|
33
|
-
__name(isPrimitiveComparable, "isPrimitiveComparable");
|
|
34
|
-
function tryObjectToPrimitive(obj) {
|
|
35
|
-
if (typeof obj.valueOf === "function") {
|
|
36
|
-
const valueOfResult = obj.valueOf();
|
|
37
|
-
if (valueOfResult !== obj) {
|
|
38
|
-
if (isPrimitiveComparable(valueOfResult)) return valueOfResult;
|
|
39
|
-
if (typeof valueOfResult === "object" && valueOfResult !== null) return tryObjectToPrimitive(valueOfResult);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (typeof obj.toString === "function") {
|
|
43
|
-
const stringResult = obj.toString();
|
|
44
|
-
if (stringResult !== "[object Object]") return stringResult;
|
|
45
|
-
}
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
__name(tryObjectToPrimitive, "tryObjectToPrimitive");
|
|
49
|
-
function isComparable(value, isForceObjectComparable = false) {
|
|
50
|
-
if (value === null || value === void 0) return false;
|
|
51
|
-
if (isPrimitiveComparable(value)) return true;
|
|
52
|
-
if (typeof value !== "object") return false;
|
|
53
|
-
if (value instanceof Date) return true;
|
|
54
|
-
if (isForceObjectComparable) return true;
|
|
55
|
-
const comparableValue = tryObjectToPrimitive(value);
|
|
56
|
-
if (comparableValue === null || comparableValue === void 0) return false;
|
|
57
|
-
return isPrimitiveComparable(comparableValue);
|
|
58
|
-
}
|
|
59
|
-
__name(isComparable, "isComparable");
|
|
60
28
|
|
|
61
29
|
// src/data-structures/base/iterable-entry-base.ts
|
|
62
30
|
var _IterableEntryBase = class _IterableEntryBase {
|
|
@@ -212,6 +180,14 @@ var _IterableEntryBase = class _IterableEntryBase {
|
|
|
212
180
|
}
|
|
213
181
|
return accumulator;
|
|
214
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Converts data structure to `[key, value]` pairs.
|
|
185
|
+
* @returns Array of entries.
|
|
186
|
+
* @remarks Time O(n), Space O(n)
|
|
187
|
+
*/
|
|
188
|
+
toArray() {
|
|
189
|
+
return [...this];
|
|
190
|
+
}
|
|
215
191
|
/**
|
|
216
192
|
* Visualize the iterable as an array of `[key, value]` pairs (or a custom string).
|
|
217
193
|
* @returns Array of entries (default) or a string.
|
|
@@ -2766,8 +2742,6 @@ var _Range = class _Range {
|
|
|
2766
2742
|
this.high = high;
|
|
2767
2743
|
this.includeLow = includeLow;
|
|
2768
2744
|
this.includeHigh = includeHigh;
|
|
2769
|
-
if (!(isComparable(low) && isComparable(high))) throw new RangeError("low or high is not comparable");
|
|
2770
|
-
if (low > high) throw new RangeError("low must be less than or equal to high");
|
|
2771
2745
|
}
|
|
2772
2746
|
// Determine whether a key is within the range
|
|
2773
2747
|
isInRange(key, comparator) {
|