bst-typed 1.53.6 → 1.53.8
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/README.md +61 -0
- package/dist/common/index.d.ts +12 -0
- package/dist/common/index.js +28 -0
- package/dist/data-structures/binary-tree/avl-tree-multi-map.d.ts +1 -1
- package/dist/data-structures/binary-tree/avl-tree-multi-map.js +9 -12
- package/dist/data-structures/binary-tree/avl-tree.js +2 -2
- package/dist/data-structures/binary-tree/binary-tree.d.ts +55 -20
- package/dist/data-structures/binary-tree/binary-tree.js +102 -68
- package/dist/data-structures/binary-tree/bst.d.ts +131 -37
- package/dist/data-structures/binary-tree/bst.js +222 -69
- package/dist/data-structures/binary-tree/index.d.ts +1 -1
- package/dist/data-structures/binary-tree/index.js +1 -1
- package/dist/data-structures/binary-tree/{rb-tree.d.ts → red-black-tree.d.ts} +53 -0
- package/dist/data-structures/binary-tree/{rb-tree.js → red-black-tree.js} +56 -3
- package/dist/data-structures/binary-tree/tree-multi-map.d.ts +2 -2
- package/dist/data-structures/binary-tree/tree-multi-map.js +7 -7
- package/dist/data-structures/hash/hash-map.d.ts +30 -0
- package/dist/data-structures/hash/hash-map.js +30 -0
- package/dist/data-structures/heap/heap.d.ts +26 -9
- package/dist/data-structures/heap/heap.js +37 -17
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +54 -9
- package/dist/data-structures/linked-list/doubly-linked-list.js +80 -19
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +35 -2
- package/dist/data-structures/linked-list/singly-linked-list.js +55 -11
- package/dist/data-structures/queue/deque.d.ts +37 -8
- package/dist/data-structures/queue/deque.js +73 -29
- package/dist/data-structures/queue/queue.d.ts +41 -1
- package/dist/data-structures/queue/queue.js +51 -9
- package/dist/data-structures/stack/stack.d.ts +27 -10
- package/dist/data-structures/stack/stack.js +39 -20
- package/dist/data-structures/trie/trie.d.ts +111 -6
- package/dist/data-structures/trie/trie.js +123 -14
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/types/data-structures/binary-tree/binary-tree.d.ts +1 -1
- package/dist/types/data-structures/binary-tree/bst.d.ts +3 -2
- package/dist/types/data-structures/binary-tree/rb-tree.d.ts +1 -1
- package/dist/types/utils/utils.d.ts +10 -6
- package/dist/utils/utils.js +4 -2
- package/package.json +2 -2
- package/src/common/index.ts +25 -0
- package/src/data-structures/binary-tree/avl-tree-multi-map.ts +9 -11
- package/src/data-structures/binary-tree/avl-tree.ts +3 -2
- package/src/data-structures/binary-tree/binary-tree.ts +110 -66
- package/src/data-structures/binary-tree/bst.ts +232 -72
- package/src/data-structures/binary-tree/index.ts +1 -1
- package/src/data-structures/binary-tree/{rb-tree.ts → red-black-tree.ts} +56 -3
- package/src/data-structures/binary-tree/tree-multi-map.ts +6 -6
- package/src/data-structures/hash/hash-map.ts +30 -0
- package/src/data-structures/heap/heap.ts +72 -49
- package/src/data-structures/linked-list/doubly-linked-list.ts +173 -105
- package/src/data-structures/linked-list/singly-linked-list.ts +61 -11
- package/src/data-structures/queue/deque.ts +72 -28
- package/src/data-structures/queue/queue.ts +50 -7
- package/src/data-structures/stack/stack.ts +39 -20
- package/src/data-structures/trie/trie.ts +123 -13
- package/src/index.ts +2 -1
- package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
- package/src/types/data-structures/binary-tree/bst.ts +3 -2
- package/src/types/data-structures/binary-tree/rb-tree.ts +1 -1
- package/src/types/utils/utils.ts +16 -10
- package/src/utils/utils.ts +4 -2
package/src/types/utils/utils.ts
CHANGED
|
@@ -7,17 +7,23 @@ export type SpecifyOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T,
|
|
|
7
7
|
|
|
8
8
|
export type Any = string | number | bigint | boolean | symbol | undefined | object;
|
|
9
9
|
|
|
10
|
+
export type Arithmetic = number | bigint;
|
|
11
|
+
|
|
10
12
|
export type ComparablePrimitive = number | bigint | string | boolean;
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
export interface BaseComparableObject {
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ValueComparableObject extends BaseComparableObject {
|
|
19
|
+
valueOf: () => ComparablePrimitive | ValueComparableObject;
|
|
20
|
+
toString?: () => string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface StringComparableObject extends BaseComparableObject {
|
|
24
|
+
toString: () => string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type ComparableObject = ValueComparableObject | StringComparableObject;
|
|
22
28
|
|
|
23
29
|
export type Comparable = ComparablePrimitive | Date | ComparableObject;
|
package/src/utils/utils.ts
CHANGED
|
@@ -226,7 +226,8 @@ export const roundFixed = (num: number, digit: number = 10) => {
|
|
|
226
226
|
*/
|
|
227
227
|
function isPrimitiveComparable(value: unknown): value is ComparablePrimitive {
|
|
228
228
|
const valueType = typeof value;
|
|
229
|
-
if (valueType === 'number') return
|
|
229
|
+
if (valueType === 'number') return true;
|
|
230
|
+
// if (valueType === 'number') return !Number.isNaN(value);
|
|
230
231
|
return valueType === 'bigint' || valueType === 'string' || valueType === 'boolean';
|
|
231
232
|
}
|
|
232
233
|
|
|
@@ -274,7 +275,8 @@ export function isComparable(value: unknown, isForceObjectComparable = false): v
|
|
|
274
275
|
if (isPrimitiveComparable(value)) return true;
|
|
275
276
|
|
|
276
277
|
if (typeof value !== 'object') return false;
|
|
277
|
-
if (value instanceof Date) return
|
|
278
|
+
if (value instanceof Date) return true;
|
|
279
|
+
// if (value instanceof Date) return !Number.isNaN(value.getTime());
|
|
278
280
|
if (isForceObjectComparable) return true;
|
|
279
281
|
const comparableValue = tryObjectToPrimitive(value);
|
|
280
282
|
if (comparableValue === null || comparableValue === undefined) return false;
|