ddan-js 2.6.0 → 2.6.2

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.
@@ -187,18 +187,19 @@ declare const dUtil: {
187
187
  declare const dHook: {
188
188
  sleep: (ms?: number) => Promise<unknown>;
189
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>;
190
+ exec: (func: import("./typings").Ddan.Function, taskId?: string) => import("./typings").Ddan.PSafeResult<any>;
191
191
  debounce: typeof import("./modules/hook/modules/debounce").default;
192
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
194
  mutex: typeof import("./modules/hook/modules/mutex").default;
195
195
  polling: typeof import("./modules/hook/modules/polling").default;
196
- pipe: (func: import("./typings").Ddan.Function) => import("./modules/hook/modules/pipeline").default;
196
+ pipe: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/pipeline").default;
197
197
  pipeline: (max?: number) => import("./modules/hook/modules/pipeline").default;
198
+ safeTask: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/safeTask").default;
198
199
  to: <T_1 = any, U extends object = any>(promise: Promise<T_1>, errorExt?: object | undefined) => Promise<[null, T_1] | [U, undefined]>;
199
200
  go: <T_2 = any>(task?: import("./typings").Ddan.PFunction<T_2> | undefined) => Promise<[any, undefined] | [null, T_2]>;
200
201
  delay: (ms?: number) => Promise<unknown>;
201
- safeDo: <T_3 = any>(func: any) => Promise<[null, T_3] | [any, undefined]>;
202
+ safeRun: <T_3 = any>(func: any) => Promise<[any, undefined] | [null, T_3]>;
202
203
  base64: {
203
204
  encode: (input: string) => string;
204
205
  decode: (input: string) => string;
@@ -472,18 +473,19 @@ declare const _default: {
472
473
  hook: {
473
474
  sleep: (ms?: number) => Promise<unknown>;
474
475
  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
+ exec: (func: import("./typings").Ddan.Function, taskId?: string) => import("./typings").Ddan.PSafeResult<any>;
476
477
  debounce: typeof import("./modules/hook/modules/debounce").default;
477
478
  throttle: typeof import("./modules/hook/modules/throttle").default;
478
479
  task: (param?: import("./typings").Ddan.Func1<any, any> | undefined) => import("./class/pipeTask").default;
479
480
  mutex: typeof import("./modules/hook/modules/mutex").default;
480
481
  polling: typeof import("./modules/hook/modules/polling").default;
481
- pipe: (func: import("./typings").Ddan.Function) => import("./modules/hook/modules/pipeline").default;
482
+ pipe: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/pipeline").default;
482
483
  pipeline: (max?: number) => import("./modules/hook/modules/pipeline").default;
484
+ safeTask: (func: import("./typings").Ddan.Function, callback?: ((result: import("./typings").Ddan.SafeResult<any>) => void) | undefined) => import("./modules/hook/modules/safeTask").default;
483
485
  to: <T_1 = any, U extends object = any>(promise: Promise<T_1>, errorExt?: object | undefined) => Promise<[null, T_1] | [U, undefined]>;
484
486
  go: <T_2 = any>(task?: import("./typings").Ddan.PFunction<T_2> | undefined) => Promise<[any, undefined] | [null, T_2]>;
485
487
  delay: (ms?: number) => Promise<unknown>;
486
- safeDo: <T_3 = any>(func: any) => Promise<[null, T_3] | [any, undefined]>;
488
+ safeRun: <T_3 = any>(func: any) => Promise<[any, undefined] | [null, T_3]>;
487
489
  };
488
490
  math: {
489
491
  random: (max: number) => number;
@@ -4,6 +4,6 @@ declare const _default: {
4
4
  to: typeof to;
5
5
  go: <T = any>(task?: Ddan.PFunction<T> | undefined) => Promise<[any, undefined] | [null, T]>;
6
6
  delay: (ms?: number) => Promise<unknown>;
7
- safeDo: <T_1 = any>(func: any) => Promise<[null, T_1] | [any, undefined]>;
7
+ safeRun: <T_1 = any>(func: any) => Promise<[null, T_1] | [any, undefined]>;
8
8
  };
9
9
  export default _default;
@@ -7,11 +7,11 @@ declare const DHooker_base: {
7
7
  readonly I: DHooker;
8
8
  };
9
9
  export default class DHooker extends DHooker_base {
10
- __lockedMap: Map<string, Ddan.SafeResult<any>>;
10
+ __lockedMap: Map<string, Ddan.PSafeResult<any>>;
11
11
  pipeline: DPipeline;
12
12
  constructor();
13
13
  lock(id: string, func: Ddan.PFunction): Promise<[any, undefined] | [null, any]> | undefined;
14
14
  unlock(id: string): void;
15
- exec(func: Ddan.PFunction, taskId: string): Ddan.SafeResult;
15
+ exec(func: Ddan.PFunction, taskId: string): Ddan.PSafeResult;
16
16
  }
17
17
  export {};
@@ -5,6 +5,7 @@ import mutex from './modules/mutex';
5
5
  import DPipeTask from '../../class/pipeTask';
6
6
  import polling from './modules/polling';
7
7
  import DPipeline from './modules/pipeline';
8
+ import DSafeTask from './modules/safeTask';
8
9
  /**
9
10
  *
10
11
  * @param task 任务
@@ -15,17 +16,18 @@ declare function run<T = any>(task?: Ddan.PFunction<T>, wait?: number): Promise<
15
16
  declare const _default: {
16
17
  sleep: (ms?: number) => Promise<unknown>;
17
18
  run: typeof run;
18
- exec: (func: Ddan.Function, taskId?: string) => Ddan.SafeResult<any>;
19
+ exec: (func: Ddan.Function, taskId?: string) => Ddan.PSafeResult<any>;
19
20
  debounce: typeof debounce;
20
21
  throttle: typeof throttle;
21
22
  task: (param?: Ddan.Func1<any, any> | undefined) => DPipeTask;
22
23
  mutex: typeof mutex;
23
24
  polling: typeof polling;
24
- pipe: (func: Ddan.Function) => DPipeline;
25
+ pipe: (func: Ddan.Function, callback?: ((result: Ddan.SafeResult<any>) => void) | undefined) => DPipeline;
25
26
  pipeline: (max?: number) => DPipeline;
27
+ safeTask: (func: Ddan.Function, callback?: ((result: Ddan.SafeResult<any>) => void) | undefined) => DSafeTask;
26
28
  to: <T = any, U extends object = any>(promise: Promise<T>, errorExt?: object | undefined) => Promise<[null, T] | [U, undefined]>;
27
29
  go: <T_1 = any>(task?: Ddan.PFunction<T_1> | undefined) => Promise<[any, undefined] | [null, T_1]>;
28
30
  delay: (ms?: number) => Promise<unknown>;
29
- safeDo: <T_2 = any>(func: any) => Promise<[null, T_2] | [any, undefined]>;
31
+ safeRun: <T_2 = any>(func: any) => Promise<[null, T_2] | [any, undefined]>;
30
32
  };
31
33
  export default _default;
@@ -1,10 +1,11 @@
1
1
  import { Ddan } from '../../../typings';
2
+ import DSafeTask from './safeTask';
2
3
  export default class DPipeline implements Ddan.IPipeline {
3
- __list: Ddan.Function[];
4
+ __list: DSafeTask[];
4
5
  __count: number;
5
6
  __max: number;
6
7
  constructor(max?: number);
7
- push(func?: Ddan.Function): this;
8
+ push(func: Ddan.Function, callback?: (result: Ddan.SafeResult) => void): this;
8
9
  clear(): this;
9
10
  _step(): void;
10
11
  whenAll(): Promise<this>;
@@ -0,0 +1,7 @@
1
+ import { Ddan } from '../../../typings';
2
+ export default class DSafeTask implements Ddan.ISafeTask {
3
+ _func: Ddan.PFunction;
4
+ _callback: ((result: Ddan.SafeResult) => void) | undefined;
5
+ constructor(task: Ddan.PFunction, callback?: (result: Ddan.SafeResult) => void);
6
+ run(): Ddan.PSafeResult;
7
+ }
@@ -14,6 +14,12 @@ declare class Schema {
14
14
  string: import("./interface").ExecuteValidator;
15
15
  method: import("./interface").ExecuteValidator;
16
16
  number: import("./interface").ExecuteValidator;
17
+ /**
18
+ * Encapsulates a validation schema.
19
+ *
20
+ * @param descriptor An object declaring validation rules
21
+ * for this schema.
22
+ */
17
23
  boolean: import("./interface").ExecuteValidator;
18
24
  regexp: import("./interface").ExecuteValidator;
19
25
  integer: import("./interface").ExecuteValidator;
@@ -16,7 +16,24 @@ export declare namespace Ddan {
16
16
  type Func3<T0 = any, T1 = any, T2 = any, R = any> = Callback<[T0, T1, T2], R>;
17
17
  type Func4<T0 = any, T1 = any, T2 = any, T3 = any, R = any> = Callback<[T0, T1, T2, T3], R>;
18
18
  type Result<T = any> = T | Promise<T>;
19
- type SafeResult<T = any> = Promise<[any, undefined] | [null, T]>;
19
+ type SafeResult<T = any> = [any, undefined] | [null, T];
20
+ type PSafeResult<T = any> = Promise<SafeResult<T>>;
21
+ type ObjToKeyValUnion<T> = {
22
+ [K in keyof T]: {
23
+ key: K;
24
+ value: T[K];
25
+ };
26
+ }[keyof T];
27
+ type ObjToKeyValArray<T> = {
28
+ [K in keyof T]: [K, T[K]];
29
+ }[keyof T];
30
+ type ObjToSelectedValueUnion<T> = {
31
+ [K in keyof T]: T[K];
32
+ }[keyof T];
33
+ type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
34
+ type GetOptional<T> = {
35
+ [P in keyof T as T[P] extends Required<T>[P] ? never : P]: T[P];
36
+ };
20
37
  interface IHttpHost {
21
38
  href: string;
22
39
  url: string;
@@ -149,6 +166,9 @@ export declare namespace Ddan {
149
166
  clear(): IPipeline;
150
167
  whenAll(): Promise<IPipeline>;
151
168
  }
169
+ interface ISafeTask {
170
+ run(): PSafeResult;
171
+ }
152
172
  }
153
173
  export declare namespace dd {
154
174
  interface IHttpRequest {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ddan-js",
3
- "version": "2.6.0",
3
+ "version": "2.6.2",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "ddan-js",