data-structure-typed 1.15.0 → 1.15.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.
- package/README.md +378 -7
- package/dist/data-structures/binary-tree/binary-tree.d.ts +30 -30
- package/dist/data-structures/binary-tree/binary-tree.js +55 -55
- package/dist/data-structures/binary-tree/segment-tree.d.ts +17 -17
- package/dist/data-structures/binary-tree/segment-tree.js +30 -30
- package/dist/data-structures/graph/abstract-graph.d.ts +6 -6
- package/dist/data-structures/graph/abstract-graph.js +6 -6
- package/dist/data-structures/graph/directed-graph.d.ts +4 -4
- package/dist/data-structures/graph/directed-graph.js +6 -6
- package/dist/data-structures/graph/undirected-graph.d.ts +3 -3
- package/dist/data-structures/hash/coordinate-map.d.ts +2 -2
- package/dist/data-structures/hash/coordinate-set.d.ts +2 -2
- package/dist/data-structures/heap/heap.d.ts +14 -14
- package/dist/data-structures/heap/heap.js +12 -12
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +9 -9
- package/dist/data-structures/linked-list/doubly-linked-list.js +12 -12
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +7 -7
- package/dist/data-structures/priority-queue/priority-queue.d.ts +7 -7
- package/dist/data-structures/priority-queue/priority-queue.js +6 -6
- package/dist/data-structures/queue/deque.d.ts +1 -1
- package/dist/utils/types/utils.d.ts +0 -52
- package/dist/utils/types/utils.js +0 -52
- package/dist/utils/utils.d.ts +1 -97
- package/dist/utils/utils.js +1 -547
- package/package.json +3 -4
- package/src/assets/overview-diagram-of-data-structures.png +0 -0
- package/src/data-structures/binary-tree/binary-tree.ts +83 -76
- package/src/data-structures/binary-tree/segment-tree.ts +55 -36
- package/src/data-structures/graph/abstract-graph.ts +21 -19
- package/src/data-structures/graph/directed-graph.ts +23 -18
- package/src/data-structures/graph/undirected-graph.ts +16 -11
- package/src/data-structures/hash/coordinate-map.ts +11 -8
- package/src/data-structures/hash/coordinate-set.ts +11 -8
- package/src/data-structures/heap/heap.ts +34 -28
- package/src/data-structures/linked-list/doubly-linked-list.ts +40 -26
- package/src/data-structures/linked-list/singly-linked-list.ts +32 -23
- package/src/data-structures/priority-queue/priority-queue.ts +17 -14
- package/src/data-structures/queue/deque.ts +14 -4
- package/src/utils/types/utils.ts +1 -175
- package/src/utils/utils.ts +1 -484
- package/tests/unit/data-structures/binary-tree/bst.test.ts +40 -31
- package/tests/unit/data-structures/graph/directed-graph.test.ts +31 -34
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare class DoublyLinkedListNode<T> {
|
|
2
|
+
constructor(nodeValue: T);
|
|
2
3
|
protected _val: T;
|
|
3
4
|
get val(): T;
|
|
4
5
|
set val(v: T);
|
|
@@ -8,31 +9,30 @@ export declare class DoublyLinkedListNode<T> {
|
|
|
8
9
|
protected _prev: DoublyLinkedListNode<T> | null;
|
|
9
10
|
get prev(): DoublyLinkedListNode<T> | null;
|
|
10
11
|
set prev(v: DoublyLinkedListNode<T> | null);
|
|
11
|
-
constructor(nodeValue: T);
|
|
12
12
|
}
|
|
13
13
|
export declare class DoublyLinkedList<T> {
|
|
14
|
+
constructor();
|
|
14
15
|
protected _first: DoublyLinkedListNode<T> | null;
|
|
15
16
|
get first(): DoublyLinkedListNode<T> | null;
|
|
17
|
+
protected set first(v: DoublyLinkedListNode<T> | null);
|
|
18
|
+
protected _last: DoublyLinkedListNode<T> | null;
|
|
19
|
+
get last(): DoublyLinkedListNode<T> | null;
|
|
20
|
+
protected set last(v: DoublyLinkedListNode<T> | null);
|
|
21
|
+
protected _size: number;
|
|
22
|
+
get size(): number;
|
|
23
|
+
protected set size(v: number);
|
|
16
24
|
/**
|
|
17
25
|
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
18
26
|
*/
|
|
19
27
|
getFirst(): DoublyLinkedListNode<T> | null;
|
|
20
|
-
protected set first(v: DoublyLinkedListNode<T> | null);
|
|
21
|
-
protected _last: DoublyLinkedListNode<T> | null;
|
|
22
|
-
get last(): DoublyLinkedListNode<T> | null;
|
|
23
28
|
/**
|
|
24
29
|
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
25
30
|
*/
|
|
26
31
|
getLast(): DoublyLinkedListNode<T> | null;
|
|
27
|
-
protected set last(v: DoublyLinkedListNode<T> | null);
|
|
28
|
-
protected _size: number;
|
|
29
|
-
get size(): number;
|
|
30
32
|
/**
|
|
31
33
|
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
32
34
|
*/
|
|
33
35
|
getSize(): number;
|
|
34
|
-
protected set size(v: number);
|
|
35
|
-
constructor();
|
|
36
36
|
/**
|
|
37
37
|
* The function adds a new node with a given value to the beginning of a doubly linked list.
|
|
38
38
|
* @param {T} val - The `val` parameter represents the value of the element that you want to add to the beginning of
|
|
@@ -56,12 +56,6 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
56
56
|
enumerable: false,
|
|
57
57
|
configurable: true
|
|
58
58
|
});
|
|
59
|
-
/**
|
|
60
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
61
|
-
*/
|
|
62
|
-
DoublyLinkedList.prototype.getFirst = function () {
|
|
63
|
-
return this._first;
|
|
64
|
-
};
|
|
65
59
|
Object.defineProperty(DoublyLinkedList.prototype, "last", {
|
|
66
60
|
get: function () {
|
|
67
61
|
return this._last;
|
|
@@ -72,12 +66,6 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
72
66
|
enumerable: false,
|
|
73
67
|
configurable: true
|
|
74
68
|
});
|
|
75
|
-
/**
|
|
76
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
77
|
-
*/
|
|
78
|
-
DoublyLinkedList.prototype.getLast = function () {
|
|
79
|
-
return this._last;
|
|
80
|
-
};
|
|
81
69
|
Object.defineProperty(DoublyLinkedList.prototype, "size", {
|
|
82
70
|
get: function () {
|
|
83
71
|
return this._size;
|
|
@@ -88,6 +76,18 @@ var DoublyLinkedList = /** @class */ (function () {
|
|
|
88
76
|
enumerable: false,
|
|
89
77
|
configurable: true
|
|
90
78
|
});
|
|
79
|
+
/**
|
|
80
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
81
|
+
*/
|
|
82
|
+
DoublyLinkedList.prototype.getFirst = function () {
|
|
83
|
+
return this._first;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
87
|
+
*/
|
|
88
|
+
DoublyLinkedList.prototype.getLast = function () {
|
|
89
|
+
return this._last;
|
|
90
|
+
};
|
|
91
91
|
/**
|
|
92
92
|
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
93
93
|
*/
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @license MIT License
|
|
7
7
|
*/
|
|
8
8
|
export declare class SinglyLinkedListNode<NodeVal = any> {
|
|
9
|
+
constructor(val: NodeVal, prev?: SinglyLinkedListNode<NodeVal> | null, next?: SinglyLinkedListNode<NodeVal> | null, list?: SinglyLinkedList<NodeVal> | null);
|
|
9
10
|
protected _val: NodeVal;
|
|
10
11
|
get val(): NodeVal;
|
|
11
12
|
set val(value: NodeVal);
|
|
@@ -18,7 +19,6 @@ export declare class SinglyLinkedListNode<NodeVal = any> {
|
|
|
18
19
|
protected _list: SinglyLinkedList<NodeVal> | null;
|
|
19
20
|
get list(): SinglyLinkedList<NodeVal> | null;
|
|
20
21
|
set list(value: SinglyLinkedList<NodeVal> | null);
|
|
21
|
-
constructor(val: NodeVal, prev?: SinglyLinkedListNode<NodeVal> | null, next?: SinglyLinkedListNode<NodeVal> | null, list?: SinglyLinkedList<NodeVal> | null);
|
|
22
22
|
get index(): number | undefined;
|
|
23
23
|
/**
|
|
24
24
|
* The `insertBefore` function inserts a new node with the given value before the current node in a singly linked list.
|
|
@@ -40,6 +40,12 @@ export declare class SinglyLinkedListNode<NodeVal = any> {
|
|
|
40
40
|
remove(): SinglyLinkedListNode<NodeVal>;
|
|
41
41
|
}
|
|
42
42
|
export declare class SinglyLinkedList<NodeVal = any> {
|
|
43
|
+
/**
|
|
44
|
+
* The constructor initializes a linked list with the given arguments as nodes.
|
|
45
|
+
* @param {NodeVal[]} args - args is a rest parameter that allows the constructor to accept an arbitrary number of
|
|
46
|
+
* arguments of type NodeVal.
|
|
47
|
+
*/
|
|
48
|
+
constructor(...args: NodeVal[]);
|
|
43
49
|
protected _head: SinglyLinkedListNode<NodeVal> | null;
|
|
44
50
|
get head(): SinglyLinkedListNode<NodeVal> | null;
|
|
45
51
|
set head(value: SinglyLinkedListNode<NodeVal> | null);
|
|
@@ -49,12 +55,6 @@ export declare class SinglyLinkedList<NodeVal = any> {
|
|
|
49
55
|
protected _size: number;
|
|
50
56
|
get size(): number;
|
|
51
57
|
set size(value: number);
|
|
52
|
-
/**
|
|
53
|
-
* The constructor initializes a linked list with the given arguments as nodes.
|
|
54
|
-
* @param {NodeVal[]} args - args is a rest parameter that allows the constructor to accept an arbitrary number of
|
|
55
|
-
* arguments of type NodeVal.
|
|
56
|
-
*/
|
|
57
|
-
constructor(...args: NodeVal[]);
|
|
58
58
|
/**
|
|
59
59
|
* The `from` function in TypeScript creates a new SinglyLinkedList instance from an iterable object.
|
|
60
60
|
* @param iterable - The `iterable` parameter is an object that can be iterated over, such as an array or a string. It
|
|
@@ -7,19 +7,15 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { PriorityQueueComparator, PriorityQueueDFSOrderPattern, PriorityQueueOptions } from '../types';
|
|
9
9
|
export declare class PriorityQueue<T = number> {
|
|
10
|
-
protected _nodes: T[];
|
|
11
|
-
get nodes(): T[];
|
|
12
|
-
/**
|
|
13
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
14
|
-
*/
|
|
15
|
-
getNodes(): T[];
|
|
16
|
-
protected set nodes(value: T[]);
|
|
17
10
|
/**
|
|
18
11
|
* The constructor initializes a priority queue with the given options, including an array of nodes and a comparator
|
|
19
12
|
* function.
|
|
20
13
|
* @param options - The `options` parameter is an object that contains the following properties:
|
|
21
14
|
*/
|
|
22
15
|
constructor(options: PriorityQueueOptions<T>);
|
|
16
|
+
protected _nodes: T[];
|
|
17
|
+
get nodes(): T[];
|
|
18
|
+
protected set nodes(value: T[]);
|
|
23
19
|
get size(): number;
|
|
24
20
|
/**
|
|
25
21
|
* The `heapify` function creates a new PriorityQueue instance and fixes the heap property.
|
|
@@ -37,6 +33,10 @@ export declare class PriorityQueue<T = number> {
|
|
|
37
33
|
* @returns the result of calling the `isValid()` method on a new instance of the `PriorityQueue` class.
|
|
38
34
|
*/
|
|
39
35
|
static isPriorityQueueified<T>(options: Omit<PriorityQueueOptions<T>, 'isFix'>): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
38
|
+
*/
|
|
39
|
+
getNodes(): T[];
|
|
40
40
|
/**
|
|
41
41
|
* The "add" function adds a node to the heap and ensures that the heap property is maintained.
|
|
42
42
|
* @param {T} node - The parameter "node" is of type T, which means it can be any data type. It represents the node
|
|
@@ -67,12 +67,6 @@ var PriorityQueue = /** @class */ (function () {
|
|
|
67
67
|
enumerable: false,
|
|
68
68
|
configurable: true
|
|
69
69
|
});
|
|
70
|
-
/**
|
|
71
|
-
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
72
|
-
*/
|
|
73
|
-
PriorityQueue.prototype.getNodes = function () {
|
|
74
|
-
return this._nodes;
|
|
75
|
-
};
|
|
76
70
|
Object.defineProperty(PriorityQueue.prototype, "size", {
|
|
77
71
|
get: function () {
|
|
78
72
|
return this.nodes.length;
|
|
@@ -102,6 +96,12 @@ var PriorityQueue = /** @class */ (function () {
|
|
|
102
96
|
PriorityQueue.isPriorityQueueified = function (options) {
|
|
103
97
|
return new PriorityQueue(__assign(__assign({}, options), { isFix: true })).isValid();
|
|
104
98
|
};
|
|
99
|
+
/**
|
|
100
|
+
* Starting from TypeScript version 5.0 and onwards, the use of distinct access modifiers for Getters and Setters is not permitted. As an alternative, to ensure compatibility, it is necessary to adopt a Java-style approach for Setters (using the same name as the property) while utilizing separate method names for Getters.
|
|
101
|
+
*/
|
|
102
|
+
PriorityQueue.prototype.getNodes = function () {
|
|
103
|
+
return this._nodes;
|
|
104
|
+
};
|
|
105
105
|
/**
|
|
106
106
|
* The "add" function adds a node to the heap and ensures that the heap property is maintained.
|
|
107
107
|
* @param {T} node - The parameter "node" is of type T, which means it can be any data type. It represents the node
|
|
@@ -9,6 +9,7 @@ import { DoublyLinkedList } from '../linked-list';
|
|
|
9
9
|
export declare class Deque<T> extends DoublyLinkedList<T> {
|
|
10
10
|
}
|
|
11
11
|
export declare class ObjectDeque<T> {
|
|
12
|
+
constructor(capacity?: number);
|
|
12
13
|
private _nodes;
|
|
13
14
|
get nodes(): {
|
|
14
15
|
[p: number]: T;
|
|
@@ -28,7 +29,6 @@ export declare class ObjectDeque<T> {
|
|
|
28
29
|
private _size;
|
|
29
30
|
get size(): number;
|
|
30
31
|
protected set size(value: number);
|
|
31
|
-
constructor(capacity?: number);
|
|
32
32
|
addFirst(value: T): void;
|
|
33
33
|
addLast(value: T): void;
|
|
34
34
|
pollFirst(): T | undefined;
|
|
@@ -1,55 +1,3 @@
|
|
|
1
|
-
export type JSONSerializable = {
|
|
2
|
-
[key: string]: any;
|
|
3
|
-
};
|
|
4
|
-
export type JSONValue = string | number | boolean | undefined | JSONObject;
|
|
5
|
-
export interface JSONObject {
|
|
6
|
-
[key: string]: JSONValue;
|
|
7
|
-
}
|
|
8
|
-
export type AnyFunction<A extends any[] = any[], R = any> = (...args: A) => R;
|
|
9
|
-
export type Primitive = number | string | boolean | symbol | undefined | null | void | AnyFunction | Date;
|
|
10
|
-
export type Cast<T, TComplex> = {
|
|
11
|
-
[M in keyof TComplex]: T;
|
|
12
|
-
};
|
|
13
|
-
export type DeepLeavesWrap<T, TComplex> = T extends string ? Cast<string, TComplex> : T extends number ? Cast<number, TComplex> : T extends boolean ? Cast<boolean, TComplex> : T extends undefined ? Cast<undefined, TComplex> : T extends null ? Cast<null, TComplex> : T extends void ? Cast<void, TComplex> : T extends symbol ? Cast<symbol, TComplex> : T extends AnyFunction ? Cast<AnyFunction, TComplex> : T extends Date ? Cast<Date, TComplex> : {
|
|
14
|
-
[K in keyof T]: T[K] extends (infer U)[] ? DeepLeavesWrap<U, TComplex>[] : DeepLeavesWrap<T[K], TComplex>;
|
|
15
|
-
};
|
|
16
|
-
export type TypeName<T> = T extends string ? 'string' : T extends number ? 'number' : T extends boolean ? 'boolean' : T extends undefined ? 'undefined' : T extends AnyFunction ? 'function' : 'object';
|
|
17
|
-
export type JsonKeys<T> = keyof {
|
|
18
|
-
[P in keyof T]: number;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* A function that emits a side effect and does not return anything.
|
|
22
|
-
*/
|
|
23
|
-
export type Procedure = (...args: any[]) => void;
|
|
24
|
-
export type DebounceOptions = {
|
|
25
|
-
isImmediate?: boolean;
|
|
26
|
-
maxWait?: number;
|
|
27
|
-
};
|
|
28
|
-
export interface DebouncedFunction<F extends Procedure> {
|
|
29
|
-
cancel: () => void;
|
|
30
|
-
(this: ThisParameterType<F>, ...args: [...Parameters<F>]): void;
|
|
31
|
-
}
|
|
32
|
-
export type MonthKey = 'January' | 'February' | 'March' | 'April' | 'May' | 'June' | 'July' | 'August' | 'September' | 'October' | 'November' | 'December';
|
|
33
|
-
export type Month = {
|
|
34
|
-
[key in MonthKey]: string;
|
|
35
|
-
};
|
|
36
|
-
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
37
|
-
export declare class TreeNode<T> {
|
|
38
|
-
id: string;
|
|
39
|
-
name?: string | undefined;
|
|
40
|
-
value?: T | undefined;
|
|
41
|
-
children?: TreeNode<T>[] | undefined;
|
|
42
|
-
constructor(id: string, name?: string, value?: T, children?: TreeNode<T>[]);
|
|
43
|
-
addChildren(children: TreeNode<T> | TreeNode<T>[]): void;
|
|
44
|
-
getHeight(): number;
|
|
45
|
-
}
|
|
46
|
-
export type OrderType = 'InOrder' | 'PreOrder' | 'PostOrder';
|
|
47
|
-
export type DeepProxy<T> = T extends (...args: any[]) => infer R ? (...args: [...Parameters<T>]) => DeepProxy<R> : T extends object ? {
|
|
48
|
-
[K in keyof T]: DeepProxy<T[K]>;
|
|
49
|
-
} : T;
|
|
50
|
-
export type DeepProxyOnChange = (target: any, property: string | symbol, value: any, receiver: any, descriptor: any, result: any) => void;
|
|
51
|
-
export type DeepProxyOnGet = (target: any, property: string | symbol, value: any, receiver: any, descriptor: any, result: any) => void;
|
|
52
|
-
export type CurryFunc<T> = T extends (...args: infer Args) => infer R ? Args extends [infer Arg, ...infer RestArgs] ? (arg: Arg) => CurryFunc<(...args: RestArgs) => R> : R : T;
|
|
53
1
|
export type ToThunkFn = () => ReturnType<TrlFn>;
|
|
54
2
|
export type Thunk = () => ReturnType<ToThunkFn> & {
|
|
55
3
|
__THUNK__: Symbol;
|
|
@@ -1,54 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TreeNode = void 0;
|
|
4
|
-
var arr = ['1', 2, 4, 5, 6];
|
|
5
|
-
var a = 2;
|
|
6
|
-
var TreeNode = /** @class */ (function () {
|
|
7
|
-
function TreeNode(id, name, value, children) {
|
|
8
|
-
this.id = id;
|
|
9
|
-
this.name = name || '';
|
|
10
|
-
this.value = value || undefined;
|
|
11
|
-
this.children = children || [];
|
|
12
|
-
}
|
|
13
|
-
// TODO get set
|
|
14
|
-
// get name (): string | undefined {
|
|
15
|
-
// return this.name;
|
|
16
|
-
// }
|
|
17
|
-
//
|
|
18
|
-
// set name (name: string | undefined) {
|
|
19
|
-
// this.name = name;
|
|
20
|
-
// }
|
|
21
|
-
TreeNode.prototype.addChildren = function (children) {
|
|
22
|
-
if (!this.children) {
|
|
23
|
-
this.children = [];
|
|
24
|
-
}
|
|
25
|
-
if (children instanceof TreeNode) {
|
|
26
|
-
this.children.push(children);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
this.children = this.children.concat(children);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
TreeNode.prototype.getHeight = function () {
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
34
|
-
var beginRoot = this;
|
|
35
|
-
var maxDepth = 1;
|
|
36
|
-
if (beginRoot) {
|
|
37
|
-
var bfs_1 = function (node, level) {
|
|
38
|
-
if (level > maxDepth) {
|
|
39
|
-
maxDepth = level;
|
|
40
|
-
}
|
|
41
|
-
var children = node.children;
|
|
42
|
-
if (children) {
|
|
43
|
-
for (var i = 0, len = children.length; i < len; i++) {
|
|
44
|
-
bfs_1(children[i], level + 1);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
bfs_1(beginRoot, 1);
|
|
49
|
-
}
|
|
50
|
-
return maxDepth;
|
|
51
|
-
};
|
|
52
|
-
return TreeNode;
|
|
53
|
-
}());
|
|
54
|
-
exports.TreeNode = TreeNode;
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -1,101 +1,5 @@
|
|
|
1
|
-
import type { AnyFunction, JSONObject, JSONSerializable } from './types';
|
|
2
|
-
export declare function randomText(length: number): string;
|
|
3
1
|
export declare const uuidV4: () => string;
|
|
4
|
-
export declare class IncrementId {
|
|
5
|
-
private _id;
|
|
6
|
-
private readonly _prefix;
|
|
7
|
-
constructor(prefix?: string);
|
|
8
|
-
getId(): string;
|
|
9
|
-
}
|
|
10
|
-
export declare function incrementId(prefix?: string): () => string;
|
|
11
|
-
export declare const getValue: <T, K extends keyof T>(obj: T, names: K[]) => T[K][];
|
|
12
|
-
export declare const isObject: (object: string | JSONObject | boolean | AnyFunction | number) => boolean;
|
|
13
|
-
export declare const looseEqual: (a: any, b: any) => boolean;
|
|
14
|
-
export declare const strictEqual: (a: any, b: any) => boolean;
|
|
15
|
-
export declare const strictObjectIsEqual: (a: any, b: any) => boolean;
|
|
16
|
-
export declare const deepObjectStrictEqual: (object1: JSONSerializable, object2: JSONSerializable) => boolean;
|
|
17
|
-
export declare function reverseColor(oldColor: string): string;
|
|
18
|
-
export declare const isSameStructure: (objA: unknown, objB: unknown) => boolean;
|
|
19
|
-
export declare const isLeafParent: (obj: JSONObject) => boolean;
|
|
20
|
-
export declare const addDays: (date: Date, days: number) => Date;
|
|
21
|
-
export declare class WaitManager {
|
|
22
|
-
private _time30;
|
|
23
|
-
private readonly _nXSpeed;
|
|
24
|
-
constructor(nXSpeed?: number);
|
|
25
|
-
private _time1;
|
|
26
|
-
get time1(): number;
|
|
27
|
-
private _time2;
|
|
28
|
-
get time2(): number;
|
|
29
|
-
private _time3;
|
|
30
|
-
get time3(): number;
|
|
31
|
-
private _time4;
|
|
32
|
-
get time4(): number;
|
|
33
|
-
private _time10;
|
|
34
|
-
get time10(): number;
|
|
35
|
-
private _time20;
|
|
36
|
-
get time20(): number;
|
|
37
|
-
get time50(): number;
|
|
38
|
-
private _time60;
|
|
39
|
-
get time60(): number;
|
|
40
|
-
private _cusTime;
|
|
41
|
-
get cusTime(): number;
|
|
42
|
-
set cusTime(v: number);
|
|
43
|
-
}
|
|
44
|
-
export declare const wait: (ms: number, resolveValue?: any) => Promise<unknown>;
|
|
45
|
-
export declare function extractValue<Item>(data: {
|
|
46
|
-
key: string;
|
|
47
|
-
value: Item;
|
|
48
|
-
}[]): Item[];
|
|
49
|
-
export declare function keyValueToArray<Item>(data: {
|
|
50
|
-
[key: string]: Item;
|
|
51
|
-
}): Item[];
|
|
52
|
-
export declare function minuted(time: number): string;
|
|
53
|
-
export declare function randomDate(start?: Date, end?: Date, specificProbabilityStart?: Date, specificProbability?: number): Date;
|
|
54
|
-
export declare const capitalizeWords: (str: string) => string;
|
|
55
|
-
export declare const capitalizeFirstLetter: (str: string) => string;
|
|
56
|
-
export declare const comparerArray: <T>(otherArray: T[], limitKeys?: string[]) => (current: T) => boolean;
|
|
57
|
-
export declare const onlyInA: <T>(a: T[], b: T[]) => T[];
|
|
58
|
-
export declare const onlyInB: <T>(a: T[], b: T[]) => T[];
|
|
59
|
-
export declare const diffAB: <T>(a: T[], b: T[]) => T[];
|
|
60
|
-
export declare class StringUtil {
|
|
61
|
-
static toCamelCase(str: string): string;
|
|
62
|
-
static toSnakeCase(str: string): string;
|
|
63
|
-
static toPascalCase(str: string): string;
|
|
64
|
-
static toConstantCase(str: string): string;
|
|
65
|
-
static toKebabCase(str: string): string;
|
|
66
|
-
static toLowerCase(str: string): string;
|
|
67
|
-
static toTitleCase(str: string): string;
|
|
68
|
-
static toSentenceCase(str: string): string;
|
|
69
|
-
static toPathCase(str: string): string;
|
|
70
|
-
static toDotCase(str: string): string;
|
|
71
|
-
}
|
|
72
|
-
export type CaseType = 'camel' | 'snake' | 'pascal' | 'constant' | 'kebab' | 'lower' | 'title' | 'sentence' | 'path' | 'dot';
|
|
73
|
-
export declare const deepKeysConvert: (obj: any, toType?: CaseType) => any;
|
|
74
|
-
export declare const deepRemoveByKey: (obj: any, keysToBeRemoved: string[]) => any;
|
|
75
|
-
export declare const deepRenameKeys: (obj: JSONSerializable, keysMap: {
|
|
76
|
-
[x: string]: string;
|
|
77
|
-
}) => JSONSerializable;
|
|
78
|
-
export declare const deepReplaceValues: (obj: JSONSerializable, keyReducerMap: {
|
|
79
|
-
[x: string]: (item: JSONSerializable) => any;
|
|
80
|
-
}) => JSONSerializable;
|
|
81
|
-
export declare const deepAdd: (obj: JSONSerializable, keyReducerMap: {
|
|
82
|
-
[x: string]: (item: JSONSerializable) => any;
|
|
83
|
-
}, isItemRootParent?: boolean) => [] | JSONObject;
|
|
84
|
-
export declare const bunnyConsole: {
|
|
85
|
-
log: (headerLog?: string, ...args: any[]) => void;
|
|
86
|
-
warn: (headerLog?: string, ...args: any[]) => void;
|
|
87
|
-
error: (headerLog?: string, ...args: any[]) => void;
|
|
88
|
-
};
|
|
89
|
-
export declare const timeStart: () => number;
|
|
90
|
-
export declare const timeEnd: (startTime: number, headerLog?: string, consoleConditionFn?: ((timeSpent: number) => boolean) | undefined) => void;
|
|
91
2
|
export declare const arrayRemove: <T>(array: T[], predicate: (item: T, index: number, array: T[]) => boolean) => T[];
|
|
92
|
-
export declare function memo(): (target: Object, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
93
|
-
export declare function zip<T = number, T1 = number>(array1: T[], array2: T1[], options?: {
|
|
94
|
-
isToObj: boolean;
|
|
95
|
-
}): [T, T1][] | {
|
|
96
|
-
x: T;
|
|
97
|
-
y: T1;
|
|
98
|
-
}[];
|
|
99
3
|
/**
|
|
100
4
|
* data-structure-typed
|
|
101
5
|
*
|
|
@@ -103,7 +7,7 @@ export declare function zip<T = number, T1 = number>(array1: T[], array2: T1[],
|
|
|
103
7
|
* @copyright Copyright (c) 2022 Tyler Zeng <zrwusa@gmail.com>
|
|
104
8
|
* @license MIT License
|
|
105
9
|
*/
|
|
106
|
-
import { Thunk, ToThunkFn, TrlAsyncFn, TrlFn } from './types';
|
|
10
|
+
import type { Thunk, ToThunkFn, TrlAsyncFn, TrlFn } from './types';
|
|
107
11
|
export declare const THUNK_SYMBOL: unique symbol;
|
|
108
12
|
export declare const isThunk: (fnOrValue: any) => boolean;
|
|
109
13
|
export declare const toThunk: (fn: ToThunkFn) => Thunk;
|