min-heap-typed 1.45.0 → 1.45.2

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.
Files changed (47) hide show
  1. package/dist/data-structures/hash/hash-map.d.ts +58 -58
  2. package/dist/data-structures/hash/hash-map.js +73 -73
  3. package/dist/data-structures/heap/heap.js +21 -12
  4. package/package.json +2 -2
  5. package/src/data-structures/binary-tree/avl-tree.ts +7 -7
  6. package/src/data-structures/binary-tree/binary-indexed-tree.ts +3 -3
  7. package/src/data-structures/binary-tree/binary-tree.ts +39 -31
  8. package/src/data-structures/binary-tree/bst.ts +12 -8
  9. package/src/data-structures/binary-tree/rb-tree.ts +17 -6
  10. package/src/data-structures/binary-tree/segment-tree.ts +1 -1
  11. package/src/data-structures/binary-tree/tree-multimap.ts +12 -9
  12. package/src/data-structures/graph/abstract-graph.ts +46 -31
  13. package/src/data-structures/graph/directed-graph.ts +10 -5
  14. package/src/data-structures/graph/map-graph.ts +8 -8
  15. package/src/data-structures/graph/undirected-graph.ts +9 -9
  16. package/src/data-structures/hash/hash-map.ts +103 -103
  17. package/src/data-structures/hash/hash-table.ts +1 -1
  18. package/src/data-structures/hash/tree-map.ts +2 -1
  19. package/src/data-structures/hash/tree-set.ts +2 -1
  20. package/src/data-structures/heap/heap.ts +30 -17
  21. package/src/data-structures/heap/max-heap.ts +3 -3
  22. package/src/data-structures/heap/min-heap.ts +3 -3
  23. package/src/data-structures/linked-list/doubly-linked-list.ts +1 -1
  24. package/src/data-structures/linked-list/singly-linked-list.ts +1 -1
  25. package/src/data-structures/matrix/matrix.ts +2 -2
  26. package/src/data-structures/matrix/matrix2d.ts +1 -1
  27. package/src/data-structures/matrix/navigator.ts +3 -3
  28. package/src/data-structures/matrix/vector2d.ts +2 -1
  29. package/src/data-structures/priority-queue/max-priority-queue.ts +3 -3
  30. package/src/data-structures/priority-queue/min-priority-queue.ts +3 -3
  31. package/src/data-structures/priority-queue/priority-queue.ts +3 -3
  32. package/src/data-structures/queue/deque.ts +5 -4
  33. package/src/data-structures/queue/queue.ts +2 -2
  34. package/src/data-structures/tree/tree.ts +1 -1
  35. package/src/data-structures/trie/trie.ts +1 -1
  36. package/src/interfaces/binary-tree.ts +2 -2
  37. package/src/interfaces/graph.ts +1 -1
  38. package/src/types/data-structures/binary-tree/avl-tree.ts +2 -2
  39. package/src/types/data-structures/binary-tree/binary-tree.ts +1 -1
  40. package/src/types/data-structures/binary-tree/bst.ts +2 -2
  41. package/src/types/data-structures/binary-tree/rb-tree.ts +2 -2
  42. package/src/types/data-structures/binary-tree/tree-multimap.ts +2 -2
  43. package/src/types/data-structures/hash/hash-map.ts +6 -6
  44. package/src/types/data-structures/matrix/navigator.ts +1 -1
  45. package/src/types/utils/utils.ts +1 -1
  46. package/src/types/utils/validate-type.ts +18 -4
  47. package/src/utils/utils.ts +6 -6
@@ -1,5 +1,5 @@
1
- import {BinaryTreeNode} from '../data-structures';
2
- import {BinaryTreeNodeNested, BiTreeDeleteResult, BTNCallback, BTNKey} from '../types';
1
+ import { BinaryTreeNode } from '../data-structures';
2
+ import { BinaryTreeNodeNested, BiTreeDeleteResult, BTNCallback, BTNKey } from '../types';
3
3
 
4
4
  export interface IBinaryTree<V = any, N extends BinaryTreeNode<V, N> = BinaryTreeNodeNested<V>> {
5
5
  createNode(key: BTNKey, value?: N['value']): N;
@@ -1,4 +1,4 @@
1
- import {VertexKey} from '../types';
1
+ import { VertexKey } from '../types';
2
2
 
3
3
  export interface IGraph<V, E, VO, EO> {
4
4
  createVertex(key: VertexKey, value?: V): VO;
@@ -1,5 +1,5 @@
1
- import {AVLTreeNode} from '../../../data-structures';
2
- import {BSTOptions} from './bst';
1
+ import { AVLTreeNode } from '../../../data-structures';
2
+ import { BSTOptions } from './bst';
3
3
 
4
4
  export type AVLTreeNodeNested<T> = AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, AVLTreeNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
5
5
  export type AVLTreeOptions = BSTOptions & {};
@@ -1,4 +1,4 @@
1
- import {BinaryTreeNode} from '../../../data-structures';
1
+ import { BinaryTreeNode } from '../../../data-structures';
2
2
 
3
3
  /**
4
4
  * Enum representing different loop types.
@@ -1,5 +1,5 @@
1
- import {BSTNode} from '../../../data-structures';
2
- import type {BinaryTreeOptions, BTNKey} from './binary-tree';
1
+ import { BSTNode } from '../../../data-structures';
2
+ import type { BinaryTreeOptions, BTNKey } from './binary-tree';
3
3
 
4
4
  export type BSTComparator = (a: BTNKey, b: BTNKey) => number;
5
5
 
@@ -1,5 +1,5 @@
1
- import {RedBlackTreeNode} from '../../../data-structures';
2
- import {BSTOptions} from "./bst";
1
+ import { RedBlackTreeNode } from '../../../data-structures';
2
+ import { BSTOptions } from "./bst";
3
3
 
4
4
  export enum RBTNColor { RED = 1, BLACK = 0}
5
5
 
@@ -1,5 +1,5 @@
1
- import {TreeMultimapNode} from '../../../data-structures';
2
- import {AVLTreeOptions} from './avl-tree';
1
+ import { TreeMultimapNode } from '../../../data-structures';
2
+ import { AVLTreeOptions } from './avl-tree';
3
3
 
4
4
  export type TreeMultimapNodeNested<T> = TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, TreeMultimapNode<T, any>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
5
5
 
@@ -7,11 +7,11 @@ export type HashMapOptions<T> = {
7
7
  sizeFunction?: number | (() => number);
8
8
  fixedLength?: number;
9
9
  forEach: (callback: (el: T) => void) => void;
10
- }
10
+ };
11
11
 
12
12
  export type HashMapLinkedNode<K, V> = {
13
- key: K
14
- value: V
15
- next: HashMapLinkedNode<K, V>
16
- prev: HashMapLinkedNode<K, V>
17
- }
13
+ key: K;
14
+ value: V;
15
+ next: HashMapLinkedNode<K, V>;
16
+ prev: HashMapLinkedNode<K, V>;
17
+ };
@@ -1,6 +1,6 @@
1
1
  export type Direction = 'up' | 'right' | 'down' | 'left';
2
2
 
3
- export type Turning = {[key in Direction]: Direction};
3
+ export type Turning = { [key in Direction]: Direction };
4
4
 
5
5
  export type NavigatorParams<T = any> = {
6
6
  matrix: T[][];
@@ -1,5 +1,5 @@
1
1
  export type ToThunkFn = () => ReturnType<TrlFn>;
2
- export type Thunk = () => ReturnType<ToThunkFn> & {__THUNK__: symbol};
2
+ export type Thunk = () => ReturnType<ToThunkFn> & { __THUNK__: symbol };
3
3
  export type TrlFn = (...args: any[]) => any;
4
4
  export type TrlAsyncFn = (...args: any[]) => any;
5
5
 
@@ -1,6 +1,6 @@
1
- export type KeyValueObject = {[key: string]: any};
1
+ export type KeyValueObject = { [key: string]: any };
2
2
 
3
- export type KeyValueObjectWithKey = {[key: string]: any; key: string | number | symbol};
3
+ export type KeyValueObjectWithKey = { [key: string]: any; key: string | number | symbol };
4
4
 
5
5
  export type NonNumberNonObjectButDefined = string | boolean | symbol | null;
6
6
 
@@ -16,6 +16,20 @@ export type ObjectWithNumberKey = {
16
16
  key: number;
17
17
  };
18
18
 
19
- export type RestrictValByKey = NonNumberNonObjectButDefined | ObjectWithoutKey | ObjectWithNonNumberKey | ObjectWithNumberKey;
19
+ export type RestrictValByKey =
20
+ | NonNumberNonObjectButDefined
21
+ | ObjectWithoutKey
22
+ | ObjectWithNonNumberKey
23
+ | ObjectWithNumberKey;
20
24
 
21
- export type DummyAny = string | number | boolean | null | undefined | object | symbol | void | ((...args: []) => any) | never;
25
+ export type DummyAny =
26
+ | string
27
+ | number
28
+ | boolean
29
+ | null
30
+ | undefined
31
+ | object
32
+ | symbol
33
+ | void
34
+ | ((...args: []) => any)
35
+ | never;
@@ -5,7 +5,7 @@
5
5
  * @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
6
6
  * @license MIT License
7
7
  */
8
- import type {Thunk, ToThunkFn, TrlAsyncFn, TrlFn} from '../types';
8
+ import type { Thunk, ToThunkFn, TrlAsyncFn, TrlFn } from '../types';
9
9
 
10
10
  export const uuidV4 = function () {
11
11
  return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/[x]/g, function (c) {
@@ -57,7 +57,7 @@ export const trampoline = (fn: TrlFn) => {
57
57
 
58
58
  return result;
59
59
  },
60
- {cont}
60
+ { cont }
61
61
  );
62
62
  };
63
63
 
@@ -74,7 +74,7 @@ export const trampolineAsync = (fn: TrlAsyncFn) => {
74
74
 
75
75
  return result;
76
76
  },
77
- {cont}
77
+ { cont }
78
78
  );
79
79
  };
80
80
 
@@ -87,13 +87,13 @@ export const getMSB = (value: number): number => {
87
87
 
88
88
  export const rangeCheck = (index: number, min: number, max: number, message = 'Index out of bounds.'): void => {
89
89
  if (index < min || index > max) throw new RangeError(message);
90
- }
90
+ };
91
91
 
92
92
  export const throwRangeError = (message = 'The value is off-limits.'): void => {
93
93
  throw new RangeError(message);
94
- }
94
+ };
95
95
 
96
96
  export const isObjOrFunc = (input: unknown): input is Record<string, unknown> | ((...args: any[]) => any) => {
97
97
  const inputType = typeof input;
98
98
  return (inputType === 'object' && input !== null) || inputType === 'function';
99
- }
99
+ };