data-structure-typed 1.15.0 → 1.15.1
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/utils/types/utils.d.ts +0 -49
- package/dist/utils/types/utils.js +14 -52
- package/dist/utils/utils.d.ts +1 -97
- package/dist/utils/utils.js +197 -546
- package/package.json +3 -2
- package/src/utils/types/utils.ts +165 -167
- package/src/utils/utils.ts +209 -480
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "data-structure-typed",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.1",
|
|
4
4
|
"description": "Explore our comprehensive Javascript Data Structure / TypeScript Data Structure Library, meticulously crafted to empower developers with a versatile set of essential data structures. Our library includes a wide range of data structures, such as Binary Tree, AVL Tree, Binary Search Tree (BST), Tree Multiset, Segment Tree, Binary Indexed Tree, Graph, Directed Graph, Undirected Graph, Singly Linked List, Hash, CoordinateSet, CoordinateMap, Heap, Doubly Linked List, Priority Queue, Max Priority Queue, Min Priority Queue, Queue, ObjectDeque, ArrayDeque, Stack, and Trie. Each data structure is thoughtfully designed and implemented using TypeScript to provide efficient, reliable, and easy-to-use solutions for your programming needs. Whether you're optimizing algorithms, managing data, or enhancing performance, our TypeScript Data Structure Library is your go-to resource. Elevate your coding experience with these fundamental building blocks for software development.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "rm -rf dist && npx tsc",
|
|
8
8
|
"test": "jest",
|
|
9
9
|
"build:docs": "typedoc --out docs ./src",
|
|
10
|
-
"deps:check": "dependency-cruiser src"
|
|
10
|
+
"deps:check": "dependency-cruiser src",
|
|
11
|
+
"build:publish": "npm run test && npm run build && npm run build:docs && npm run publish"
|
|
11
12
|
},
|
|
12
13
|
"repository": {
|
|
13
14
|
"type": "git",
|
package/src/utils/types/utils.ts
CHANGED
|
@@ -1,174 +1,161 @@
|
|
|
1
|
-
export type JSONSerializable = {
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export type
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const arr = ['1', 2, 4, 5, 6] as const;
|
|
61
|
-
type Range = typeof arr[number];
|
|
62
|
-
const a: Range = 2;
|
|
63
|
-
|
|
1
|
+
// export type JSONSerializable = {
|
|
2
|
+
// [key: string]: any
|
|
3
|
+
// }
|
|
4
|
+
|
|
5
|
+
// export type JSONValue = string | number | boolean | undefined | JSONObject;
|
|
6
|
+
//
|
|
7
|
+
// export interface JSONObject {
|
|
8
|
+
// [key: string]: JSONValue;
|
|
9
|
+
// }
|
|
10
|
+
//
|
|
11
|
+
// export type AnyFunction<A extends any[] = any[], R = any> = (...args: A) => R;
|
|
12
|
+
|
|
13
|
+
// export type Primitive =
|
|
14
|
+
// | number
|
|
15
|
+
// | string
|
|
16
|
+
// | boolean
|
|
17
|
+
// | symbol
|
|
18
|
+
// | undefined
|
|
19
|
+
// | null
|
|
20
|
+
// | void
|
|
21
|
+
// | AnyFunction
|
|
22
|
+
// | Date;
|
|
23
|
+
|
|
24
|
+
// export type Cast<T, TComplex> = { [M in keyof TComplex]: T };
|
|
25
|
+
|
|
26
|
+
// export type DeepLeavesWrap<T, TComplex> =
|
|
27
|
+
// T extends string ? Cast<string, TComplex>
|
|
28
|
+
// : T extends number ? Cast<number, TComplex>
|
|
29
|
+
// : T extends boolean ? Cast<boolean, TComplex>
|
|
30
|
+
// : T extends undefined ? Cast<undefined, TComplex>
|
|
31
|
+
// : T extends null ? Cast<null, TComplex>
|
|
32
|
+
// : T extends void ? Cast<void, TComplex>
|
|
33
|
+
// : T extends symbol ? Cast<symbol, TComplex>
|
|
34
|
+
// : T extends AnyFunction ? Cast<AnyFunction, TComplex>
|
|
35
|
+
// : T extends Date ? Cast<Date, TComplex>
|
|
36
|
+
// : {
|
|
37
|
+
// [K in keyof T]:
|
|
38
|
+
// T[K] extends (infer U)[] ? DeepLeavesWrap<U, TComplex>[]
|
|
39
|
+
// : DeepLeavesWrap<T[K], TComplex>;
|
|
40
|
+
// }
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
// type Json = null | string | number | boolean | Json [] | { [name: string]: Json }
|
|
44
|
+
|
|
45
|
+
// export type TypeName<T> = T extends string
|
|
46
|
+
// ? 'string'
|
|
47
|
+
// : T extends number
|
|
48
|
+
// ? 'number'
|
|
49
|
+
// : T extends boolean
|
|
50
|
+
// ? 'boolean'
|
|
51
|
+
// : T extends undefined
|
|
52
|
+
// ? 'undefined'
|
|
53
|
+
// : T extends AnyFunction
|
|
54
|
+
// ? 'function'
|
|
55
|
+
// : 'object';
|
|
56
|
+
|
|
57
|
+
// export type JsonKeys<T> = keyof {
|
|
58
|
+
// [P in keyof T]: number
|
|
59
|
+
// }
|
|
64
60
|
|
|
65
61
|
/**
|
|
66
62
|
* A function that emits a side effect and does not return anything.
|
|
67
63
|
*/
|
|
68
|
-
export type Procedure = (...args: any[]) => void;
|
|
69
|
-
|
|
70
|
-
export type DebounceOptions = {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export interface DebouncedFunction<F extends Procedure> {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export type MonthKey =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
export type Month = { [key in MonthKey]: string }
|
|
96
|
-
|
|
97
|
-
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
98
|
-
|
|
99
|
-
export class TreeNode<T> {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
export type DeepProxyOnChange = (target: any, property: string | symbol, value: any, receiver: any, descriptor: any, result: any) => void;
|
|
164
|
-
|
|
165
|
-
export type DeepProxyOnGet = (target: any, property: string | symbol, value: any, receiver: any, descriptor: any, result: any) => void;
|
|
166
|
-
|
|
167
|
-
export type CurryFunc<T> = T extends (...args: infer Args) => infer R
|
|
168
|
-
? Args extends [infer Arg, ...infer RestArgs]
|
|
169
|
-
? (arg: Arg) => CurryFunc<(...args: RestArgs) => R>
|
|
170
|
-
: R
|
|
171
|
-
: T;
|
|
64
|
+
// export type Procedure = (...args: any[]) => void;
|
|
65
|
+
|
|
66
|
+
// export type DebounceOptions = {
|
|
67
|
+
// isImmediate?: boolean;
|
|
68
|
+
// maxWait?: number;
|
|
69
|
+
// };
|
|
70
|
+
|
|
71
|
+
// export interface DebouncedFunction<F extends Procedure> {
|
|
72
|
+
// cancel: () => void;
|
|
73
|
+
//
|
|
74
|
+
// (this: ThisParameterType<F>, ...args: [...Parameters<F>]): void;
|
|
75
|
+
// }
|
|
76
|
+
|
|
77
|
+
// export type MonthKey =
|
|
78
|
+
// 'January' |
|
|
79
|
+
// 'February' |
|
|
80
|
+
// 'March' |
|
|
81
|
+
// 'April' |
|
|
82
|
+
// 'May' |
|
|
83
|
+
// 'June' |
|
|
84
|
+
// 'July' |
|
|
85
|
+
// 'August' |
|
|
86
|
+
// 'September' |
|
|
87
|
+
// 'October' |
|
|
88
|
+
// 'November' |
|
|
89
|
+
// 'December';
|
|
90
|
+
|
|
91
|
+
// export type Month = { [key in MonthKey]: string }
|
|
92
|
+
|
|
93
|
+
// export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
94
|
+
|
|
95
|
+
// export class TreeNode<T> {
|
|
96
|
+
// id: string;
|
|
97
|
+
// name?: string | undefined;
|
|
98
|
+
// value?: T | undefined;
|
|
99
|
+
// children?: TreeNode<T>[] | undefined;
|
|
100
|
+
//
|
|
101
|
+
// constructor(id: string, name?: string, value?: T, children?: TreeNode<T>[]) {
|
|
102
|
+
// this.id = id;
|
|
103
|
+
// this.name = name || '';
|
|
104
|
+
// this.value = value || undefined;
|
|
105
|
+
// this.children = children || [];
|
|
106
|
+
// }
|
|
107
|
+
//
|
|
108
|
+
// addChildren(children: TreeNode<T> | TreeNode<T> []) {
|
|
109
|
+
// if (!this.children) {
|
|
110
|
+
// this.children = [];
|
|
111
|
+
// }
|
|
112
|
+
// if (children instanceof TreeNode) {
|
|
113
|
+
// this.children.push(children);
|
|
114
|
+
// } else {
|
|
115
|
+
// this.children = this.children.concat(children);
|
|
116
|
+
// }
|
|
117
|
+
// }
|
|
118
|
+
//
|
|
119
|
+
// getHeight() {
|
|
120
|
+
// // eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
121
|
+
// const beginRoot = this;
|
|
122
|
+
// let maxDepth = 1;
|
|
123
|
+
// if (beginRoot) {
|
|
124
|
+
// const bfs = (node: TreeNode<T>, level: number) => {
|
|
125
|
+
// if (level > maxDepth) {
|
|
126
|
+
// maxDepth = level;
|
|
127
|
+
// }
|
|
128
|
+
// const {children} = node;
|
|
129
|
+
// if (children) {
|
|
130
|
+
// for (let i = 0, len = children.length; i < len; i++) {
|
|
131
|
+
// bfs(children[i], level + 1);
|
|
132
|
+
// }
|
|
133
|
+
// }
|
|
134
|
+
// };
|
|
135
|
+
// bfs(beginRoot, 1);
|
|
136
|
+
// }
|
|
137
|
+
// return maxDepth;
|
|
138
|
+
// }
|
|
139
|
+
//
|
|
140
|
+
// }
|
|
141
|
+
|
|
142
|
+
// export type OrderType = 'InOrder' | 'PreOrder' | 'PostOrder'
|
|
143
|
+
|
|
144
|
+
// export type DeepProxy<T> = T extends (...args: any[]) => infer R
|
|
145
|
+
// ? (...args: [...Parameters<T>]) => DeepProxy<R>
|
|
146
|
+
// : T extends object
|
|
147
|
+
// ? { [K in keyof T]: DeepProxy<T[K]> }
|
|
148
|
+
// : T;
|
|
149
|
+
|
|
150
|
+
// export type DeepProxyOnChange = (target: any, property: string | symbol, value: any, receiver: any, descriptor: any, result: any) => void;
|
|
151
|
+
|
|
152
|
+
// export type DeepProxyOnGet = (target: any, property: string | symbol, value: any, receiver: any, descriptor: any, result: any) => void;
|
|
153
|
+
|
|
154
|
+
// export type CurryFunc<T> = T extends (...args: infer Args) => infer R
|
|
155
|
+
// ? Args extends [infer Arg, ...infer RestArgs]
|
|
156
|
+
// ? (arg: Arg) => CurryFunc<(...args: RestArgs) => R>
|
|
157
|
+
// : R
|
|
158
|
+
// : T;
|
|
172
159
|
|
|
173
160
|
|
|
174
161
|
export type ToThunkFn = () => ReturnType<TrlFn>;
|
|
@@ -176,3 +163,14 @@ export type Thunk = () => ReturnType<ToThunkFn> & { __THUNK__: Symbol };
|
|
|
176
163
|
export type TrlFn = (...args: any[]) => any;
|
|
177
164
|
export type TrlAsyncFn = (...args: any[]) => any;
|
|
178
165
|
|
|
166
|
+
// export type CaseType =
|
|
167
|
+
// 'camel'
|
|
168
|
+
// | 'snake'
|
|
169
|
+
// | 'pascal'
|
|
170
|
+
// | 'constant'
|
|
171
|
+
// | 'kebab'
|
|
172
|
+
// | 'lower'
|
|
173
|
+
// | 'title'
|
|
174
|
+
// | 'sentence'
|
|
175
|
+
// | 'path'
|
|
176
|
+
// | 'dot';
|