ddan-js 2.2.1 → 2.2.3
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/lib/typings/xhao.js +2 -0
- package/bin/types/class/tracker.d.ts +2 -2
- package/bin/types/index.d.ts +4 -3
- package/bin/types/modules/hook/debounce.d.ts +3 -2
- package/bin/types/modules/hook/index.d.ts +2 -2
- package/bin/types/modules/hook/mutex.d.ts +2 -2
- package/bin/types/modules/hook/throttle.d.ts +3 -2
- package/bin/types/modules/http/index.d.ts +3 -2
- package/bin/types/modules/list/index.d.ts +3 -3
- package/bin/types/typings/index.d.ts +5 -21
- package/bin/types/typings/xhao.d.ts +17 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Xhao } from "../typings/xhao";
|
|
2
2
|
export declare class DTrack {
|
|
3
3
|
id: string;
|
|
4
4
|
/** 开始时间戳 */
|
|
@@ -41,7 +41,7 @@ export declare class DTracker {
|
|
|
41
41
|
get list(): DTrack[];
|
|
42
42
|
get size(): number;
|
|
43
43
|
_endId: (id: string) => string;
|
|
44
|
-
report(cb?:
|
|
44
|
+
report(cb?: Xhao.Func2<DTrack, number>): void;
|
|
45
45
|
}
|
|
46
46
|
declare const tracker: DTracker;
|
|
47
47
|
export default tracker;
|
package/bin/types/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import Event from "./class/event";
|
|
|
2
2
|
import Http from "./modules/http";
|
|
3
3
|
import Store from "./class/store";
|
|
4
4
|
import Persist from "./class/persist";
|
|
5
|
+
export { Xhao } from "./typings/xhao";
|
|
5
6
|
declare const _default: {
|
|
6
7
|
gbk: {
|
|
7
8
|
gbkLength: (str: string) => number;
|
|
@@ -34,7 +35,7 @@ declare const _default: {
|
|
|
34
35
|
exec: (func: Function, taskId?: string) => Promise<any[]>;
|
|
35
36
|
debounce: typeof import("./modules/hook/debounce").default;
|
|
36
37
|
throttle: typeof import("./modules/hook/throttle").default;
|
|
37
|
-
task: (param?: import("./typings").
|
|
38
|
+
task: (param?: import("./typings/xhao").Xhao.Func1<any, any> | undefined) => import("./class/pipeTask").default;
|
|
38
39
|
delay: (time?: number) => Promise<unknown>;
|
|
39
40
|
mutex: typeof import("./modules/hook/mutex").default;
|
|
40
41
|
};
|
|
@@ -92,12 +93,12 @@ declare const _default: {
|
|
|
92
93
|
isPromise: (value: any) => boolean;
|
|
93
94
|
};
|
|
94
95
|
list: {
|
|
95
|
-
stepAction: <T_1>(list: T_1[], func: import("./typings").
|
|
96
|
+
stepAction: <T_1>(list: T_1[], func: import("./typings/xhao").Xhao.Task<T_1, void>, stepCount?: number) => void;
|
|
96
97
|
skip: <T_2>(list: T_2[], count: number) => T_2[];
|
|
97
98
|
take: <T_3>(list: T_3[], count: number, skip?: number) => T_3[];
|
|
98
99
|
distinct: <T_4>(list: T_4[]) => T_4[];
|
|
99
100
|
randoms: <T_5>(list: T_5[], count?: number, repeat?: boolean) => T_5[];
|
|
100
|
-
toKV: (list: import("./typings").
|
|
101
|
+
toKV: (list: import("./typings/xhao").Xhao.KV<any>[], key: string, value: string) => import("./typings/xhao").Xhao.KV<any>;
|
|
101
102
|
groupBy: <T_6>(list: T_6[], key: string) => Record<string, T_6[]>;
|
|
102
103
|
first: <T_7>(list: T_7[]) => T_7 | undefined;
|
|
103
104
|
last: <T_8>(list: T_8[]) => T_8 | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { dd
|
|
1
|
+
import { dd } from '../../typings';
|
|
2
|
+
import { Xhao } from '../../typings/xhao';
|
|
2
3
|
/**
|
|
3
4
|
* 防抖 一段时间内,规定时间间隔多次执行,回调触发一次
|
|
4
5
|
* @param func
|
|
@@ -6,7 +7,7 @@ import { dd, xhao } from '../../typings';
|
|
|
6
7
|
* @param options 参数:leading 开始执行, trailing结束执行
|
|
7
8
|
* @returns
|
|
8
9
|
*/
|
|
9
|
-
declare function debounce(func:
|
|
10
|
+
declare function debounce(func: Xhao.Action, wait?: number, options?: dd.IDebounceOption): {
|
|
10
11
|
(...debouncedArgs: any[]): any;
|
|
11
12
|
cancel: () => void;
|
|
12
13
|
flush: () => any;
|
|
@@ -2,14 +2,14 @@ import debounce from "./debounce";
|
|
|
2
2
|
import throttle from "./throttle";
|
|
3
3
|
import mutex from "./mutex";
|
|
4
4
|
import DPipeTask from "../../class/pipeTask";
|
|
5
|
-
import {
|
|
5
|
+
import { Xhao } from "../../typings/xhao";
|
|
6
6
|
declare const _default: {
|
|
7
7
|
sleep: (time?: number) => Promise<unknown>;
|
|
8
8
|
run: (task?: Function | Promise<any> | undefined, wait?: number) => Promise<any[]>;
|
|
9
9
|
exec: (func: Function, taskId?: string) => Promise<any[]>;
|
|
10
10
|
debounce: typeof debounce;
|
|
11
11
|
throttle: typeof throttle;
|
|
12
|
-
task: (param?:
|
|
12
|
+
task: (param?: Xhao.Func1<any, any> | undefined) => DPipeTask;
|
|
13
13
|
delay: (time?: number) => Promise<unknown>;
|
|
14
14
|
mutex: typeof mutex;
|
|
15
15
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare function mutex(func:
|
|
1
|
+
import { Xhao } from "../../typings/xhao";
|
|
2
|
+
declare function mutex(func: Xhao.Action): (...args: any[]) => Promise<false | undefined>;
|
|
3
3
|
export default mutex;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { dd
|
|
1
|
+
import { dd } from "../../typings";
|
|
2
|
+
import { Xhao } from "../../typings/xhao";
|
|
2
3
|
/**
|
|
3
4
|
* 节流 每个间隔内,触发一次
|
|
4
5
|
* @param func
|
|
@@ -6,7 +7,7 @@ import { dd, xhao } from "../../typings";
|
|
|
6
7
|
* @param options 参数:leading 开始执行, trailing结束执行
|
|
7
8
|
* @returns
|
|
8
9
|
*/
|
|
9
|
-
declare function throttle(func:
|
|
10
|
+
declare function throttle(func: Xhao.Action, wait?: number, options?: Omit<dd.IDebounceOption, 'maxWait'>): {
|
|
10
11
|
(...debouncedArgs: any[]): any;
|
|
11
12
|
cancel: () => void;
|
|
12
13
|
flush: () => any;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Interceptor from "./interceptor";
|
|
2
|
-
import { dd
|
|
2
|
+
import { dd } from "../../typings";
|
|
3
|
+
import { Xhao } from "../../typings/xhao";
|
|
3
4
|
export default class Http implements dd.IHttp {
|
|
4
5
|
host: string;
|
|
5
6
|
reqConfig: {};
|
|
@@ -32,5 +33,5 @@ export default class Http implements dd.IHttp {
|
|
|
32
33
|
* @param {object} req
|
|
33
34
|
*/
|
|
34
35
|
getIdFromReqUrl(req: any): any;
|
|
35
|
-
fetch(name: string, payload?:
|
|
36
|
+
fetch(name: string, payload?: Xhao.KV): Promise<any>;
|
|
36
37
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Xhao } from "../../typings/xhao";
|
|
2
2
|
/**
|
|
3
3
|
* 分步动作
|
|
4
4
|
* @param list 列表
|
|
@@ -6,7 +6,7 @@ import { xhao } from "../../typings";
|
|
|
6
6
|
* @param stepCount 每步数量
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
|
-
declare function stepAction<T>(list: T[], func:
|
|
9
|
+
declare function stepAction<T>(list: T[], func: Xhao.Task<T>, stepCount?: number): void;
|
|
10
10
|
/**
|
|
11
11
|
* 跳过数据
|
|
12
12
|
* @param list 列表
|
|
@@ -35,7 +35,7 @@ declare const _default: {
|
|
|
35
35
|
take: typeof take;
|
|
36
36
|
distinct: typeof distinct;
|
|
37
37
|
randoms: typeof randoms;
|
|
38
|
-
toKV: (list:
|
|
38
|
+
toKV: (list: Xhao.KV<any>[], key: string, value: string) => Xhao.KV<any>;
|
|
39
39
|
groupBy: <T>(list: T[], key: string) => Record<string, T[]>;
|
|
40
40
|
first: <T_1>(list: T_1[]) => T_1 | undefined;
|
|
41
41
|
last: <T_2>(list: T_2[]) => T_2 | undefined;
|
|
@@ -1,21 +1,5 @@
|
|
|
1
1
|
import DPersist from "../class/persist";
|
|
2
|
-
|
|
3
|
-
type KV<T = any> = Record<string, T>;
|
|
4
|
-
type KeyValueOjbect<T = any> = {
|
|
5
|
-
key: string;
|
|
6
|
-
value: T;
|
|
7
|
-
};
|
|
8
|
-
type KeyValue<T = any> = Required<KeyValueOjbect<T>>;
|
|
9
|
-
type Callback<T extends any[] = unknown[], R = void> = (...args: T) => R;
|
|
10
|
-
type Action<T extends any[] = unknown[], R = any> = Callback<T, R>;
|
|
11
|
-
type Task<T = any, R = void> = Callback<[T[]], R>;
|
|
12
|
-
type Func<R = any> = Callback<[], R>;
|
|
13
|
-
type Func1<T = any, R = any> = Callback<[T], R>;
|
|
14
|
-
type Func2<T0 = any, T1 = any, R = any> = Callback<[T0, T1], R>;
|
|
15
|
-
type Func3<T0 = any, T1 = any, T2 = any, R = any> = Callback<[T0, T1, T2], R>;
|
|
16
|
-
type Func4<T0 = any, T1 = any, T2 = any, T3 = any, R = any> = Callback<[T0, T1, T2, T3], R>;
|
|
17
|
-
type Result<T = any> = T | Promise<T>;
|
|
18
|
-
}
|
|
2
|
+
import { Xhao } from "./xhao";
|
|
19
3
|
export declare namespace dd {
|
|
20
4
|
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
21
5
|
/**
|
|
@@ -62,14 +46,14 @@ export declare namespace dd {
|
|
|
62
46
|
interface IHttpApiConfig {
|
|
63
47
|
[key: string]: IHttpRequestInit;
|
|
64
48
|
}
|
|
65
|
-
type ResponseInterceptFunc =
|
|
66
|
-
type RequestInterceptFunc =
|
|
49
|
+
type ResponseInterceptFunc = Xhao.Func1<IHttpResponse>;
|
|
50
|
+
type RequestInterceptFunc = Xhao.Func1<IHttpRequest, IHttpRequest>;
|
|
67
51
|
interface IHttpConfig {
|
|
68
52
|
host?: string;
|
|
69
53
|
config: IHttpApiConfig;
|
|
70
54
|
handleRequest?: RequestInterceptFunc | RequestInterceptFunc[];
|
|
71
55
|
handleResponse?: ResponseInterceptFunc | ResponseInterceptFunc[];
|
|
72
|
-
handleError?:
|
|
56
|
+
handleError?: Xhao.Func1;
|
|
73
57
|
}
|
|
74
58
|
interface IHttpRequestInit extends RequestInit {
|
|
75
59
|
[key: string]: any;
|
|
@@ -90,7 +74,7 @@ export declare namespace dd {
|
|
|
90
74
|
}
|
|
91
75
|
interface IHttpResponse {
|
|
92
76
|
response: Response & Record<string, any>;
|
|
93
|
-
config?:
|
|
77
|
+
config?: Xhao.KV;
|
|
94
78
|
refetch: () => Promise<any>;
|
|
95
79
|
}
|
|
96
80
|
interface IMiniHttpOptions {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare namespace Xhao {
|
|
2
|
+
type KV<T = any> = Record<string, T>;
|
|
3
|
+
type KeyValueOjbect<T = any> = {
|
|
4
|
+
key: string;
|
|
5
|
+
value: T;
|
|
6
|
+
};
|
|
7
|
+
type KeyValue<T = any> = Required<KeyValueOjbect<T>>;
|
|
8
|
+
type Callback<T extends any[] = unknown[], R = any> = (...args: T) => R;
|
|
9
|
+
type Action<T extends any[] = unknown[]> = Callback<T, void>;
|
|
10
|
+
type Task<T = any, R = void> = Callback<[T[]], R>;
|
|
11
|
+
type Func<R = any> = Callback<[], R>;
|
|
12
|
+
type Func1<T = any, R = any> = Callback<[T], R>;
|
|
13
|
+
type Func2<T0 = any, T1 = any, R = any> = Callback<[T0, T1], R>;
|
|
14
|
+
type Func3<T0 = any, T1 = any, T2 = any, R = any> = Callback<[T0, T1, T2], R>;
|
|
15
|
+
type Func4<T0 = any, T1 = any, T2 = any, T3 = any, R = any> = Callback<[T0, T1, T2, T3], R>;
|
|
16
|
+
type Result<T = any> = T | Promise<T>;
|
|
17
|
+
}
|