ddan-js 2.3.8 → 2.4.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.esm.js +1 -1
- package/bin/ddan-js.js +1 -1
- package/bin/lib/index.js +34 -32
- package/bin/lib/typings/index.js +6 -2
- package/bin/types/class/event.d.ts +2 -1
- package/bin/types/class/persist.d.ts +6 -6
- package/bin/types/class/store.d.ts +7 -7
- package/bin/types/index.d.ts +328 -2
- package/bin/types/typings/index.d.ts +48 -30
- package/package.json +1 -1
package/bin/types/index.d.ts
CHANGED
|
@@ -304,9 +304,9 @@ declare const dClass: {
|
|
|
304
304
|
};
|
|
305
305
|
declare const dStore: {
|
|
306
306
|
Store: typeof Store;
|
|
307
|
-
storeRef: (source: import("./typings").
|
|
307
|
+
storeRef: (source: import("./typings").Ddan.IDStore, persistConfig?: import("./typings").Ddan.IDPersistConfig | undefined) => any;
|
|
308
308
|
Persist: typeof Persist;
|
|
309
|
-
persistConfig: (key: string, fields: string[], storage: import("./typings").
|
|
309
|
+
persistConfig: (key: string, fields: string[], storage: import("./typings").Ddan.IStorage) => import("./typings").Ddan.IDPersistConfig;
|
|
310
310
|
};
|
|
311
311
|
declare const dJoker: import("./class/joker").Joker;
|
|
312
312
|
declare const dTracker: import("./class/tracker").DTracker;
|
|
@@ -409,3 +409,329 @@ declare const dWeb: {
|
|
|
409
409
|
};
|
|
410
410
|
};
|
|
411
411
|
export { dUtil, dHook, dWeb, dMini, dCdn, dClass, dStore, dJoker, dTracker, dLogger };
|
|
412
|
+
declare const _default: {
|
|
413
|
+
gbk: {
|
|
414
|
+
gbkLength: (str: string) => number;
|
|
415
|
+
gbkCut: (source: string, len: number) => string;
|
|
416
|
+
};
|
|
417
|
+
time: {
|
|
418
|
+
now: () => import("./modules/time/dtime").default;
|
|
419
|
+
isToday: (date: any) => any;
|
|
420
|
+
parseTimestamp: ({ year, month, date, hour, minute, second }: {
|
|
421
|
+
year?: number | undefined;
|
|
422
|
+
month?: number | undefined;
|
|
423
|
+
date?: number | undefined;
|
|
424
|
+
hour?: number | undefined;
|
|
425
|
+
minute?: number | undefined;
|
|
426
|
+
second?: number | undefined;
|
|
427
|
+
}) => number;
|
|
428
|
+
todayZero: () => number;
|
|
429
|
+
format: (time: string | number | Date, reg?: string) => string;
|
|
430
|
+
countdown: (endTime: string | number | Date, reg?: string) => "" | import("./modules/time/dtime").IDCountdownFormat;
|
|
431
|
+
dtime: (time: string | number | Date) => import("./modules/time/dtime").default;
|
|
432
|
+
loopFrame: (interval?: number) => import("./modules/time/frame").default;
|
|
433
|
+
oneDay: number;
|
|
434
|
+
oneHour: number;
|
|
435
|
+
oneMinute: number;
|
|
436
|
+
oneSecond: number;
|
|
437
|
+
};
|
|
438
|
+
hook: {
|
|
439
|
+
run: <T = any>(task?: Function | Promise<T> | undefined, wait?: number) => Promise<[any, undefined] | [null, T]>;
|
|
440
|
+
exec: (func: Function, taskId?: string) => Promise<any[]>;
|
|
441
|
+
debounce: typeof import("./modules/hook/debounce").default;
|
|
442
|
+
throttle: typeof import("./modules/hook/throttle").default;
|
|
443
|
+
task: (param?: import("./typings").Ddan.Func1<any, any> | undefined) => import("./class/pipeTask").default;
|
|
444
|
+
mutex: typeof import("./modules/hook/mutex").default;
|
|
445
|
+
polling: typeof import("./modules/hook/polling").default;
|
|
446
|
+
singleton: <T_1>() => {
|
|
447
|
+
new (): {};
|
|
448
|
+
__instance__: any;
|
|
449
|
+
readonly Instance: T_1;
|
|
450
|
+
};
|
|
451
|
+
to: <T_2 = any, U extends object = any>(promise: Promise<T_2>, errorExt?: object | undefined) => Promise<[null, T_2] | [U, undefined]>;
|
|
452
|
+
delay: (time?: number) => Promise<unknown>;
|
|
453
|
+
};
|
|
454
|
+
math: {
|
|
455
|
+
random: (max: number) => number;
|
|
456
|
+
randomRange: (min: number, max: number) => number;
|
|
457
|
+
lerp: (start: number, end: number, t: number) => number;
|
|
458
|
+
randoms: (max: number, count?: number, repeat?: boolean) => number[];
|
|
459
|
+
strip: (num: string | number, digits?: number) => number;
|
|
460
|
+
float: (num: string | number, { digits, fixed }?: {
|
|
461
|
+
digits?: number | undefined;
|
|
462
|
+
fixed?: boolean | undefined;
|
|
463
|
+
}) => number;
|
|
464
|
+
radian2degree: (radians: number) => number;
|
|
465
|
+
degree2radian: (degrees: number) => number;
|
|
466
|
+
formatMemory: (mem: number) => {
|
|
467
|
+
g: number;
|
|
468
|
+
m: number;
|
|
469
|
+
kb: number;
|
|
470
|
+
b: number;
|
|
471
|
+
desc: string;
|
|
472
|
+
};
|
|
473
|
+
};
|
|
474
|
+
util: {
|
|
475
|
+
includes: typeof import("./util/includes").default;
|
|
476
|
+
forof: (source: any, cb: (key: any, val: any) => void) => void;
|
|
477
|
+
copy: (source: any, options?: {
|
|
478
|
+
fields?: string[] | undefined;
|
|
479
|
+
camel?: boolean | undefined;
|
|
480
|
+
pure?: boolean | undefined;
|
|
481
|
+
} & import("./typings").dd.IIgnoreParams) => any;
|
|
482
|
+
clone: (source: any) => any;
|
|
483
|
+
merge: (target: any, source: any, options?: import("./typings").dd.IIgnoreParams) => {};
|
|
484
|
+
isEmpty: (source: any) => boolean;
|
|
485
|
+
parseValue: (source: any, { number, boolean }?: {
|
|
486
|
+
number?: boolean | undefined;
|
|
487
|
+
boolean?: boolean | undefined;
|
|
488
|
+
}) => any;
|
|
489
|
+
cloneClass: <T_3>(source: T_3) => T_3;
|
|
490
|
+
combine: (target: any, source: any, options?: import("./typings").dd.IIgnoreParams) => any;
|
|
491
|
+
combines: (objs: any[], options?: import("./typings").dd.IIgnoreParams) => {};
|
|
492
|
+
observe: (obj: any, key: any, watchFun: any, owner: any, deep?: boolean) => void;
|
|
493
|
+
getTag: (value: any) => string;
|
|
494
|
+
getType: (value: any) => string;
|
|
495
|
+
toString: () => string;
|
|
496
|
+
hasOwnProperty: (v: PropertyKey) => boolean;
|
|
497
|
+
propertyIsEnumerable: (v: PropertyKey) => boolean;
|
|
498
|
+
is: (val: any, type: string) => boolean;
|
|
499
|
+
isNumber: (value: any) => boolean;
|
|
500
|
+
isString: (value: any) => boolean;
|
|
501
|
+
isObject: (value: any) => boolean;
|
|
502
|
+
isObjectLike: (value: any) => boolean;
|
|
503
|
+
isPlainObject: (value: any) => boolean;
|
|
504
|
+
isSymbol: (value: any) => boolean;
|
|
505
|
+
isFunction: (value: any) => boolean;
|
|
506
|
+
isArray: (arg: any) => arg is any[];
|
|
507
|
+
isArrayLikeObject: (value: any) => boolean;
|
|
508
|
+
isIndex: (value: any, length: number) => boolean;
|
|
509
|
+
isArrayLike: (value: any) => boolean;
|
|
510
|
+
isPrototype: (value: any) => boolean;
|
|
511
|
+
isArguments: (value: any) => boolean;
|
|
512
|
+
isPromise: (value: any) => boolean;
|
|
513
|
+
};
|
|
514
|
+
list: {
|
|
515
|
+
stepAction: <T_4>(list: T_4[], func: import("./typings").Ddan.Task<T_4, void>, stepCount?: number) => void;
|
|
516
|
+
skip: <T_5>(list: T_5[], count: number) => T_5[];
|
|
517
|
+
take: <T_6>(list: T_6[], count: number, skip?: number) => T_6[];
|
|
518
|
+
distinct: <T_7>(list: T_7[]) => T_7[];
|
|
519
|
+
randoms: <T_8>(list: T_8[], count?: number, repeat?: boolean) => T_8[];
|
|
520
|
+
toKV: (list: import("./typings").Ddan.KV<any>[], key: string, value: string) => import("./typings").Ddan.KV<any>;
|
|
521
|
+
groupBy: <T_9>(list: T_9[], key: string) => Record<string, T_9[]>;
|
|
522
|
+
first: <T_10>(list: T_10[]) => T_10 | undefined;
|
|
523
|
+
last: <T_11>(list: T_11[]) => T_11 | undefined;
|
|
524
|
+
toList: <T_12>(val: T_12 | T_12[]) => T_12[];
|
|
525
|
+
};
|
|
526
|
+
string: {
|
|
527
|
+
toString: (value: any) => any;
|
|
528
|
+
startCase: (string: any) => any;
|
|
529
|
+
snakeCase: (string: any) => any;
|
|
530
|
+
kebabCase: (string: any) => any;
|
|
531
|
+
camelCase: (string: any) => any;
|
|
532
|
+
upperCase: (string: any) => any;
|
|
533
|
+
upperFirst: (string: any) => any;
|
|
534
|
+
lowerCase: (string: any) => any;
|
|
535
|
+
lowerFirst: (string: any) => any;
|
|
536
|
+
splitOnFirst: (string: any, separator: any) => string[];
|
|
537
|
+
parseValue: (value?: any, { number, boolean }?: {
|
|
538
|
+
number?: boolean | undefined;
|
|
539
|
+
boolean?: boolean | undefined;
|
|
540
|
+
}) => any;
|
|
541
|
+
replace: (source: string, rules: import("./typings").dd.IRegexRule | import("./typings").dd.IRegexRule[]) => string;
|
|
542
|
+
};
|
|
543
|
+
obj: {
|
|
544
|
+
copy: (source: any, options?: {
|
|
545
|
+
fields?: string[] | undefined;
|
|
546
|
+
camel?: boolean | undefined;
|
|
547
|
+
pure?: boolean | undefined;
|
|
548
|
+
} & import("./typings").dd.IIgnoreParams) => any;
|
|
549
|
+
clone: (source: any) => any;
|
|
550
|
+
merge: (target: any, source: any, options?: import("./typings").dd.IIgnoreParams) => {};
|
|
551
|
+
isEmpty: (source: any) => boolean;
|
|
552
|
+
parseValue: (source: any, { number, boolean }?: {
|
|
553
|
+
number?: boolean | undefined;
|
|
554
|
+
boolean?: boolean | undefined;
|
|
555
|
+
}) => any;
|
|
556
|
+
cloneClass: <T_3>(source: T_3) => T_3;
|
|
557
|
+
combine: (target: any, source: any, options?: import("./typings").dd.IIgnoreParams) => any;
|
|
558
|
+
combines: (objs: any[], options?: import("./typings").dd.IIgnoreParams) => {};
|
|
559
|
+
observe: (obj: any, key: any, watchFun: any, owner: any, deep?: boolean) => void;
|
|
560
|
+
};
|
|
561
|
+
crypto: {
|
|
562
|
+
base64: {
|
|
563
|
+
encode: (input: string) => string;
|
|
564
|
+
decode: (input: string) => string;
|
|
565
|
+
encodeByOss: (input: string) => string;
|
|
566
|
+
};
|
|
567
|
+
uuid: (len?: number, radix?: number) => string;
|
|
568
|
+
getNewId: (len: number, prefix?: boolean, sep?: string) => string;
|
|
569
|
+
keyNumber: string;
|
|
570
|
+
keyLower: string;
|
|
571
|
+
keyUpper: string;
|
|
572
|
+
keyChars: string;
|
|
573
|
+
};
|
|
574
|
+
mini: {
|
|
575
|
+
diff: typeof import("./modules/mini/diff").default;
|
|
576
|
+
promixify: (miniapi: any) => any;
|
|
577
|
+
run: (func: any, args?: {}) => Promise<[any, undefined] | [null, any]>;
|
|
578
|
+
formatList: (lists: any[], start: any, name: any) => any;
|
|
579
|
+
ruleValidator: (_: any, value: any) => boolean;
|
|
580
|
+
Http: typeof import("./modules/mini/http").default;
|
|
581
|
+
setWatcher: (page: any) => void;
|
|
582
|
+
};
|
|
583
|
+
qs: {
|
|
584
|
+
parse: (qs: any, { sep, eq, max, multiple, uri, parseNumber, parseBoolean }?: {
|
|
585
|
+
sep?: string | undefined;
|
|
586
|
+
eq?: string | undefined;
|
|
587
|
+
max?: number | undefined;
|
|
588
|
+
multiple?: boolean | undefined;
|
|
589
|
+
uri?: boolean | undefined;
|
|
590
|
+
parseNumber?: boolean | undefined;
|
|
591
|
+
parseBoolean?: boolean | undefined;
|
|
592
|
+
}) => {};
|
|
593
|
+
stringify: (obj: any, { sep, eq, name, uri, cleanZero, cleanNull, cleanWhitespace }?: {
|
|
594
|
+
sep?: string | undefined;
|
|
595
|
+
eq?: string | undefined;
|
|
596
|
+
name?: null | undefined;
|
|
597
|
+
uri?: boolean | undefined;
|
|
598
|
+
cleanZero?: boolean | undefined;
|
|
599
|
+
cleanNull?: boolean | undefined;
|
|
600
|
+
cleanWhitespace?: boolean | undefined;
|
|
601
|
+
}) => string;
|
|
602
|
+
https: (url: string) => string;
|
|
603
|
+
parseUrl: (url: string) => {
|
|
604
|
+
host: string;
|
|
605
|
+
origin: string;
|
|
606
|
+
url: string;
|
|
607
|
+
path: string;
|
|
608
|
+
page: string;
|
|
609
|
+
query: string;
|
|
610
|
+
filename: string;
|
|
611
|
+
filenameWithoutExtension: string;
|
|
612
|
+
extension: string;
|
|
613
|
+
route: string;
|
|
614
|
+
params: {};
|
|
615
|
+
};
|
|
616
|
+
parsePath: (path: string) => {
|
|
617
|
+
root: string;
|
|
618
|
+
name: string;
|
|
619
|
+
withoutExtension: string;
|
|
620
|
+
extension: string;
|
|
621
|
+
};
|
|
622
|
+
join: (...args: string[]) => string;
|
|
623
|
+
};
|
|
624
|
+
css: {
|
|
625
|
+
stringify: (styleObj: Record<string, string | number>) => string;
|
|
626
|
+
parse: (styleStr: string, { camel, pure }?: {
|
|
627
|
+
camel?: boolean | undefined;
|
|
628
|
+
pure?: boolean | undefined;
|
|
629
|
+
}) => {} | undefined;
|
|
630
|
+
fixValue: (value: string | number, unit?: string) => string | number;
|
|
631
|
+
style: (cssKV: Record<string, any>, unit?: string) => string;
|
|
632
|
+
commonFields: string[];
|
|
633
|
+
};
|
|
634
|
+
cdn: {
|
|
635
|
+
ossImage: (url: string, options?: {
|
|
636
|
+
webp?: boolean | undefined;
|
|
637
|
+
resize?: number | undefined;
|
|
638
|
+
interlace?: boolean | undefined;
|
|
639
|
+
domain?: string | string[] | undefined;
|
|
640
|
+
}) => string;
|
|
641
|
+
ossSnapshot: (url: string, options?: {
|
|
642
|
+
t?: number | undefined;
|
|
643
|
+
w?: number | undefined;
|
|
644
|
+
h?: number | undefined;
|
|
645
|
+
m?: "" | "fast" | undefined;
|
|
646
|
+
f?: "jpg" | "png" | undefined;
|
|
647
|
+
ar?: "auto" | "h" | "w" | undefined;
|
|
648
|
+
}) => string;
|
|
649
|
+
};
|
|
650
|
+
html: {
|
|
651
|
+
dataURLtoFile: (dataurl: any, filename: any) => File;
|
|
652
|
+
dataURLtoBlob: (dataurl: any) => Blob;
|
|
653
|
+
blobToFile: (blob: any, fileName: string) => any;
|
|
654
|
+
readAsDataURL: (file: any, cb: any) => void;
|
|
655
|
+
downloadUrl: (url: string, filename?: string, checkSomeOrigin?: boolean) => void;
|
|
656
|
+
download: (urlOrFile: string | Blob | MediaSource, filename?: string) => void;
|
|
657
|
+
downloadFile: (data: Blob | MediaSource, filename?: string) => void;
|
|
658
|
+
downloadImage: (url: string) => Promise<void> | undefined;
|
|
659
|
+
watermark: (text: string, { width, height, angle, fillStyle, font, textAlign, textBaseline }?: {
|
|
660
|
+
width?: number | undefined;
|
|
661
|
+
height?: number | undefined;
|
|
662
|
+
angle?: number | undefined;
|
|
663
|
+
fillStyle?: string | undefined;
|
|
664
|
+
font?: string | undefined;
|
|
665
|
+
textAlign?: "center" | "end" | "left" | "right" | "start" | undefined;
|
|
666
|
+
textBaseline?: "alphabetic" | "bottom" | "hanging" | "ideographic" | "middle" | "top" | undefined;
|
|
667
|
+
}) => string;
|
|
668
|
+
};
|
|
669
|
+
icon: import("./class/icon").DIcon;
|
|
670
|
+
rule: {
|
|
671
|
+
validateId: (content: any) => boolean;
|
|
672
|
+
validatePhone: (content: any) => boolean;
|
|
673
|
+
validator: (rules: import("./modules/rule/async-validator").Rules) => import("./modules/rule/async-validator").default;
|
|
674
|
+
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>;
|
|
675
|
+
isChinese: (content: string) => boolean;
|
|
676
|
+
isNumber: (content: string) => boolean;
|
|
677
|
+
isFloat: (content: string) => boolean;
|
|
678
|
+
isPhoneNumber: (content: any) => boolean;
|
|
679
|
+
};
|
|
680
|
+
regex: {
|
|
681
|
+
pattern: {
|
|
682
|
+
num: string;
|
|
683
|
+
zh: string;
|
|
684
|
+
en: string;
|
|
685
|
+
};
|
|
686
|
+
regex: (patt: string, modifiers?: "i" | "g" | "m" | undefined) => RegExp;
|
|
687
|
+
entire: {
|
|
688
|
+
chinese: RegExp;
|
|
689
|
+
real: RegExp;
|
|
690
|
+
cssReal: RegExp;
|
|
691
|
+
id: RegExp;
|
|
692
|
+
yyyyMMdd: RegExp;
|
|
693
|
+
};
|
|
694
|
+
};
|
|
695
|
+
convert: {
|
|
696
|
+
uint8ArrayToString: (arr: any) => string;
|
|
697
|
+
stringToArrayBuffer: (str: any) => ArrayBuffer;
|
|
698
|
+
arrayBufferToString: (data: ArrayBuffer, base64?: boolean) => string;
|
|
699
|
+
};
|
|
700
|
+
Event: typeof Event;
|
|
701
|
+
Http: typeof Http;
|
|
702
|
+
Store: typeof Store;
|
|
703
|
+
storeRef: (source: import("./typings").Ddan.IDStore, persistConfig?: import("./typings").Ddan.IDPersistConfig | undefined) => any;
|
|
704
|
+
Persist: typeof Persist;
|
|
705
|
+
persistConfig: (key: string, fields: string[], storage: import("./typings").Ddan.IStorage) => import("./typings").Ddan.IDPersistConfig;
|
|
706
|
+
watermark: (bg: string, size?: {
|
|
707
|
+
width?: number | undefined;
|
|
708
|
+
height?: number | undefined;
|
|
709
|
+
} | undefined) => import("./class/watermark").DWatermark;
|
|
710
|
+
joker: import("./class/joker").Joker;
|
|
711
|
+
tracker: import("./class/tracker").DTracker;
|
|
712
|
+
logger: {
|
|
713
|
+
override: () => void;
|
|
714
|
+
log: (...args: any[]) => void;
|
|
715
|
+
info: (...args: any[]) => void;
|
|
716
|
+
warn: (...args: any[]) => void;
|
|
717
|
+
error: (...args: any[]) => void;
|
|
718
|
+
config: ({ tag, format }?: {
|
|
719
|
+
tag?: boolean | undefined;
|
|
720
|
+
format?: string | undefined;
|
|
721
|
+
}) => void;
|
|
722
|
+
};
|
|
723
|
+
fetch: {
|
|
724
|
+
getDataURL: (url: string) => Promise<[any, undefined] | [null, {
|
|
725
|
+
contentType: string;
|
|
726
|
+
dataUrl: string;
|
|
727
|
+
}]>;
|
|
728
|
+
getArrayBuffer: (url: string) => Promise<[any, undefined] | [null, ArrayBuffer]>;
|
|
729
|
+
getJson: (url: string) => Promise<[any, undefined] | [null, any]>;
|
|
730
|
+
download: (url: string, opts?: {
|
|
731
|
+
success?: ((buffer: Uint8Array) => void) | undefined;
|
|
732
|
+
progress?: ((percentage: number, current: number, total: number) => void) | undefined;
|
|
733
|
+
fail?: ((error: Error) => void) | undefined;
|
|
734
|
+
}) => Promise<Uint8Array | undefined>;
|
|
735
|
+
};
|
|
736
|
+
};
|
|
737
|
+
export default _default;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import DPersist from "../class/persist";
|
|
2
1
|
export declare namespace Ddan {
|
|
3
2
|
type KV<T = any> = Record<string, T>;
|
|
4
|
-
|
|
3
|
+
interface IKeyValuePart<T = any> {
|
|
5
4
|
key: string;
|
|
6
5
|
value: T;
|
|
7
|
-
}
|
|
8
|
-
type KeyValue<T = any> = Required<
|
|
6
|
+
}
|
|
7
|
+
type KeyValue<T = any> = Required<IKeyValuePart<T>>;
|
|
8
|
+
type Function = (...args: any[]) => void;
|
|
9
9
|
type Callback<T extends any[] = unknown[], R = any> = (...args: T) => R;
|
|
10
10
|
type Action<T extends any[] = unknown[]> = Callback<T, void>;
|
|
11
11
|
type Task<T = any, R = void> = Callback<[T[]], R>;
|
|
@@ -15,33 +15,25 @@ export declare namespace Ddan {
|
|
|
15
15
|
type Func3<T0 = any, T1 = any, T2 = any, R = any> = Callback<[T0, T1, T2], R>;
|
|
16
16
|
type Func4<T0 = any, T1 = any, T2 = any, T3 = any, R = any> = Callback<[T0, T1, T2, T3], R>;
|
|
17
17
|
type Result<T = any> = T | Promise<T>;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
maxWait?: number;
|
|
28
|
-
trailing?: boolean;
|
|
18
|
+
interface IEvent {
|
|
19
|
+
clear: () => void;
|
|
20
|
+
on: (name: string, handler: Function, tag: string) => void;
|
|
21
|
+
emit: (name: string, ...args: any[]) => void;
|
|
22
|
+
off: (name: string, handler: Function) => void;
|
|
23
|
+
remove: (name: string) => void;
|
|
24
|
+
removeByTag: (tag: string) => void;
|
|
25
|
+
once: (name: string, handler: Function) => void;
|
|
26
|
+
has: (name: string) => boolean;
|
|
29
27
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
[key: string]: any;
|
|
38
|
-
getters?: Record<string, TStoreGetterFunction>;
|
|
39
|
-
setters?: Record<string, TStoreSetterFunction>;
|
|
40
|
-
actions?: Record<string, TStoreActionFunction>;
|
|
41
|
-
persist?: IDPersistConfig;
|
|
42
|
-
__persist?: DPersist;
|
|
28
|
+
interface IPersist {
|
|
29
|
+
key: string;
|
|
30
|
+
storage?: IStorage;
|
|
31
|
+
fields: string[];
|
|
32
|
+
save: (data: any) => any;
|
|
33
|
+
read: () => any;
|
|
34
|
+
handleSave: (target: IDStore, key: string) => void;
|
|
43
35
|
}
|
|
44
|
-
interface
|
|
36
|
+
interface IStorage {
|
|
45
37
|
getItem?: (key: string) => string | null;
|
|
46
38
|
removeItem?: (key: string) => void;
|
|
47
39
|
setItem?: (key: string, value: string) => void;
|
|
@@ -52,7 +44,33 @@ export declare namespace dd {
|
|
|
52
44
|
interface IDPersistConfig {
|
|
53
45
|
key: string;
|
|
54
46
|
fields: string[];
|
|
55
|
-
storage:
|
|
47
|
+
storage: IStorage;
|
|
48
|
+
}
|
|
49
|
+
interface IDStore {
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
getters?: Record<string, TStoreGetterFunction>;
|
|
52
|
+
setters?: Record<string, TStoreSetterFunction>;
|
|
53
|
+
actions?: Record<string, TStoreActionFunction>;
|
|
54
|
+
persist?: IDPersistConfig;
|
|
55
|
+
__persist?: IPersist;
|
|
56
|
+
}
|
|
57
|
+
type TStoreGetterFunction = (arg: IDStore) => any;
|
|
58
|
+
type TStoreCommitFunction = (name: string, payload: any) => void;
|
|
59
|
+
type TStoreSetterFunction = (arg: IDStore, payload: any) => boolean;
|
|
60
|
+
type TStoreActionFunction = (arg: IDStore & {
|
|
61
|
+
commit: TStoreCommitFunction;
|
|
62
|
+
}, payload: any) => any;
|
|
63
|
+
}
|
|
64
|
+
export declare namespace dd {
|
|
65
|
+
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
66
|
+
/**
|
|
67
|
+
* leading 开始执行
|
|
68
|
+
* trailing 结束执行
|
|
69
|
+
*/
|
|
70
|
+
interface IDebounceOption {
|
|
71
|
+
leading?: boolean;
|
|
72
|
+
maxWait?: number;
|
|
73
|
+
trailing?: boolean;
|
|
56
74
|
}
|
|
57
75
|
interface IHttpRequest {
|
|
58
76
|
url: string;
|