data-structure-typed 0.8.6 → 0.8.17
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/data-structures/binary-tree/aa-tree.d.ts +2 -0
- package/dist/data-structures/binary-tree/avl-tree.d.ts +21 -0
- package/dist/data-structures/binary-tree/b-tree.d.ts +2 -0
- package/dist/data-structures/binary-tree/binary-indexed-tree.d.ts +8 -0
- package/dist/data-structures/binary-tree/binary-tree.d.ts +140 -0
- package/dist/data-structures/binary-tree/bst.d.ts +32 -0
- package/dist/data-structures/binary-tree/index.d.ts +4 -0
- package/dist/data-structures/binary-tree/rb-tree.d.ts +2 -0
- package/dist/data-structures/binary-tree/segment-tree.d.ts +33 -0
- package/dist/data-structures/binary-tree/splay-tree.d.ts +2 -0
- package/dist/data-structures/binary-tree/tree-multiset.d.ts +11 -0
- package/dist/data-structures/binary-tree/two-three-tree.d.ts +2 -0
- package/dist/data-structures/graph/abstract-graph.d.ts +126 -0
- package/dist/data-structures/graph/directed-graph.d.ts +51 -0
- package/dist/data-structures/graph/index.d.ts +3 -0
- package/dist/data-structures/graph/undirected-graph.d.ts +24 -0
- package/dist/data-structures/hash/coordinate-map.d.ts +8 -0
- package/dist/data-structures/hash/coordinate-set.d.ts +7 -0
- package/dist/data-structures/hash/hash-table.d.ts +1 -0
- package/dist/data-structures/hash/index.d.ts +1 -0
- package/dist/data-structures/hash/pair.d.ts +1 -0
- package/dist/data-structures/hash/tree-map.d.ts +1 -0
- package/dist/data-structures/hash/tree-set.d.ts +1 -0
- package/dist/data-structures/heap/heap.d.ts +72 -0
- package/dist/data-structures/heap/index.d.ts +3 -0
- package/dist/data-structures/heap/max-heap.d.ts +14 -0
- package/dist/data-structures/heap/min-heap.d.ts +14 -0
- package/dist/data-structures/index.d.ts +9 -0
- package/dist/data-structures/linked-list/doubly-linked-list.d.ts +59 -0
- package/dist/data-structures/linked-list/index.d.ts +2 -0
- package/dist/data-structures/linked-list/singly-linked-list.d.ts +358 -0
- package/dist/data-structures/linked-list/skip-linked-list.d.ts +1 -0
- package/dist/data-structures/matrix/index.d.ts +4 -0
- package/dist/data-structures/matrix/index.js +1 -0
- package/dist/data-structures/matrix/matrix.d.ts +9 -0
- package/dist/data-structures/matrix/matrix2d.d.ts +25 -0
- package/dist/data-structures/matrix/navigator.d.ts +31 -0
- package/dist/data-structures/matrix/vector2d.d.ts +74 -0
- package/dist/data-structures/priority-queue/index.d.ts +3 -0
- package/dist/data-structures/priority-queue/max-priority-queue.d.ts +4 -0
- package/dist/data-structures/priority-queue/min-priority-queue.d.ts +4 -0
- package/dist/data-structures/priority-queue/priority-queue.d.ts +36 -0
- package/dist/data-structures/queue/deque.d.ts +37 -0
- package/dist/data-structures/queue/index.d.ts +1 -0
- package/dist/data-structures/queue/queue.d.ts +76 -0
- package/dist/data-structures/stack/index.d.ts +1 -0
- package/dist/data-structures/stack/stack.d.ts +69 -0
- package/dist/data-structures/trampoline.d.ts +25 -0
- package/dist/data-structures/trie/index.d.ts +1 -0
- package/dist/data-structures/trie/trie.d.ts +28 -0
- package/dist/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils.d.ts +37 -113
- package/dist/utils.d.ts +122 -0
- package/package.json +4 -3
- package/src/data-structures/matrix/index.ts +1 -0
- package/tsconfig.json +3 -2
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
* @copyright 2020 Pablo
|
|
4
|
+
*
|
|
5
|
+
* @class
|
|
6
|
+
*/
|
|
7
|
+
export declare class Queue<T> {
|
|
8
|
+
protected _nodes: T[];
|
|
9
|
+
protected _offset: number;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a queue.
|
|
12
|
+
* @param {array} [elements]
|
|
13
|
+
*/
|
|
14
|
+
constructor(elements?: T[]);
|
|
15
|
+
/**
|
|
16
|
+
* Adds an element at the back of the queue.
|
|
17
|
+
* @public
|
|
18
|
+
* @param {any} element
|
|
19
|
+
*/
|
|
20
|
+
offer(element: T): Queue<T>;
|
|
21
|
+
/**
|
|
22
|
+
* Dequeues the front element in the queue.
|
|
23
|
+
* @public
|
|
24
|
+
* @returns {any}
|
|
25
|
+
*/
|
|
26
|
+
poll(): T | null;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the front element of the queue.
|
|
29
|
+
* @public
|
|
30
|
+
* @returns {any}
|
|
31
|
+
*/
|
|
32
|
+
peek(): T | null;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the back element of the queue.
|
|
35
|
+
* @public
|
|
36
|
+
* @returns {any}
|
|
37
|
+
*/
|
|
38
|
+
peekLast(): T | null;
|
|
39
|
+
/**
|
|
40
|
+
* Returns the number of elements in the queue.
|
|
41
|
+
* @public
|
|
42
|
+
* @returns {number}
|
|
43
|
+
*/
|
|
44
|
+
size(): number;
|
|
45
|
+
/**
|
|
46
|
+
* Checks if the queue is empty.
|
|
47
|
+
* @public
|
|
48
|
+
* @returns {boolean}
|
|
49
|
+
*/
|
|
50
|
+
isEmpty(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the remaining elements in the queue as an array.
|
|
53
|
+
* @public
|
|
54
|
+
* @returns {array}
|
|
55
|
+
*/
|
|
56
|
+
toArray(): T[];
|
|
57
|
+
/**
|
|
58
|
+
* Clears the queue.
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
clear(): void;
|
|
62
|
+
/**
|
|
63
|
+
* Creates a shallow copy of the queue.
|
|
64
|
+
* @public
|
|
65
|
+
* @return {Queue}
|
|
66
|
+
*/
|
|
67
|
+
clone(): Queue<T>;
|
|
68
|
+
/**
|
|
69
|
+
* Creates a queue from an existing array.
|
|
70
|
+
* @public
|
|
71
|
+
* @static
|
|
72
|
+
* @param {array} elements
|
|
73
|
+
* @return {Queue}
|
|
74
|
+
*/
|
|
75
|
+
static fromArray<T>(elements: T[]): Queue<T>;
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './stack';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
* @copyright 2020 Pablo Rios <zrwusa@gmail.com>
|
|
4
|
+
*
|
|
5
|
+
* @class
|
|
6
|
+
*/
|
|
7
|
+
export declare class Stack<T> {
|
|
8
|
+
protected _elements: T[];
|
|
9
|
+
/**
|
|
10
|
+
* Creates a stack.
|
|
11
|
+
* @param {array} [elements]
|
|
12
|
+
*/
|
|
13
|
+
constructor(elements?: T[]);
|
|
14
|
+
/**
|
|
15
|
+
* Checks if the stack is empty.
|
|
16
|
+
* @public
|
|
17
|
+
* @returns {boolean}
|
|
18
|
+
*/
|
|
19
|
+
isEmpty(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the number of elements in the stack.
|
|
22
|
+
* @public
|
|
23
|
+
* @returns {number}
|
|
24
|
+
*/
|
|
25
|
+
size(): number;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the top element in the stack.
|
|
28
|
+
* @public
|
|
29
|
+
* @returns {object}
|
|
30
|
+
*/
|
|
31
|
+
peek(): T | null;
|
|
32
|
+
/**
|
|
33
|
+
* Adds an element to the top of the stack.
|
|
34
|
+
* @public
|
|
35
|
+
* @param {object} element
|
|
36
|
+
*/
|
|
37
|
+
push(element: T): Stack<T>;
|
|
38
|
+
/**
|
|
39
|
+
* Removes and returns the top element in the stack.
|
|
40
|
+
* @public
|
|
41
|
+
* @returns {object}
|
|
42
|
+
*/
|
|
43
|
+
pop(): T | null;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the remaining elements as an array.
|
|
46
|
+
* @public
|
|
47
|
+
* @returns {array}
|
|
48
|
+
*/
|
|
49
|
+
toArray(): T[];
|
|
50
|
+
/**
|
|
51
|
+
* Clears all elements from the stack.
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
clear(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Creates a shallow copy from the stack.
|
|
57
|
+
* @public
|
|
58
|
+
* @return {Stack}
|
|
59
|
+
*/
|
|
60
|
+
clone(): Stack<T>;
|
|
61
|
+
/**
|
|
62
|
+
* Creates a stack from an existing array
|
|
63
|
+
* @public
|
|
64
|
+
* @static
|
|
65
|
+
* @param {array} [elements]
|
|
66
|
+
* @return {Stack}
|
|
67
|
+
*/
|
|
68
|
+
static fromArray<T>(elements: T[]): Stack<T>;
|
|
69
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type ArgumentTypes<T extends (...args: any[]) => any> = T extends (...args: infer A) => any ? A : never;
|
|
2
|
+
export declare const THUNK_SYMBOL: unique symbol;
|
|
3
|
+
export interface Thunk<T> extends Function {
|
|
4
|
+
__THUNK__: typeof THUNK_SYMBOL;
|
|
5
|
+
(): T;
|
|
6
|
+
}
|
|
7
|
+
export type ThunkOrValue<T> = T | Thunk<T>;
|
|
8
|
+
export type UnwrapThunkDeep<T> = {
|
|
9
|
+
0: T extends Thunk<infer U> ? UnwrapThunkDeep<U> : T;
|
|
10
|
+
}[T extends ThunkOrValue<T> ? 0 : never];
|
|
11
|
+
export declare const isThunk: <T>(value: any) => value is Thunk<T>;
|
|
12
|
+
export declare const toThunk: <R>(fn: () => R) => Thunk<R>;
|
|
13
|
+
export type UnwrapPromise<T> = T extends Promise<infer U> ? Exclude<U, Promise<T>> : T;
|
|
14
|
+
export type Unbox<T> = UnwrapThunkDeep<UnwrapPromise<T>>;
|
|
15
|
+
export type Cont<A extends any[], R> = (...args: A) => Thunk<Unbox<R>>;
|
|
16
|
+
export interface Trampoline<F extends ((...args: any[]) => any)> {
|
|
17
|
+
(...args: ArgumentTypes<F>): Unbox<ReturnType<F>>;
|
|
18
|
+
cont: Cont<ArgumentTypes<F>, ReturnType<F>>;
|
|
19
|
+
}
|
|
20
|
+
export interface TrampolineAsync<F extends ((...args: any[]) => any)> {
|
|
21
|
+
(...args: ArgumentTypes<F>): Promise<Unbox<ReturnType<F>>>;
|
|
22
|
+
cont: Cont<ArgumentTypes<F>, ReturnType<F>>;
|
|
23
|
+
}
|
|
24
|
+
export declare const trampoline: <F extends (...args: any[]) => any>(fn: F) => Trampoline<F>;
|
|
25
|
+
export declare const trampolineAsync: <F extends (...args: any[]) => any>(fn: F) => TrampolineAsync<F>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './trie';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare class TrieNode {
|
|
2
|
+
protected _children: Map<string, TrieNode>;
|
|
3
|
+
get children(): Map<string, TrieNode>;
|
|
4
|
+
set children(v: Map<string, TrieNode>);
|
|
5
|
+
protected _isEnd: boolean;
|
|
6
|
+
get isEnd(): boolean;
|
|
7
|
+
set isEnd(v: boolean);
|
|
8
|
+
}
|
|
9
|
+
export declare class Trie {
|
|
10
|
+
protected _root: TrieNode;
|
|
11
|
+
get root(): TrieNode;
|
|
12
|
+
set root(v: TrieNode);
|
|
13
|
+
constructor();
|
|
14
|
+
put(input: string): boolean;
|
|
15
|
+
has(input: string): boolean;
|
|
16
|
+
remove(word: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Only can present as a prefix, not a word
|
|
19
|
+
* @param input
|
|
20
|
+
*/
|
|
21
|
+
isAbsPrefix(input: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Can present as a prefix or word
|
|
24
|
+
* @param input
|
|
25
|
+
*/
|
|
26
|
+
isPrefix(input: string): boolean;
|
|
27
|
+
getAll(prefix?: string): string[];
|
|
28
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './data-structures';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './utils';
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
export type AnyFunction<A extends any[] = any[], R = any> = (...args: A) => R;
|
|
2
|
+
export type Primitive = number | string | boolean | symbol | undefined | null | void | AnyFunction | Date;
|
|
3
|
+
export type Cast<T, TComplex> = {
|
|
4
|
+
[M in keyof TComplex]: T;
|
|
5
|
+
};
|
|
6
|
+
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> : {
|
|
7
|
+
[K in keyof T]: T[K] extends (infer U)[] ? DeepLeavesWrap<U, TComplex>[] : DeepLeavesWrap<T[K], TComplex>;
|
|
8
|
+
};
|
|
2
9
|
export type JSONSerializable = {
|
|
3
10
|
[key: string]: any;
|
|
4
11
|
};
|
|
@@ -6,117 +13,34 @@ export type JSONValue = string | number | boolean | undefined | JSONObject;
|
|
|
6
13
|
export interface JSONObject {
|
|
7
14
|
[key: string]: JSONValue;
|
|
8
15
|
}
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export declare const isTypeEqual: <T>(obj: unknown) => void;
|
|
25
|
-
export declare function reverseColor(oldColor: string): string;
|
|
26
|
-
export declare const isSameStructure: (objA: unknown, objB: unknown) => boolean;
|
|
27
|
-
export declare const isLeafParent: (obj: JSONObject) => boolean;
|
|
28
|
-
export declare const addDays: (date: Date, days: number) => Date;
|
|
29
|
-
export declare class WaitManager {
|
|
30
|
-
private _time1;
|
|
31
|
-
get time1(): number;
|
|
32
|
-
private _time2;
|
|
33
|
-
get time2(): number;
|
|
34
|
-
private _time3;
|
|
35
|
-
get time3(): number;
|
|
36
|
-
private _time4;
|
|
37
|
-
get time4(): number;
|
|
38
|
-
private _time10;
|
|
39
|
-
get time10(): number;
|
|
40
|
-
private _time20;
|
|
41
|
-
get time20(): number;
|
|
42
|
-
private _time30;
|
|
43
|
-
get time50(): number;
|
|
44
|
-
private _time60;
|
|
45
|
-
get time60(): number;
|
|
46
|
-
private _cusTime;
|
|
47
|
-
get cusTime(): number;
|
|
48
|
-
set cusTime(v: number);
|
|
49
|
-
private readonly _nXSpeed;
|
|
50
|
-
constructor(nXSpeed?: number);
|
|
51
|
-
}
|
|
52
|
-
export declare const wait: (ms: number, resolveValue?: any) => Promise<unknown>;
|
|
53
|
-
export declare class AuthAPIError extends Error {
|
|
54
|
-
protected serverErrorStack: string | undefined;
|
|
55
|
-
protected serverErrorCode: string | undefined;
|
|
56
|
-
constructor(serverErrorMessage: string, serverErrorCode?: string, serverErrorStack?: string);
|
|
57
|
-
}
|
|
58
|
-
export declare class BunnyAPIError extends Error {
|
|
59
|
-
protected serverErrorStack: string | undefined;
|
|
60
|
-
protected serverErrorCode: string | undefined;
|
|
61
|
-
constructor(serverErrorMessage: string, serverErrorCode?: string, serverErrorStack?: string);
|
|
62
|
-
}
|
|
63
|
-
export declare class NomicsAPIError extends Error {
|
|
64
|
-
protected serverErrorStack: string | undefined;
|
|
65
|
-
protected serverErrorCode: string | undefined;
|
|
66
|
-
constructor(serverErrorMessage: string, serverErrorCode?: string, serverErrorStack?: string);
|
|
67
|
-
}
|
|
68
|
-
export declare function extractValue<Item>(data: {
|
|
69
|
-
key: string;
|
|
70
|
-
value: Item;
|
|
71
|
-
}[]): Item[];
|
|
72
|
-
export declare function keyValueToArray<Item>(data: {
|
|
73
|
-
[key: string]: Item;
|
|
74
|
-
}): Item[];
|
|
75
|
-
export declare function minuted(time: number): string;
|
|
76
|
-
export declare function randomDate(start?: Date, end?: Date, specificProbabilityStart?: Date, specificProbability?: number): Date;
|
|
77
|
-
export declare const capitalizeWords: (str: string) => string;
|
|
78
|
-
export declare const capitalizeFirstLetter: (str: string) => string;
|
|
79
|
-
export declare const comparerArray: <T>(otherArray: T[], limitKeys?: string[]) => (current: T) => boolean;
|
|
80
|
-
export declare const onlyInA: <T>(a: T[], b: T[]) => T[];
|
|
81
|
-
export declare const onlyInB: <T>(a: T[], b: T[]) => T[];
|
|
82
|
-
export declare const diffAB: <T>(a: T[], b: T[]) => T[];
|
|
83
|
-
export declare class StringUtil {
|
|
84
|
-
static toCamelCase(str: string): string;
|
|
85
|
-
static toSnakeCase(str: string): string;
|
|
86
|
-
static toPascalCase(str: string): string;
|
|
87
|
-
static toConstantCase(str: string): string;
|
|
88
|
-
static toKebabCase(str: string): string;
|
|
89
|
-
static toLowerCase(str: string): string;
|
|
90
|
-
static toTitleCase(str: string): string;
|
|
91
|
-
static toSentenceCase(str: string): string;
|
|
92
|
-
static toPathCase(str: string): string;
|
|
93
|
-
static toDotCase(str: string): string;
|
|
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
|
+
(this: ThisParameterType<F>, ...args: Parameters<F>): void;
|
|
30
|
+
cancel: () => void;
|
|
94
31
|
}
|
|
95
|
-
type
|
|
96
|
-
export
|
|
97
|
-
|
|
98
|
-
export declare const deepRenameKeys: (obj: JSONSerializable, keysMap: {
|
|
99
|
-
[x: string]: string;
|
|
100
|
-
}) => JSONSerializable;
|
|
101
|
-
export declare const deepReplaceValues: (obj: JSONSerializable, keyReducerMap: {
|
|
102
|
-
[x: string]: (item: JSONSerializable) => any;
|
|
103
|
-
}) => JSONSerializable;
|
|
104
|
-
export declare const deepAdd: (obj: JSONSerializable, keyReducerMap: {
|
|
105
|
-
[x: string]: (item: JSONSerializable) => any;
|
|
106
|
-
}, isItemRootParent?: boolean) => [] | JSONObject;
|
|
107
|
-
export declare const bunnyConsole: {
|
|
108
|
-
log: (headerLog?: string, ...args: any[]) => void;
|
|
109
|
-
warn: (headerLog?: string, ...args: any[]) => void;
|
|
110
|
-
error: (headerLog?: string, ...args: any[]) => void;
|
|
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;
|
|
111
35
|
};
|
|
112
|
-
export
|
|
113
|
-
export declare
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
export
|
|
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';
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { AnyFunction } from './types';
|
|
2
|
+
export type JSONSerializable = {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
};
|
|
5
|
+
export type JSONValue = string | number | boolean | undefined | JSONObject;
|
|
6
|
+
export interface JSONObject {
|
|
7
|
+
[key: string]: JSONValue;
|
|
8
|
+
}
|
|
9
|
+
export declare function randomText(length: number): string;
|
|
10
|
+
export declare const uuidV4: () => string;
|
|
11
|
+
export declare class IncrementId {
|
|
12
|
+
private _id;
|
|
13
|
+
private readonly _prefix;
|
|
14
|
+
constructor(prefix?: string);
|
|
15
|
+
getId(): string;
|
|
16
|
+
}
|
|
17
|
+
export declare function incrementId(prefix?: string): () => string;
|
|
18
|
+
export declare const getValue: <T, K extends keyof T>(obj: T, names: K[]) => T[K][];
|
|
19
|
+
export declare const isObject: (object: string | JSONObject | boolean | AnyFunction | number) => boolean;
|
|
20
|
+
export declare const looseEqual: (a: any, b: any) => boolean;
|
|
21
|
+
export declare const strictEqual: (a: any, b: any) => boolean;
|
|
22
|
+
export declare const strictObjectIsEqual: (a: any, b: any) => boolean;
|
|
23
|
+
export declare const deepObjectStrictEqual: (object1: JSONSerializable, object2: JSONSerializable) => boolean;
|
|
24
|
+
export declare const isTypeEqual: <T>(obj: unknown) => void;
|
|
25
|
+
export declare function reverseColor(oldColor: string): string;
|
|
26
|
+
export declare const isSameStructure: (objA: unknown, objB: unknown) => boolean;
|
|
27
|
+
export declare const isLeafParent: (obj: JSONObject) => boolean;
|
|
28
|
+
export declare const addDays: (date: Date, days: number) => Date;
|
|
29
|
+
export declare class WaitManager {
|
|
30
|
+
private _time1;
|
|
31
|
+
get time1(): number;
|
|
32
|
+
private _time2;
|
|
33
|
+
get time2(): number;
|
|
34
|
+
private _time3;
|
|
35
|
+
get time3(): number;
|
|
36
|
+
private _time4;
|
|
37
|
+
get time4(): number;
|
|
38
|
+
private _time10;
|
|
39
|
+
get time10(): number;
|
|
40
|
+
private _time20;
|
|
41
|
+
get time20(): number;
|
|
42
|
+
private _time30;
|
|
43
|
+
get time50(): number;
|
|
44
|
+
private _time60;
|
|
45
|
+
get time60(): number;
|
|
46
|
+
private _cusTime;
|
|
47
|
+
get cusTime(): number;
|
|
48
|
+
set cusTime(v: number);
|
|
49
|
+
private readonly _nXSpeed;
|
|
50
|
+
constructor(nXSpeed?: number);
|
|
51
|
+
}
|
|
52
|
+
export declare const wait: (ms: number, resolveValue?: any) => Promise<unknown>;
|
|
53
|
+
export declare class AuthAPIError extends Error {
|
|
54
|
+
protected serverErrorStack: string | undefined;
|
|
55
|
+
protected serverErrorCode: string | undefined;
|
|
56
|
+
constructor(serverErrorMessage: string, serverErrorCode?: string, serverErrorStack?: string);
|
|
57
|
+
}
|
|
58
|
+
export declare class BunnyAPIError extends Error {
|
|
59
|
+
protected serverErrorStack: string | undefined;
|
|
60
|
+
protected serverErrorCode: string | undefined;
|
|
61
|
+
constructor(serverErrorMessage: string, serverErrorCode?: string, serverErrorStack?: string);
|
|
62
|
+
}
|
|
63
|
+
export declare class NomicsAPIError extends Error {
|
|
64
|
+
protected serverErrorStack: string | undefined;
|
|
65
|
+
protected serverErrorCode: string | undefined;
|
|
66
|
+
constructor(serverErrorMessage: string, serverErrorCode?: string, serverErrorStack?: string);
|
|
67
|
+
}
|
|
68
|
+
export declare function extractValue<Item>(data: {
|
|
69
|
+
key: string;
|
|
70
|
+
value: Item;
|
|
71
|
+
}[]): Item[];
|
|
72
|
+
export declare function keyValueToArray<Item>(data: {
|
|
73
|
+
[key: string]: Item;
|
|
74
|
+
}): Item[];
|
|
75
|
+
export declare function minuted(time: number): string;
|
|
76
|
+
export declare function randomDate(start?: Date, end?: Date, specificProbabilityStart?: Date, specificProbability?: number): Date;
|
|
77
|
+
export declare const capitalizeWords: (str: string) => string;
|
|
78
|
+
export declare const capitalizeFirstLetter: (str: string) => string;
|
|
79
|
+
export declare const comparerArray: <T>(otherArray: T[], limitKeys?: string[]) => (current: T) => boolean;
|
|
80
|
+
export declare const onlyInA: <T>(a: T[], b: T[]) => T[];
|
|
81
|
+
export declare const onlyInB: <T>(a: T[], b: T[]) => T[];
|
|
82
|
+
export declare const diffAB: <T>(a: T[], b: T[]) => T[];
|
|
83
|
+
export declare class StringUtil {
|
|
84
|
+
static toCamelCase(str: string): string;
|
|
85
|
+
static toSnakeCase(str: string): string;
|
|
86
|
+
static toPascalCase(str: string): string;
|
|
87
|
+
static toConstantCase(str: string): string;
|
|
88
|
+
static toKebabCase(str: string): string;
|
|
89
|
+
static toLowerCase(str: string): string;
|
|
90
|
+
static toTitleCase(str: string): string;
|
|
91
|
+
static toSentenceCase(str: string): string;
|
|
92
|
+
static toPathCase(str: string): string;
|
|
93
|
+
static toDotCase(str: string): string;
|
|
94
|
+
}
|
|
95
|
+
type ToCase = 'camel' | 'snake' | 'pascal' | 'constant' | 'kebab' | 'lower' | 'title' | 'sentence' | 'path' | 'dot';
|
|
96
|
+
export declare const deepKeysConvert: (obj: any, toType?: ToCase) => any;
|
|
97
|
+
export declare const deepRemoveByKey: (obj: any, keysToBeRemoved: string[]) => any;
|
|
98
|
+
export declare const deepRenameKeys: (obj: JSONSerializable, keysMap: {
|
|
99
|
+
[x: string]: string;
|
|
100
|
+
}) => JSONSerializable;
|
|
101
|
+
export declare const deepReplaceValues: (obj: JSONSerializable, keyReducerMap: {
|
|
102
|
+
[x: string]: (item: JSONSerializable) => any;
|
|
103
|
+
}) => JSONSerializable;
|
|
104
|
+
export declare const deepAdd: (obj: JSONSerializable, keyReducerMap: {
|
|
105
|
+
[x: string]: (item: JSONSerializable) => any;
|
|
106
|
+
}, isItemRootParent?: boolean) => [] | JSONObject;
|
|
107
|
+
export declare const bunnyConsole: {
|
|
108
|
+
log: (headerLog?: string, ...args: any[]) => void;
|
|
109
|
+
warn: (headerLog?: string, ...args: any[]) => void;
|
|
110
|
+
error: (headerLog?: string, ...args: any[]) => void;
|
|
111
|
+
};
|
|
112
|
+
export declare const timeStart: () => number;
|
|
113
|
+
export declare const timeEnd: (startTime: number, headerLog?: string, consoleConditionFn?: ((timeSpent: number) => boolean) | undefined) => void;
|
|
114
|
+
export declare const arrayRemove: <T>(array: T[], predicate: (item: T, index: number, array: T[]) => boolean) => T[];
|
|
115
|
+
export declare function memo(): (target: Object, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
116
|
+
export declare function zip<T = number, T1 = number>(array1: T[], array2: T1[], options?: {
|
|
117
|
+
isToObj: boolean;
|
|
118
|
+
}): [T, T1][] | {
|
|
119
|
+
x: T;
|
|
120
|
+
y: T1;
|
|
121
|
+
}[];
|
|
122
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "data-structure-typed",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.17",
|
|
4
4
|
"description": "Hash (CoordinateSet, CoordinateMap) Heap (MaxHeap, MinHeap) Binary Tree (AVL Tree, Binary Indexed Tree, Binary Search Tree, Segment Tree, Tree Multiset) Graph (Directed Graph, Undirected Graph) Linked List (Singly Linked List, Doubly Linked List) Matrix Priority Queue (Max Priority Queue, Min Priority Queue) Queue (Queue, Dequeue) Stack Trie",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -62,9 +62,10 @@
|
|
|
62
62
|
"author": "Tyler Zeng",
|
|
63
63
|
"license": "ISC",
|
|
64
64
|
"bugs": {
|
|
65
|
-
"url": "https://github.com/zrwusa/data-structure-
|
|
65
|
+
"url": "https://github.com/zrwusa/data-structure-typed/issues"
|
|
66
66
|
},
|
|
67
|
-
"homepage": "https://github.com/zrwusa/data-structure-
|
|
67
|
+
"homepage": "https://github.com/zrwusa/data-structure-typed#readme",
|
|
68
|
+
"types": "dist/index.d.ts",
|
|
68
69
|
"devDependencies": {
|
|
69
70
|
"@types/lodash": "^4.14.178",
|
|
70
71
|
"typescript": "^4.6.2"
|
package/tsconfig.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"strict": true,
|
|
14
14
|
"esModuleInterop": true,
|
|
15
15
|
"moduleResolution": "node",
|
|
16
|
-
"declarationDir": "./dist
|
|
16
|
+
"declarationDir": "./dist",
|
|
17
17
|
"skipLibCheck": true
|
|
18
18
|
|
|
19
19
|
// "allowJs": true,
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
// "noEmit": true,
|
|
26
26
|
},
|
|
27
27
|
"include": [
|
|
28
|
-
"src"
|
|
28
|
+
"src",
|
|
29
|
+
"node_modules/data-structure-typed"
|
|
29
30
|
],
|
|
30
31
|
"exclude": [
|
|
31
32
|
"node_modules",
|