graph-typed 2.2.5 → 2.2.6
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/graph-typed.js +8 -31
- package/dist/umd/graph-typed.js.map +1 -1
- package/dist/umd/graph-typed.min.js +1 -1
- package/dist/umd/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
package/dist/cjs/index.cjs
CHANGED
|
@@ -23,38 +23,6 @@ var arrayRemove = /* @__PURE__ */ __name(function(array, predicate) {
|
|
|
23
23
|
}
|
|
24
24
|
return result;
|
|
25
25
|
}, "arrayRemove");
|
|
26
|
-
function isPrimitiveComparable(value) {
|
|
27
|
-
const valueType = typeof value;
|
|
28
|
-
if (valueType === "number") return true;
|
|
29
|
-
return valueType === "bigint" || valueType === "string" || valueType === "boolean";
|
|
30
|
-
}
|
|
31
|
-
__name(isPrimitiveComparable, "isPrimitiveComparable");
|
|
32
|
-
function tryObjectToPrimitive(obj) {
|
|
33
|
-
if (typeof obj.valueOf === "function") {
|
|
34
|
-
const valueOfResult = obj.valueOf();
|
|
35
|
-
if (valueOfResult !== obj) {
|
|
36
|
-
if (isPrimitiveComparable(valueOfResult)) return valueOfResult;
|
|
37
|
-
if (typeof valueOfResult === "object" && valueOfResult !== null) return tryObjectToPrimitive(valueOfResult);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (typeof obj.toString === "function") {
|
|
41
|
-
const stringResult = obj.toString();
|
|
42
|
-
if (stringResult !== "[object Object]") return stringResult;
|
|
43
|
-
}
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
__name(tryObjectToPrimitive, "tryObjectToPrimitive");
|
|
47
|
-
function isComparable(value, isForceObjectComparable = false) {
|
|
48
|
-
if (value === null || value === void 0) return false;
|
|
49
|
-
if (isPrimitiveComparable(value)) return true;
|
|
50
|
-
if (typeof value !== "object") return false;
|
|
51
|
-
if (value instanceof Date) return true;
|
|
52
|
-
if (isForceObjectComparable) return true;
|
|
53
|
-
const comparableValue = tryObjectToPrimitive(value);
|
|
54
|
-
if (comparableValue === null || comparableValue === void 0) return false;
|
|
55
|
-
return isPrimitiveComparable(comparableValue);
|
|
56
|
-
}
|
|
57
|
-
__name(isComparable, "isComparable");
|
|
58
26
|
|
|
59
27
|
// src/data-structures/base/iterable-entry-base.ts
|
|
60
28
|
var IterableEntryBase = class {
|
|
@@ -213,6 +181,14 @@ var IterableEntryBase = class {
|
|
|
213
181
|
}
|
|
214
182
|
return accumulator;
|
|
215
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Converts data structure to `[key, value]` pairs.
|
|
186
|
+
* @returns Array of entries.
|
|
187
|
+
* @remarks Time O(n), Space O(n)
|
|
188
|
+
*/
|
|
189
|
+
toArray() {
|
|
190
|
+
return [...this];
|
|
191
|
+
}
|
|
216
192
|
/**
|
|
217
193
|
* Visualize the iterable as an array of `[key, value]` pairs (or a custom string).
|
|
218
194
|
* @returns Array of entries (default) or a string.
|
|
@@ -3254,8 +3230,6 @@ var Range = class {
|
|
|
3254
3230
|
this.high = high;
|
|
3255
3231
|
this.includeLow = includeLow;
|
|
3256
3232
|
this.includeHigh = includeHigh;
|
|
3257
|
-
if (!(isComparable(low) && isComparable(high))) throw new RangeError("low or high is not comparable");
|
|
3258
|
-
if (low > high) throw new RangeError("low must be less than or equal to high");
|
|
3259
3233
|
}
|
|
3260
3234
|
static {
|
|
3261
3235
|
__name(this, "Range");
|