ddan-js 2.5.6 → 2.5.8
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/modules/hook/index.js +4 -4
- package/bin/lib/modules/hook/{debounce.js → modules/debounce.js} +2 -2
- package/bin/lib/modules/hook/modules/pipeline.js +2 -2
- package/bin/lib/modules/hook/{polling.js → modules/polling.js} +1 -1
- package/bin/lib/modules/hook/{throttle.js → modules/throttle.js} +1 -1
- package/bin/types/index.d.ts +16 -16
- package/bin/types/modules/hook/base.d.ts +2 -1
- package/bin/types/modules/hook/hooker.d.ts +4 -3
- package/bin/types/modules/hook/index.d.ts +8 -8
- package/bin/types/modules/hook/{debounce.d.ts → modules/debounce.d.ts} +1 -1
- package/bin/types/modules/hook/{mutex.d.ts → modules/mutex.d.ts} +1 -1
- package/bin/types/modules/hook/modules/pipeline.d.ts +2 -2
- package/bin/types/modules/hook/{polling.d.ts → modules/polling.d.ts} +1 -1
- package/bin/types/modules/hook/{throttle.d.ts → modules/throttle.d.ts} +1 -1
- package/bin/types/typings/index.d.ts +3 -1
- package/package.json +1 -1
- /package/bin/lib/modules/hook/{mutex.js → modules/mutex.js} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const debounce_1 = require("./debounce");
|
|
4
|
-
const throttle_1 = require("./throttle");
|
|
5
|
-
const mutex_1 = require("./mutex");
|
|
3
|
+
const debounce_1 = require("./modules/debounce");
|
|
4
|
+
const throttle_1 = require("./modules/throttle");
|
|
5
|
+
const mutex_1 = require("./modules/mutex");
|
|
6
6
|
const pipeTask_1 = require("../../class/pipeTask");
|
|
7
7
|
const base_1 = require("./base");
|
|
8
|
-
const polling_1 = require("./polling");
|
|
8
|
+
const polling_1 = require("./modules/polling");
|
|
9
9
|
const hooker_1 = require("./hooker");
|
|
10
10
|
const pipeline_1 = require("./modules/pipeline");
|
|
11
11
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const to_1 = require("
|
|
4
|
-
const is_1 = require("
|
|
3
|
+
const to_1 = require("../../../util/to");
|
|
4
|
+
const is_1 = require("../../../util/is");
|
|
5
5
|
const FUNC_ERROR_TEXT = 'Expected a function';
|
|
6
6
|
const nativeMax = Math.max;
|
|
7
7
|
const nativeMin = Math.min;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const base_1 = require("
|
|
3
|
+
const base_1 = require("../base");
|
|
4
4
|
async function polling(params = {}) {
|
|
5
5
|
const { func, interval = 100, times = 1000 } = params;
|
|
6
6
|
let _times = times;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const is_1 = require("
|
|
3
|
+
const is_1 = require("../../../util/is");
|
|
4
4
|
const debounce_1 = require("./debounce");
|
|
5
5
|
/** Error message constants. */
|
|
6
6
|
const FUNC_ERROR_TEXT = 'Expected a function';
|
package/bin/types/index.d.ts
CHANGED
|
@@ -186,17 +186,17 @@ declare const dUtil: {
|
|
|
186
186
|
};
|
|
187
187
|
declare const dHook: {
|
|
188
188
|
sleep: (ms?: number) => Promise<unknown>;
|
|
189
|
-
run: <T = any>(task?:
|
|
190
|
-
exec: (func: Function, taskId?: string) =>
|
|
191
|
-
debounce: typeof import("./modules/hook/debounce").default;
|
|
192
|
-
throttle: typeof import("./modules/hook/throttle").default;
|
|
189
|
+
run: <T = any>(task?: import("./typings").Ddan.PFunction<T> | undefined, wait?: number) => Promise<[any, undefined] | [null, T]>;
|
|
190
|
+
exec: (func: import("./typings").Ddan.Function, taskId?: string) => import("./typings").Ddan.SafeResult<any>;
|
|
191
|
+
debounce: typeof import("./modules/hook/modules/debounce").default;
|
|
192
|
+
throttle: typeof import("./modules/hook/modules/throttle").default;
|
|
193
193
|
task: (param?: import("./typings").Ddan.Func1<any, any> | undefined) => import("./class/pipeTask").default;
|
|
194
|
-
mutex: typeof import("./modules/hook/mutex").default;
|
|
195
|
-
polling: typeof import("./modules/hook/polling").default;
|
|
196
|
-
pipe: (func: Function) => import("./modules/hook/modules/pipeline").default;
|
|
194
|
+
mutex: typeof import("./modules/hook/modules/mutex").default;
|
|
195
|
+
polling: typeof import("./modules/hook/modules/polling").default;
|
|
196
|
+
pipe: (func: import("./typings").Ddan.Function) => import("./modules/hook/modules/pipeline").default;
|
|
197
197
|
pipeline: () => import("./modules/hook/modules/pipeline").default;
|
|
198
198
|
to: <T_1 = any, U extends object = any>(promise: Promise<T_1>, errorExt?: object | undefined) => Promise<[null, T_1] | [U, undefined]>;
|
|
199
|
-
go: <T_2 = any>(task?:
|
|
199
|
+
go: <T_2 = any>(task?: import("./typings").Ddan.PFunction<T_2> | undefined) => Promise<[any, undefined] | [null, T_2]>;
|
|
200
200
|
delay: (ms?: number) => Promise<unknown>;
|
|
201
201
|
safeDo: <T_3 = any>(func: any) => Promise<[null, T_3] | [any, undefined]>;
|
|
202
202
|
base64: {
|
|
@@ -471,17 +471,17 @@ declare const _default: {
|
|
|
471
471
|
};
|
|
472
472
|
hook: {
|
|
473
473
|
sleep: (ms?: number) => Promise<unknown>;
|
|
474
|
-
run: <T = any>(task?:
|
|
475
|
-
exec: (func: Function, taskId?: string) =>
|
|
476
|
-
debounce: typeof import("./modules/hook/debounce").default;
|
|
477
|
-
throttle: typeof import("./modules/hook/throttle").default;
|
|
474
|
+
run: <T = any>(task?: import("./typings").Ddan.PFunction<T> | undefined, wait?: number) => Promise<[any, undefined] | [null, T]>;
|
|
475
|
+
exec: (func: import("./typings").Ddan.Function, taskId?: string) => import("./typings").Ddan.SafeResult<any>;
|
|
476
|
+
debounce: typeof import("./modules/hook/modules/debounce").default;
|
|
477
|
+
throttle: typeof import("./modules/hook/modules/throttle").default;
|
|
478
478
|
task: (param?: import("./typings").Ddan.Func1<any, any> | undefined) => import("./class/pipeTask").default;
|
|
479
|
-
mutex: typeof import("./modules/hook/mutex").default;
|
|
480
|
-
polling: typeof import("./modules/hook/polling").default;
|
|
481
|
-
pipe: (func: Function) => import("./modules/hook/modules/pipeline").default;
|
|
479
|
+
mutex: typeof import("./modules/hook/modules/mutex").default;
|
|
480
|
+
polling: typeof import("./modules/hook/modules/polling").default;
|
|
481
|
+
pipe: (func: import("./typings").Ddan.Function) => import("./modules/hook/modules/pipeline").default;
|
|
482
482
|
pipeline: () => import("./modules/hook/modules/pipeline").default;
|
|
483
483
|
to: <T_1 = any, U extends object = any>(promise: Promise<T_1>, errorExt?: object | undefined) => Promise<[null, T_1] | [U, undefined]>;
|
|
484
|
-
go: <T_2 = any>(task?:
|
|
484
|
+
go: <T_2 = any>(task?: import("./typings").Ddan.PFunction<T_2> | undefined) => Promise<[any, undefined] | [null, T_2]>;
|
|
485
485
|
delay: (ms?: number) => Promise<unknown>;
|
|
486
486
|
safeDo: <T_3 = any>(func: any) => Promise<[null, T_3] | [any, undefined]>;
|
|
487
487
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Ddan } from '../../typings';
|
|
1
2
|
declare function to<T = any, U extends object = any>(promise: Promise<T>, errorExt?: object): Promise<[null, T] | [U, undefined]>;
|
|
2
3
|
declare const _default: {
|
|
3
4
|
to: typeof to;
|
|
4
|
-
go: <T = any>(task?:
|
|
5
|
+
go: <T = any>(task?: Ddan.PFunction<T> | undefined) => Promise<[any, undefined] | [null, T]>;
|
|
5
6
|
delay: (ms?: number) => Promise<unknown>;
|
|
6
7
|
safeDo: <T_1 = any>(func: any) => Promise<[null, T_1] | [any, undefined]>;
|
|
7
8
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import DPipeline from './modules/pipeline';
|
|
2
|
+
import { Ddan } from '../../typings';
|
|
2
3
|
declare const DHooker_base: {
|
|
3
4
|
new (): {};
|
|
4
5
|
__instance__: any;
|
|
@@ -6,11 +7,11 @@ declare const DHooker_base: {
|
|
|
6
7
|
readonly I: DHooker;
|
|
7
8
|
};
|
|
8
9
|
export default class DHooker extends DHooker_base {
|
|
9
|
-
__lockedMap: Map<string,
|
|
10
|
+
__lockedMap: Map<string, Ddan.SafeResult<any>>;
|
|
10
11
|
pipeline: DPipeline;
|
|
11
12
|
constructor();
|
|
12
|
-
lock(id: string, func:
|
|
13
|
+
lock(id: string, func: Ddan.PFunction): Promise<[any, undefined] | [null, any]> | undefined;
|
|
13
14
|
unlock(id: string): void;
|
|
14
|
-
exec(func:
|
|
15
|
+
exec(func: Ddan.PFunction, taskId: string): Ddan.SafeResult;
|
|
15
16
|
}
|
|
16
17
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Ddan } from '../../typings';
|
|
2
|
-
import debounce from './debounce';
|
|
3
|
-
import throttle from './throttle';
|
|
4
|
-
import mutex from './mutex';
|
|
2
|
+
import debounce from './modules/debounce';
|
|
3
|
+
import throttle from './modules/throttle';
|
|
4
|
+
import mutex from './modules/mutex';
|
|
5
5
|
import DPipeTask from '../../class/pipeTask';
|
|
6
|
-
import polling from './polling';
|
|
6
|
+
import polling from './modules/polling';
|
|
7
7
|
import DPipeline from './modules/pipeline';
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
@@ -11,20 +11,20 @@ import DPipeline from './modules/pipeline';
|
|
|
11
11
|
* @param wait 最小等待时间,单位毫秒
|
|
12
12
|
* @returns
|
|
13
13
|
*/
|
|
14
|
-
declare function run<T = any>(task?:
|
|
14
|
+
declare function run<T = any>(task?: Ddan.PFunction<T>, wait?: number): Promise<[any, undefined] | [null, T]>;
|
|
15
15
|
declare const _default: {
|
|
16
16
|
sleep: (ms?: number) => Promise<unknown>;
|
|
17
17
|
run: typeof run;
|
|
18
|
-
exec: (func: Function, taskId?: string) =>
|
|
18
|
+
exec: (func: Ddan.Function, taskId?: string) => Ddan.SafeResult<any>;
|
|
19
19
|
debounce: typeof debounce;
|
|
20
20
|
throttle: typeof throttle;
|
|
21
21
|
task: (param?: Ddan.Func1<any, any> | undefined) => DPipeTask;
|
|
22
22
|
mutex: typeof mutex;
|
|
23
23
|
polling: typeof polling;
|
|
24
|
-
pipe: (func: Function) => DPipeline;
|
|
24
|
+
pipe: (func: Ddan.Function) => DPipeline;
|
|
25
25
|
pipeline: () => DPipeline;
|
|
26
26
|
to: <T = any, U extends object = any>(promise: Promise<T>, errorExt?: object | undefined) => Promise<[null, T] | [U, undefined]>;
|
|
27
|
-
go: <T_1 = any>(task?:
|
|
27
|
+
go: <T_1 = any>(task?: Ddan.PFunction<T_1> | undefined) => Promise<[any, undefined] | [null, T_1]>;
|
|
28
28
|
delay: (ms?: number) => Promise<unknown>;
|
|
29
29
|
safeDo: <T_2 = any>(func: any) => Promise<[null, T_2] | [any, undefined]>;
|
|
30
30
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Ddan } from '../../../typings';
|
|
2
2
|
export default class DPipeline implements Ddan.IPipeline {
|
|
3
|
-
__list:
|
|
3
|
+
__list: Ddan.Function[];
|
|
4
4
|
__running: boolean;
|
|
5
5
|
__waitting: boolean;
|
|
6
6
|
constructor();
|
|
7
|
-
pipe(
|
|
7
|
+
pipe(func?: Ddan.Function): this;
|
|
8
8
|
delay(t?: number): this;
|
|
9
9
|
clear(): this;
|
|
10
10
|
_step(): Promise<void>;
|
|
@@ -6,6 +6,7 @@ export declare namespace Ddan {
|
|
|
6
6
|
}
|
|
7
7
|
type KeyValue<T = any> = Required<IKeyValuePart<T>>;
|
|
8
8
|
type Function = (...args: any[]) => void;
|
|
9
|
+
type PFunction<T = any> = Promise<T> | Function;
|
|
9
10
|
type Callback<T extends any[] = unknown[], R = any> = (...args: T) => R;
|
|
10
11
|
type Action<T extends any[] = unknown[]> = Callback<T, void>;
|
|
11
12
|
type Task<T = any, R = void> = Callback<[T[]], R>;
|
|
@@ -15,6 +16,7 @@ export declare namespace Ddan {
|
|
|
15
16
|
type Func3<T0 = any, T1 = any, T2 = any, R = any> = Callback<[T0, T1, T2], R>;
|
|
16
17
|
type Func4<T0 = any, T1 = any, T2 = any, T3 = any, R = any> = Callback<[T0, T1, T2, T3], R>;
|
|
17
18
|
type Result<T = any> = T | Promise<T>;
|
|
19
|
+
type SafeResult<T = any> = Promise<[any, undefined] | [null, T]>;
|
|
18
20
|
interface IHttpHost {
|
|
19
21
|
href: string;
|
|
20
22
|
url: string;
|
|
@@ -143,7 +145,7 @@ export declare namespace Ddan {
|
|
|
143
145
|
trailing?: boolean;
|
|
144
146
|
}
|
|
145
147
|
interface IPipeline {
|
|
146
|
-
pipe(func?:
|
|
148
|
+
pipe(func?: Function): IPipeline;
|
|
147
149
|
delay(t?: number): IPipeline;
|
|
148
150
|
clear(): IPipeline;
|
|
149
151
|
whenAll(): Promise<IPipeline>;
|
package/package.json
CHANGED
|
File without changes
|