ddan-js 3.4.0 → 3.5.0
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/bin/ddan-js.browser.js +1 -1
- package/bin/ddan-js.js +1 -1
- package/bin/ddan-js.mjs +1 -1
- package/bin/modules/qs/index.d.ts +8 -0
- package/bin/tiny/hook.d.ts +23 -14
- package/bin/tiny/mini.d.ts +1 -0
- package/bin/tiny/utils.d.ts +20 -12
- package/bin/tiny/web.d.ts +1 -0
- package/bin/util/function.d.ts +10 -1
- package/bin/util/index.d.ts +9 -1
- package/package.json +1 -1
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { Ddan } from '../../typings';
|
|
2
|
+
/**
|
|
3
|
+
* 安全可靠的 URL 拼接函数
|
|
4
|
+
* 支持协议域名、相对路径、绝对路径 (macOS/Unix) 等场景
|
|
5
|
+
* @param parts URL 各个部分
|
|
6
|
+
* @returns 拼接后的完整 URL 字符串
|
|
7
|
+
*/
|
|
8
|
+
export declare const urlJoin: (...parts: string[]) => string;
|
|
2
9
|
declare const _default: {
|
|
3
10
|
parse: (qs: any, { sep, eq, max, multiple, uri, parseNumber, parseBoolean }?: {
|
|
4
11
|
sep?: string | undefined;
|
|
@@ -44,6 +51,7 @@ declare const _default: {
|
|
|
44
51
|
};
|
|
45
52
|
parseHost: (url: string) => Ddan.IHttpHost;
|
|
46
53
|
join: (...args: string[]) => string;
|
|
54
|
+
urlJoin: (...parts: string[]) => string;
|
|
47
55
|
shExpMatch: (text: string, pattern: string) => boolean;
|
|
48
56
|
isLocalIPAddress: (addr: string) => boolean;
|
|
49
57
|
parseFileUrl: (url: string) => {
|
package/bin/tiny/hook.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ declare const dHook: {
|
|
|
44
44
|
};
|
|
45
45
|
parseHost: (url: string) => import("..").Ddan.IHttpHost;
|
|
46
46
|
join: (...args: string[]) => string;
|
|
47
|
+
urlJoin: (...parts: string[]) => string;
|
|
47
48
|
shExpMatch: (text: string, pattern: string) => boolean;
|
|
48
49
|
isLocalIPAddress: (addr: string) => boolean;
|
|
49
50
|
parseFileUrl: (url: string) => {
|
|
@@ -65,6 +66,14 @@ declare const dHook: {
|
|
|
65
66
|
readonly I: T;
|
|
66
67
|
};
|
|
67
68
|
getset: <T_1 = any>(t?: T_1 | undefined) => import("..").Ddan.IGetset<T_1>;
|
|
69
|
+
singletonFactory: <T_2 extends new (...args: any[]) => any>(constructor: T_2) => {
|
|
70
|
+
new (...args: any[]): {
|
|
71
|
+
[x: string]: any;
|
|
72
|
+
};
|
|
73
|
+
__instance__: InstanceType<T_2>;
|
|
74
|
+
getInstance(): InstanceType<T_2>;
|
|
75
|
+
readonly I: InstanceType<T_2>;
|
|
76
|
+
} & T_2;
|
|
68
77
|
random: (max: number) => number;
|
|
69
78
|
randomRange: (min: number, max: number) => number;
|
|
70
79
|
lerp: (start: number, end: number, t: number) => number;
|
|
@@ -102,7 +111,7 @@ declare const dHook: {
|
|
|
102
111
|
jsonFormat: (jsonString: string) => string;
|
|
103
112
|
toLines: (content: string, separator?: string | RegExp) => string[];
|
|
104
113
|
sleep: (ms?: number) => Promise<unknown>;
|
|
105
|
-
run: <
|
|
114
|
+
run: <T_3 = any>(task?: import("..").Ddan.PFunction<T_3> | undefined, wait?: number) => Promise<[any, undefined] | [null, T_3]>;
|
|
106
115
|
exec: (func: import("..").Ddan.Function, taskId?: string) => import("..").Ddan.PSafeResult<any>;
|
|
107
116
|
debounce: typeof import("../modules/hook/modules/debounce").default;
|
|
108
117
|
throttle: typeof import("../modules/hook/modules/throttle").default;
|
|
@@ -113,10 +122,10 @@ declare const dHook: {
|
|
|
113
122
|
pipeline: (max?: number) => import("../modules/hook/modules/pipeline").default;
|
|
114
123
|
safeTask: (func: import("..").Ddan.Function, callback?: ((result: import("..").Ddan.SafeResult<any>) => void) | undefined) => import("../modules/hook/modules/safeTask").default;
|
|
115
124
|
pipeAsync: (func: import("..").Ddan.Function) => import("..").Ddan.PSafeResult<any>;
|
|
116
|
-
runAsync: <
|
|
125
|
+
runAsync: <T_4 = any>(func: any, opts?: {
|
|
117
126
|
pipe?: boolean | undefined;
|
|
118
127
|
mutex?: string | undefined;
|
|
119
|
-
}) => Promise<
|
|
128
|
+
}) => Promise<T_4 | undefined>;
|
|
120
129
|
anySuccess: (promises: Promise<any>[]) => Promise<boolean>;
|
|
121
130
|
bezier1: (p0: import("..").Ddan.IPoint, p1: import("..").Ddan.IPoint, t: number) => import("..").Ddan.IPoint;
|
|
122
131
|
bezier2: (p0: import("..").Ddan.IPoint, p1: import("..").Ddan.IPoint, p2: import("..").Ddan.IPoint, t: number) => import("..").Ddan.IPoint;
|
|
@@ -129,14 +138,14 @@ declare const dHook: {
|
|
|
129
138
|
logParse: (logStr: string) => string;
|
|
130
139
|
logRString: (data: any) => Promise<string>;
|
|
131
140
|
logRParse: (logStr: string) => Promise<string>;
|
|
132
|
-
to: <
|
|
133
|
-
go: <
|
|
141
|
+
to: <T_5 = any, U extends object = any>(promise: Promise<T_5>, errorExt?: object | undefined, fn?: import("..").Ddan.noop | undefined) => Promise<[null, T_5] | [U, undefined]>;
|
|
142
|
+
go: <T_6 = any>(task?: import("..").Ddan.PFunction<T_6> | undefined, fn?: import("..").Ddan.noop | undefined) => Promise<[any, undefined] | [null, T_6]>;
|
|
134
143
|
delay: (ms?: number) => Promise<unknown>;
|
|
135
|
-
safeRun: <
|
|
144
|
+
safeRun: <T_7 = any>(func: any, fn?: import("..").Ddan.noop | undefined) => Promise<[any, undefined] | [null, T_7]>;
|
|
136
145
|
toError: (value: any) => any;
|
|
137
|
-
timeout: <
|
|
138
|
-
getValueIf: <
|
|
139
|
-
resolveValue: <
|
|
146
|
+
timeout: <T_8 = any>(task?: import("..").Ddan.PFunction<T_8> | undefined, ms?: number, desc?: string) => Promise<[any, undefined] | [null, T_8]>;
|
|
147
|
+
getValueIf: <T_9 = any, F = any>(condition: boolean | (() => boolean), trueValue: T_9 | (() => T_9), falseValue?: F | (() => F) | undefined) => T_9 | F | undefined;
|
|
148
|
+
resolveValue: <T_10 = any>(value: T_10 | (() => T_10)) => T_10;
|
|
140
149
|
base64: {
|
|
141
150
|
encode: (input: string) => string;
|
|
142
151
|
decode: (base64Str: string) => string;
|
|
@@ -192,7 +201,7 @@ declare const dHook: {
|
|
|
192
201
|
bytes2hex: (bytes: Uint8Array) => string;
|
|
193
202
|
toUint32: (str: string) => Uint32Array;
|
|
194
203
|
fromUint32: (uint32: Uint32Array) => string;
|
|
195
|
-
flatten: <
|
|
204
|
+
flatten: <T_11>(data: T_11[], recursive?: boolean, list?: T_11[]) => T_11[];
|
|
196
205
|
flattenPath: (data: Record<string, any>) => Record<string, any>;
|
|
197
206
|
normalizeStructure: (data: any, prevData: any) => void;
|
|
198
207
|
diffPath: (data: Record<string, any>, prevData: Record<string, any>) => Record<string, any>;
|
|
@@ -208,12 +217,12 @@ declare const dHook: {
|
|
|
208
217
|
ignoreEmptyString?: boolean | undefined;
|
|
209
218
|
}) => any;
|
|
210
219
|
clone: (source: any, weakMap?: WeakMap<object, any>) => any;
|
|
211
|
-
cloneClass: <
|
|
212
|
-
isEqual: <
|
|
220
|
+
cloneClass: <T_12>(source: T_12) => T_12;
|
|
221
|
+
isEqual: <T_13 = any>(value: T_13, other: T_13, depth?: number) => boolean;
|
|
213
222
|
isEqualArray: (value: any[], other: any[], depth?: number) => boolean;
|
|
214
223
|
isEqualObject: (value: Record<string, any>, other: Record<string, any>, depth?: number) => boolean;
|
|
215
|
-
isEqualValue: <
|
|
224
|
+
isEqualValue: <T_14>(value: T_14, other: T_14, type: string) => boolean;
|
|
216
225
|
isEqualAB: (value: ArrayBuffer, other: ArrayBuffer) => boolean;
|
|
217
|
-
isEqualDeep: <
|
|
226
|
+
isEqualDeep: <T_15>(value: T_15, other: T_15) => boolean;
|
|
218
227
|
};
|
|
219
228
|
export default dHook;
|
package/bin/tiny/mini.d.ts
CHANGED
|
@@ -63,6 +63,7 @@ declare const dMini: {
|
|
|
63
63
|
};
|
|
64
64
|
parseHost: (url: string) => import("..").Ddan.IHttpHost;
|
|
65
65
|
join: (...args: string[]) => string;
|
|
66
|
+
urlJoin: (...parts: string[]) => string;
|
|
66
67
|
shExpMatch: (text: string, pattern: string) => boolean;
|
|
67
68
|
isLocalIPAddress: (addr: string) => boolean;
|
|
68
69
|
parseFileUrl: (url: string) => {
|
package/bin/tiny/utils.d.ts
CHANGED
|
@@ -10,6 +10,14 @@ declare const dUtil: {
|
|
|
10
10
|
readonly I: T;
|
|
11
11
|
};
|
|
12
12
|
getset: <T_1 = any>(t?: T_1 | undefined) => import("..").Ddan.IGetset<T_1>;
|
|
13
|
+
singletonFactory: <T_2 extends new (...args: any[]) => any>(constructor: T_2) => {
|
|
14
|
+
new (...args: any[]): {
|
|
15
|
+
[x: string]: any;
|
|
16
|
+
};
|
|
17
|
+
__instance__: InstanceType<T_2>;
|
|
18
|
+
getInstance(): InstanceType<T_2>;
|
|
19
|
+
readonly I: InstanceType<T_2>;
|
|
20
|
+
} & T_2;
|
|
13
21
|
copy: (source: any, options?: {
|
|
14
22
|
fields?: string[] | undefined;
|
|
15
23
|
camel?: boolean | undefined;
|
|
@@ -22,7 +30,7 @@ declare const dUtil: {
|
|
|
22
30
|
number?: boolean | undefined;
|
|
23
31
|
boolean?: boolean | undefined;
|
|
24
32
|
}) => any;
|
|
25
|
-
cloneClass: <
|
|
33
|
+
cloneClass: <T_3>(source: T_3) => T_3;
|
|
26
34
|
combine: (target: any, source: any, options?: import("..").Ddan.IIgnoreParams) => any;
|
|
27
35
|
combines: (objs: any[], options?: import("..").Ddan.IIgnoreParams) => {};
|
|
28
36
|
observe: (obj: any, key: any, watchFun: any, owner: any, deep?: boolean) => void;
|
|
@@ -108,7 +116,7 @@ declare const dUtil: {
|
|
|
108
116
|
bytes2hex: (bytes: Uint8Array) => string;
|
|
109
117
|
toUint32: (str: string) => Uint32Array;
|
|
110
118
|
fromUint32: (uint32: Uint32Array) => string;
|
|
111
|
-
flatten: <
|
|
119
|
+
flatten: <T_4>(data: T_4[], recursive?: boolean, list?: T_4[]) => T_4[];
|
|
112
120
|
gbk: {
|
|
113
121
|
gbkLength: (str: string) => number;
|
|
114
122
|
gbkCut: (source: string, len: number) => string;
|
|
@@ -135,16 +143,16 @@ declare const dUtil: {
|
|
|
135
143
|
};
|
|
136
144
|
};
|
|
137
145
|
list: {
|
|
138
|
-
stepAction: <
|
|
139
|
-
skip: <
|
|
140
|
-
take: <
|
|
141
|
-
distinct: <
|
|
142
|
-
randoms: <
|
|
146
|
+
stepAction: <T_5>(list: T_5[], func: import("..").Ddan.Task<T_5, void>, stepCount?: number) => void;
|
|
147
|
+
skip: <T_6>(list: T_6[], count: number) => T_6[];
|
|
148
|
+
take: <T_7>(list: T_7[], count: number, skip?: number) => T_7[];
|
|
149
|
+
distinct: <T_8>(list: T_8[]) => T_8[];
|
|
150
|
+
randoms: <T_9>(list: T_9[], count?: number, repeat?: boolean) => T_9[];
|
|
143
151
|
toKV: (list: import("..").Ddan.KV<any>[], key: string, value: string) => import("..").Ddan.KV<any>;
|
|
144
|
-
groupBy: <
|
|
145
|
-
first: <
|
|
146
|
-
last: <
|
|
147
|
-
toList: <
|
|
152
|
+
groupBy: <T_10>(list: T_10[], key: string) => Record<string, T_10[]>;
|
|
153
|
+
first: <T_11>(list: T_11[]) => T_11 | undefined;
|
|
154
|
+
last: <T_12>(list: T_12[]) => T_12 | undefined;
|
|
155
|
+
toList: <T_13>(val: T_13 | T_13[]) => T_13[];
|
|
148
156
|
};
|
|
149
157
|
string: {
|
|
150
158
|
toString: (value: any) => any;
|
|
@@ -206,7 +214,7 @@ declare const dUtil: {
|
|
|
206
214
|
number?: boolean | undefined;
|
|
207
215
|
boolean?: boolean | undefined;
|
|
208
216
|
}) => any;
|
|
209
|
-
cloneClass: <
|
|
217
|
+
cloneClass: <T_3>(source: T_3) => T_3;
|
|
210
218
|
combine: (target: any, source: any, options?: import("..").Ddan.IIgnoreParams) => any;
|
|
211
219
|
combines: (objs: any[], options?: import("..").Ddan.IIgnoreParams) => {};
|
|
212
220
|
observe: (obj: any, key: any, watchFun: any, owner: any, deep?: boolean) => void;
|
package/bin/tiny/web.d.ts
CHANGED
|
@@ -72,6 +72,7 @@ declare const dWeb: {
|
|
|
72
72
|
};
|
|
73
73
|
parseHost: (url: string) => import("..").Ddan.IHttpHost;
|
|
74
74
|
join: (...args: string[]) => string;
|
|
75
|
+
urlJoin: (...parts: string[]) => string;
|
|
75
76
|
shExpMatch: (text: string, pattern: string) => boolean;
|
|
76
77
|
isLocalIPAddress: (addr: string) => boolean;
|
|
77
78
|
parseFileUrl: (url: string) => {
|
package/bin/util/function.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ddan } from
|
|
1
|
+
import { Ddan } from '../typings';
|
|
2
2
|
/**
|
|
3
3
|
* 设置单例模式
|
|
4
4
|
* @returns
|
|
@@ -9,9 +9,18 @@ declare function singleton<T>(): {
|
|
|
9
9
|
readonly Instance: T;
|
|
10
10
|
readonly I: T;
|
|
11
11
|
};
|
|
12
|
+
declare function singletonFactory<T extends new (...args: any[]) => any>(constructor: T): {
|
|
13
|
+
new (...args: any[]): {
|
|
14
|
+
[x: string]: any;
|
|
15
|
+
};
|
|
16
|
+
__instance__: InstanceType<T>;
|
|
17
|
+
getInstance(): InstanceType<T>;
|
|
18
|
+
readonly I: InstanceType<T>;
|
|
19
|
+
} & T;
|
|
12
20
|
declare function getset<T = any>(t?: T): Ddan.IGetset<T>;
|
|
13
21
|
declare const _default: {
|
|
14
22
|
singleton: typeof singleton;
|
|
15
23
|
getset: typeof getset;
|
|
24
|
+
singletonFactory: typeof singletonFactory;
|
|
16
25
|
};
|
|
17
26
|
export default _default;
|
package/bin/util/index.d.ts
CHANGED
|
@@ -9,6 +9,14 @@ declare const _default: {
|
|
|
9
9
|
readonly I: T;
|
|
10
10
|
};
|
|
11
11
|
getset: <T_1 = any>(t?: T_1 | undefined) => import("..").Ddan.IGetset<T_1>;
|
|
12
|
+
singletonFactory: <T_2 extends new (...args: any[]) => any>(constructor: T_2) => {
|
|
13
|
+
new (...args: any[]): {
|
|
14
|
+
[x: string]: any;
|
|
15
|
+
};
|
|
16
|
+
__instance__: InstanceType<T_2>;
|
|
17
|
+
getInstance(): InstanceType<T_2>;
|
|
18
|
+
readonly I: InstanceType<T_2>;
|
|
19
|
+
} & T_2;
|
|
12
20
|
copy: (source: any, options?: {
|
|
13
21
|
fields?: string[] | undefined;
|
|
14
22
|
camel?: boolean | undefined;
|
|
@@ -21,7 +29,7 @@ declare const _default: {
|
|
|
21
29
|
number?: boolean | undefined;
|
|
22
30
|
boolean?: boolean | undefined;
|
|
23
31
|
}) => any;
|
|
24
|
-
cloneClass: <
|
|
32
|
+
cloneClass: <T_3>(source: T_3) => T_3;
|
|
25
33
|
combine: (target: any, source: any, options?: import("..").Ddan.IIgnoreParams) => any;
|
|
26
34
|
combines: (objs: any[], options?: import("..").Ddan.IIgnoreParams) => {};
|
|
27
35
|
observe: (obj: any, key: any, watchFun: any, owner: any, deep?: boolean) => void;
|