ddan-js 2.3.1 → 2.3.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/ddan-js.esm.js +1 -1
- package/bin/ddan-js.js +1 -1
- package/bin/lib/index.js +31 -31
- package/bin/lib/modules/hook/index.js +20 -1
- package/bin/lib/modules/hook/polling.js +20 -0
- package/bin/lib/modules/rule/async-validator/index.js +1 -1
- package/bin/lib/typings/index.js +1 -1
- package/bin/types/index.d.ts +7 -307
- package/bin/types/modules/hook/index.d.ts +12 -0
- package/bin/types/modules/hook/polling.d.ts +7 -0
- package/bin/types/modules/rule/async-validator/index.d.ts +6 -0
- package/package.json +1 -1
package/bin/types/index.d.ts
CHANGED
|
@@ -178,7 +178,13 @@ declare const dHook: {
|
|
|
178
178
|
throttle: typeof import("./modules/hook/throttle").default;
|
|
179
179
|
task: (param?: import("./typings").Ddan.Func1<any, any> | undefined) => import("./class/pipeTask").default;
|
|
180
180
|
mutex: typeof import("./modules/hook/mutex").default;
|
|
181
|
-
|
|
181
|
+
polling: typeof import("./modules/hook/polling").default;
|
|
182
|
+
singleton: <T_1>() => {
|
|
183
|
+
new (): {};
|
|
184
|
+
__instance__: any;
|
|
185
|
+
readonly Instance: T_1;
|
|
186
|
+
};
|
|
187
|
+
to: <T_2 = any, U extends object = any>(promise: Promise<T_2>, errorExt?: object | undefined) => Promise<[null, T_2] | [U, undefined]>;
|
|
182
188
|
delay: (time?: number) => Promise<unknown>;
|
|
183
189
|
};
|
|
184
190
|
declare const dMini: {
|
|
@@ -382,309 +388,3 @@ declare const dWeb: {
|
|
|
382
388
|
};
|
|
383
389
|
};
|
|
384
390
|
export { dUtil, dHook, dWeb, dMini, dCdn, dClass, dStore, dJoker, dTracker, dLogger };
|
|
385
|
-
declare const _default: {
|
|
386
|
-
gbk: {
|
|
387
|
-
gbkLength: (str: string) => number;
|
|
388
|
-
gbkCut: (source: string, len: number) => string;
|
|
389
|
-
};
|
|
390
|
-
time: {
|
|
391
|
-
now: () => import("./modules/time/dtime").default;
|
|
392
|
-
isToday: (date: any) => any;
|
|
393
|
-
parseTimestamp: ({ year, month, date, hour, minute, second }: {
|
|
394
|
-
year?: number | undefined;
|
|
395
|
-
month?: number | undefined;
|
|
396
|
-
date?: number | undefined;
|
|
397
|
-
hour?: number | undefined;
|
|
398
|
-
minute?: number | undefined;
|
|
399
|
-
second?: number | undefined;
|
|
400
|
-
}) => number;
|
|
401
|
-
todayZero: () => number;
|
|
402
|
-
format: (time: string | number | Date, reg?: string) => string;
|
|
403
|
-
countdown: (endTime: string | number | Date, reg?: string) => "" | import("./modules/time/dtime").IDCountdownFormat;
|
|
404
|
-
dtime: (time: string | number | Date) => import("./modules/time/dtime").default;
|
|
405
|
-
loopFrame: (interval?: number) => import("./modules/time/frame").default;
|
|
406
|
-
oneDay: number;
|
|
407
|
-
oneHour: number;
|
|
408
|
-
oneMinute: number;
|
|
409
|
-
oneSecond: number;
|
|
410
|
-
};
|
|
411
|
-
hook: {
|
|
412
|
-
run: <T = any>(task?: Function | Promise<T> | undefined, wait?: number) => Promise<[any, undefined] | [null, T]>;
|
|
413
|
-
exec: (func: Function, taskId?: string) => Promise<any[]>;
|
|
414
|
-
debounce: typeof import("./modules/hook/debounce").default;
|
|
415
|
-
throttle: typeof import("./modules/hook/throttle").default;
|
|
416
|
-
task: (param?: import("./typings").Ddan.Func1<any, any> | undefined) => import("./class/pipeTask").default;
|
|
417
|
-
mutex: typeof import("./modules/hook/mutex").default;
|
|
418
|
-
to: <T_1 = any, U extends object = any>(promise: Promise<T_1>, errorExt?: object | undefined) => Promise<[null, T_1] | [U, undefined]>;
|
|
419
|
-
delay: (time?: number) => Promise<unknown>;
|
|
420
|
-
};
|
|
421
|
-
math: {
|
|
422
|
-
random: (max: number) => number;
|
|
423
|
-
randomRange: (min: number, max: number) => number;
|
|
424
|
-
lerp: (start: number, end: number, t: number) => number;
|
|
425
|
-
randoms: (max: number, count?: number, repeat?: boolean) => number[];
|
|
426
|
-
strip: (num: string | number, digits?: number) => number;
|
|
427
|
-
float: (num: string | number, { digits, fixed }?: {
|
|
428
|
-
digits?: number | undefined;
|
|
429
|
-
fixed?: boolean | undefined;
|
|
430
|
-
}) => number;
|
|
431
|
-
radian2degree: (radians: number) => number;
|
|
432
|
-
degree2radian: (degrees: number) => number;
|
|
433
|
-
};
|
|
434
|
-
util: {
|
|
435
|
-
includes: typeof import("./util/includes").default;
|
|
436
|
-
forof: (source: any, cb: (key: any, val: any) => void) => void;
|
|
437
|
-
copy: (source: any, options?: {
|
|
438
|
-
fields?: string[] | undefined;
|
|
439
|
-
camel?: boolean | undefined;
|
|
440
|
-
pure?: boolean | undefined;
|
|
441
|
-
} & import("./typings").dd.IIgnoreParams) => any;
|
|
442
|
-
clone: (source: any) => any;
|
|
443
|
-
merge: (target: any, source: any, options?: import("./typings").dd.IIgnoreParams) => {};
|
|
444
|
-
isEmpty: (source: any) => boolean;
|
|
445
|
-
parseValue: (source: any, { number, boolean }?: {
|
|
446
|
-
number?: boolean | undefined;
|
|
447
|
-
boolean?: boolean | undefined;
|
|
448
|
-
}) => any;
|
|
449
|
-
cloneClass: <T_2>(source: T_2) => T_2;
|
|
450
|
-
combine: (target: any, source: any, options?: import("./typings").dd.IIgnoreParams) => any;
|
|
451
|
-
combines: (objs: any[], options?: import("./typings").dd.IIgnoreParams) => {};
|
|
452
|
-
observe: (obj: any, key: any, watchFun: any, owner: any, deep?: boolean) => void;
|
|
453
|
-
getTag: (value: any) => string;
|
|
454
|
-
getType: (value: any) => string;
|
|
455
|
-
toString: () => string;
|
|
456
|
-
hasOwnProperty: (v: PropertyKey) => boolean;
|
|
457
|
-
propertyIsEnumerable: (v: PropertyKey) => boolean;
|
|
458
|
-
is: (val: any, type: string) => boolean;
|
|
459
|
-
isNumber: (value: any) => boolean;
|
|
460
|
-
isString: (value: any) => boolean;
|
|
461
|
-
isObject: (value: any) => boolean;
|
|
462
|
-
isObjectLike: (value: any) => boolean;
|
|
463
|
-
isPlainObject: (value: any) => boolean;
|
|
464
|
-
isSymbol: (value: any) => boolean;
|
|
465
|
-
isFunction: (value: any) => boolean;
|
|
466
|
-
isArray: (arg: any) => arg is any[];
|
|
467
|
-
isArrayLikeObject: (value: any) => boolean;
|
|
468
|
-
isIndex: (value: any, length: number) => boolean;
|
|
469
|
-
isArrayLike: (value: any) => boolean;
|
|
470
|
-
isPrototype: (value: any) => boolean;
|
|
471
|
-
isArguments: (value: any) => boolean;
|
|
472
|
-
isPromise: (value: any) => boolean;
|
|
473
|
-
};
|
|
474
|
-
list: {
|
|
475
|
-
stepAction: <T_3>(list: T_3[], func: import("./typings").Ddan.Task<T_3, void>, stepCount?: number) => void;
|
|
476
|
-
skip: <T_4>(list: T_4[], count: number) => T_4[];
|
|
477
|
-
take: <T_5>(list: T_5[], count: number, skip?: number) => T_5[];
|
|
478
|
-
distinct: <T_6>(list: T_6[]) => T_6[];
|
|
479
|
-
randoms: <T_7>(list: T_7[], count?: number, repeat?: boolean) => T_7[];
|
|
480
|
-
toKV: (list: import("./typings").Ddan.KV<any>[], key: string, value: string) => import("./typings").Ddan.KV<any>;
|
|
481
|
-
groupBy: <T_8>(list: T_8[], key: string) => Record<string, T_8[]>;
|
|
482
|
-
first: <T_9>(list: T_9[]) => T_9 | undefined;
|
|
483
|
-
last: <T_10>(list: T_10[]) => T_10 | undefined;
|
|
484
|
-
toList: <T_11>(val: T_11 | T_11[]) => T_11[];
|
|
485
|
-
};
|
|
486
|
-
string: {
|
|
487
|
-
toString: (value: any) => any;
|
|
488
|
-
startCase: (string: any) => any;
|
|
489
|
-
snakeCase: (string: any) => any;
|
|
490
|
-
kebabCase: (string: any) => any;
|
|
491
|
-
camelCase: (string: any) => any;
|
|
492
|
-
upperCase: (string: any) => any;
|
|
493
|
-
upperFirst: (string: any) => any;
|
|
494
|
-
lowerCase: (string: any) => any;
|
|
495
|
-
lowerFirst: (string: any) => any;
|
|
496
|
-
splitOnFirst: (string: any, separator: any) => string[];
|
|
497
|
-
parseValue: (value?: any, { number, boolean }?: {
|
|
498
|
-
number?: boolean | undefined;
|
|
499
|
-
boolean?: boolean | undefined;
|
|
500
|
-
}) => any;
|
|
501
|
-
replace: (source: string, rules: import("./typings").dd.IRegexRule | import("./typings").dd.IRegexRule[]) => string;
|
|
502
|
-
};
|
|
503
|
-
obj: {
|
|
504
|
-
copy: (source: any, options?: {
|
|
505
|
-
fields?: string[] | undefined;
|
|
506
|
-
camel?: boolean | undefined;
|
|
507
|
-
pure?: boolean | undefined;
|
|
508
|
-
} & import("./typings").dd.IIgnoreParams) => any;
|
|
509
|
-
clone: (source: any) => any;
|
|
510
|
-
merge: (target: any, source: any, options?: import("./typings").dd.IIgnoreParams) => {};
|
|
511
|
-
isEmpty: (source: any) => boolean;
|
|
512
|
-
parseValue: (source: any, { number, boolean }?: {
|
|
513
|
-
number?: boolean | undefined;
|
|
514
|
-
boolean?: boolean | undefined;
|
|
515
|
-
}) => any;
|
|
516
|
-
cloneClass: <T_2>(source: T_2) => T_2;
|
|
517
|
-
combine: (target: any, source: any, options?: import("./typings").dd.IIgnoreParams) => any;
|
|
518
|
-
combines: (objs: any[], options?: import("./typings").dd.IIgnoreParams) => {};
|
|
519
|
-
observe: (obj: any, key: any, watchFun: any, owner: any, deep?: boolean) => void;
|
|
520
|
-
};
|
|
521
|
-
crypto: {
|
|
522
|
-
base64: {
|
|
523
|
-
encode: (input: string) => string;
|
|
524
|
-
decode: (input: string) => string;
|
|
525
|
-
encodeByOss: (input: string) => string;
|
|
526
|
-
};
|
|
527
|
-
uuid: (len?: number, radix?: number) => string;
|
|
528
|
-
getNewId: (len: number, prefix?: boolean, sep?: string) => string;
|
|
529
|
-
keyNumber: string;
|
|
530
|
-
keyLower: string;
|
|
531
|
-
keyUpper: string;
|
|
532
|
-
keyChars: string;
|
|
533
|
-
};
|
|
534
|
-
mini: {
|
|
535
|
-
diff: typeof import("./modules/mini/diff").default;
|
|
536
|
-
promixify: (miniapi: any) => any;
|
|
537
|
-
run: (func: any, args?: {}) => Promise<[any, undefined] | [null, any]>;
|
|
538
|
-
formatList: (lists: any[], start: any, name: any) => any;
|
|
539
|
-
ruleValidator: (_: any, value: any) => boolean;
|
|
540
|
-
Http: typeof import("./modules/mini/http").default;
|
|
541
|
-
setWatcher: (page: any) => void;
|
|
542
|
-
};
|
|
543
|
-
qs: {
|
|
544
|
-
parse: (qs: any, { sep, eq, max, multiple, uri, parseNumber, parseBoolean }?: {
|
|
545
|
-
sep?: string | undefined;
|
|
546
|
-
eq?: string | undefined;
|
|
547
|
-
max?: number | undefined;
|
|
548
|
-
multiple?: boolean | undefined;
|
|
549
|
-
uri?: boolean | undefined;
|
|
550
|
-
parseNumber?: boolean | undefined;
|
|
551
|
-
parseBoolean?: boolean | undefined;
|
|
552
|
-
}) => {};
|
|
553
|
-
stringify: (obj: any, { sep, eq, name, uri, cleanZero, cleanNull, cleanWhitespace }?: {
|
|
554
|
-
sep?: string | undefined;
|
|
555
|
-
eq?: string | undefined;
|
|
556
|
-
name?: null | undefined;
|
|
557
|
-
uri?: boolean | undefined;
|
|
558
|
-
cleanZero?: boolean | undefined;
|
|
559
|
-
cleanNull?: boolean | undefined;
|
|
560
|
-
cleanWhitespace?: boolean | undefined;
|
|
561
|
-
}) => string;
|
|
562
|
-
https: (url: string) => string;
|
|
563
|
-
parseUrl: (url: string) => {
|
|
564
|
-
url: string;
|
|
565
|
-
path: string;
|
|
566
|
-
page: string;
|
|
567
|
-
query: string;
|
|
568
|
-
params: {};
|
|
569
|
-
};
|
|
570
|
-
parsePath: (path: string) => {
|
|
571
|
-
root: string;
|
|
572
|
-
name: string;
|
|
573
|
-
withoutExtension: string;
|
|
574
|
-
extension: string;
|
|
575
|
-
};
|
|
576
|
-
join: (...args: string[]) => string;
|
|
577
|
-
};
|
|
578
|
-
css: {
|
|
579
|
-
stringify: (styleObj: Record<string, string | number>) => string;
|
|
580
|
-
parse: (styleStr: string, { camel, pure }?: {
|
|
581
|
-
camel?: boolean | undefined;
|
|
582
|
-
pure?: boolean | undefined;
|
|
583
|
-
}) => {} | undefined;
|
|
584
|
-
fixValue: (value: string | number, unit?: string) => string | number;
|
|
585
|
-
style: (cssKV: Record<string, any>, unit?: string) => string;
|
|
586
|
-
commonFields: string[];
|
|
587
|
-
};
|
|
588
|
-
cdn: {
|
|
589
|
-
ossImage: (url: string, options?: {
|
|
590
|
-
webp?: boolean | undefined;
|
|
591
|
-
resize?: number | undefined;
|
|
592
|
-
interlace?: boolean | undefined;
|
|
593
|
-
domain?: string | string[] | undefined;
|
|
594
|
-
}) => string;
|
|
595
|
-
ossSnapshot: (url: string, options?: {
|
|
596
|
-
t?: number | undefined;
|
|
597
|
-
w?: number | undefined;
|
|
598
|
-
h?: number | undefined;
|
|
599
|
-
m?: "" | "fast" | undefined;
|
|
600
|
-
f?: "jpg" | "png" | undefined;
|
|
601
|
-
ar?: "auto" | "h" | "w" | undefined;
|
|
602
|
-
}) => string;
|
|
603
|
-
};
|
|
604
|
-
html: {
|
|
605
|
-
dataURLtoFile: (dataurl: any, filename: any) => File;
|
|
606
|
-
dataURLtoBlob: (dataurl: any) => Blob;
|
|
607
|
-
blobToFile: (theBlob: any, fileName: any) => any;
|
|
608
|
-
readAsDataURL: (file: any, cb: any) => void;
|
|
609
|
-
downloadUrl: (filename: string, url: string) => void;
|
|
610
|
-
download: (filename: string, obj: string | Blob | MediaSource) => void;
|
|
611
|
-
downloadImage: (url: string) => Promise<void> | undefined;
|
|
612
|
-
watermark: (text: string, { width, height, angle, fillStyle, font, textAlign, textBaseline }?: {
|
|
613
|
-
width?: number | undefined;
|
|
614
|
-
height?: number | undefined;
|
|
615
|
-
angle?: number | undefined;
|
|
616
|
-
fillStyle?: string | undefined;
|
|
617
|
-
font?: string | undefined;
|
|
618
|
-
textAlign?: "center" | "end" | "left" | "right" | "start" | undefined;
|
|
619
|
-
textBaseline?: "alphabetic" | "bottom" | "hanging" | "ideographic" | "middle" | "top" | undefined;
|
|
620
|
-
}) => string;
|
|
621
|
-
};
|
|
622
|
-
icon: import("./class/icon").DIcon;
|
|
623
|
-
rule: {
|
|
624
|
-
validateId: (content: any) => boolean;
|
|
625
|
-
validatePhone: (content: any) => boolean;
|
|
626
|
-
validator: (rules: import("./modules/rule/async-validator").Rules) => import("./modules/rule/async-validator").default;
|
|
627
|
-
validate: (rules: import("./modules/rule/async-validator").Rules, source_: import("./modules/rule/async-validator").Values, o?: any, oc?: any) => Promise<import("./modules/rule/async-validator").Values>;
|
|
628
|
-
isChinese: (content: string) => boolean;
|
|
629
|
-
isNumber: (content: string) => boolean;
|
|
630
|
-
isFloat: (content: string) => boolean;
|
|
631
|
-
isPhoneNumber: (content: any) => boolean;
|
|
632
|
-
};
|
|
633
|
-
regex: {
|
|
634
|
-
pattern: {
|
|
635
|
-
num: string;
|
|
636
|
-
zh: string;
|
|
637
|
-
en: string;
|
|
638
|
-
};
|
|
639
|
-
regex: (patt: string, modifiers?: "i" | "g" | "m" | undefined) => RegExp;
|
|
640
|
-
entire: {
|
|
641
|
-
chinese: RegExp;
|
|
642
|
-
real: RegExp;
|
|
643
|
-
cssReal: RegExp;
|
|
644
|
-
id: RegExp;
|
|
645
|
-
yyyyMMdd: RegExp;
|
|
646
|
-
};
|
|
647
|
-
};
|
|
648
|
-
convert: {
|
|
649
|
-
uint8ArrayToString: (arr: any) => string;
|
|
650
|
-
stringToArrayBuffer: (str: any) => ArrayBuffer;
|
|
651
|
-
arrayBufferToString: (data: ArrayBuffer, base64?: boolean) => string;
|
|
652
|
-
};
|
|
653
|
-
Event: typeof Event;
|
|
654
|
-
Http: typeof Http;
|
|
655
|
-
Store: typeof Store;
|
|
656
|
-
storeRef: (source: import("./typings").dd.IDStore, persistConfig?: import("./typings").dd.IDPersistConfig | undefined) => any;
|
|
657
|
-
Persist: typeof Persist;
|
|
658
|
-
persistConfig: (key: string, fields: string[], storage: import("./typings").dd.DStorage) => import("./typings").dd.IDPersistConfig;
|
|
659
|
-
watermark: (bg: string, size?: {
|
|
660
|
-
width?: number | undefined;
|
|
661
|
-
height?: number | undefined;
|
|
662
|
-
} | undefined) => import("./class/watermark").DWatermark;
|
|
663
|
-
joker: import("./class/joker").Joker;
|
|
664
|
-
tracker: import("./class/tracker").DTracker;
|
|
665
|
-
logger: {
|
|
666
|
-
override: () => void;
|
|
667
|
-
log: (...args: any[]) => void;
|
|
668
|
-
info: (...args: any[]) => void;
|
|
669
|
-
warn: (...args: any[]) => void;
|
|
670
|
-
error: (...args: any[]) => void;
|
|
671
|
-
config: ({ tag, format }?: {
|
|
672
|
-
tag?: boolean | undefined;
|
|
673
|
-
format?: string | undefined;
|
|
674
|
-
}) => void;
|
|
675
|
-
};
|
|
676
|
-
fetch: {
|
|
677
|
-
getDataURL: (url: string) => Promise<[any, undefined] | [null, {
|
|
678
|
-
contentType: string;
|
|
679
|
-
dataUrl: string;
|
|
680
|
-
}]>;
|
|
681
|
-
getArrayBuffer: (url: string) => Promise<[any, undefined] | [null, ArrayBuffer]>;
|
|
682
|
-
getJson: (url: string) => Promise<[any, undefined] | [null, any]>;
|
|
683
|
-
download: (url: string, opts?: {
|
|
684
|
-
success?: ((buffer: Uint8Array) => void) | undefined;
|
|
685
|
-
progress?: ((percentage: number, current: number, total: number) => void) | undefined;
|
|
686
|
-
fail?: ((error: Error) => void) | undefined;
|
|
687
|
-
}) => Promise<Uint8Array | undefined>;
|
|
688
|
-
};
|
|
689
|
-
};
|
|
690
|
-
export default _default;
|
|
@@ -3,6 +3,7 @@ import throttle from "./throttle";
|
|
|
3
3
|
import mutex from "./mutex";
|
|
4
4
|
import DPipeTask from "../../class/pipeTask";
|
|
5
5
|
import { Ddan } from "../../typings";
|
|
6
|
+
import polling from "./polling";
|
|
6
7
|
/**
|
|
7
8
|
*
|
|
8
9
|
* @param task 任务
|
|
@@ -10,6 +11,15 @@ import { Ddan } from "../../typings";
|
|
|
10
11
|
* @returns
|
|
11
12
|
*/
|
|
12
13
|
declare function run<T = any>(task?: Promise<T> | Function, wait?: number): Promise<[any, undefined] | [null, T]>;
|
|
14
|
+
/**
|
|
15
|
+
* 设置单例模式
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
declare function singleton<T>(): {
|
|
19
|
+
new (): {};
|
|
20
|
+
__instance__: any;
|
|
21
|
+
readonly Instance: T;
|
|
22
|
+
};
|
|
13
23
|
declare const _default: {
|
|
14
24
|
run: typeof run;
|
|
15
25
|
exec: (func: Function, taskId?: string) => Promise<any[]>;
|
|
@@ -17,6 +27,8 @@ declare const _default: {
|
|
|
17
27
|
throttle: typeof throttle;
|
|
18
28
|
task: (param?: Ddan.Func1<any, any> | undefined) => DPipeTask;
|
|
19
29
|
mutex: typeof mutex;
|
|
30
|
+
polling: typeof polling;
|
|
31
|
+
singleton: typeof singleton;
|
|
20
32
|
to: <T = any, U extends object = any>(promise: Promise<T>, errorExt?: object | undefined) => Promise<[null, T] | [U, undefined]>;
|
|
21
33
|
delay: (time?: number) => Promise<unknown>;
|
|
22
34
|
};
|
|
@@ -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;
|