utils-lib-js 1.7.0 → 1.7.1
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/dist/bundle/array.d.ts +10 -10
- package/dist/bundle/base.d.ts +14 -14
- package/dist/bundle/element.d.ts +6 -6
- package/dist/bundle/event.d.ts +14 -14
- package/dist/bundle/function.d.ts +12 -12
- package/dist/bundle/index.d.ts +55 -55
- package/dist/bundle/object.d.ts +30 -30
- package/dist/bundle/request.d.ts +60 -60
- package/dist/bundle/static.d.ts +16 -16
- package/dist/bundle/storage.d.ts +9 -9
- package/dist/bundle/types.d.ts +103 -103
- package/dist/cjs/array.d.ts +10 -10
- package/dist/cjs/base.d.ts +14 -14
- package/dist/cjs/element.d.ts +6 -6
- package/dist/cjs/event.d.ts +14 -14
- package/dist/cjs/function.d.ts +12 -12
- package/dist/cjs/index.d.ts +55 -55
- package/dist/cjs/index.js +567 -567
- package/dist/cjs/object.d.ts +30 -30
- package/dist/cjs/request.d.ts +60 -60
- package/dist/cjs/static.d.ts +16 -16
- package/dist/cjs/storage.d.ts +9 -9
- package/dist/cjs/types.d.ts +103 -103
- package/dist/esm/array.d.ts +10 -10
- package/dist/esm/base.d.ts +14 -14
- package/dist/esm/element.d.ts +6 -6
- package/dist/esm/event.d.ts +14 -14
- package/dist/esm/function.d.ts +12 -12
- package/dist/esm/index.d.ts +55 -55
- package/dist/esm/index.js +567 -567
- package/dist/esm/object.d.ts +30 -30
- package/dist/esm/request.d.ts +60 -60
- package/dist/esm/static.d.ts +16 -16
- package/dist/esm/storage.d.ts +9 -9
- package/dist/esm/types.d.ts +103 -103
- package/dist/umd/array.d.ts +10 -10
- package/dist/umd/base.d.ts +14 -14
- package/dist/umd/element.d.ts +6 -6
- package/dist/umd/event.d.ts +14 -14
- package/dist/umd/function.d.ts +12 -12
- package/dist/umd/index.d.ts +55 -55
- package/dist/umd/index.js +567 -567
- package/dist/umd/object.d.ts +30 -30
- package/dist/umd/request.d.ts +60 -60
- package/dist/umd/static.d.ts +16 -16
- package/dist/umd/storage.d.ts +9 -9
- package/dist/umd/types.d.ts +103 -103
- package/example.js +2 -0
- package/package.json +49 -54
- package/pnpm-lock.yaml +8 -113
- package/rollup.config.js +2 -5
package/dist/cjs/object.d.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { IGetValue, ISetValue, IMixIn, ICloneDeep, ICreateObjectVariable, IEnumInversion, IInherit, ICreateObject, IGetInstance, IClassDecorator, IStringToJson, IJsonToString } from "./index";
|
|
2
|
-
export declare const getValue: IGetValue;
|
|
3
|
-
export declare const setValue: ISetValue;
|
|
4
|
-
export declare const mixIn: IMixIn;
|
|
5
|
-
export declare const enumInversion: IEnumInversion;
|
|
6
|
-
export declare const isNotObject: (source: any, type: any) => boolean;
|
|
7
|
-
export declare const cloneDeep: ICloneDeep;
|
|
8
|
-
export declare const createObjectVariable: ICreateObjectVariable;
|
|
9
|
-
export declare const createObject: ICreateObject;
|
|
10
|
-
export declare const inherit: IInherit;
|
|
11
|
-
export declare const getInstance: IGetInstance;
|
|
12
|
-
export declare const classDecorator: IClassDecorator;
|
|
13
|
-
export declare const stringToJson: IStringToJson;
|
|
14
|
-
export declare const jsonToString: IJsonToString;
|
|
15
|
-
declare const _default: {
|
|
16
|
-
getValue: IGetValue;
|
|
17
|
-
setValue: ISetValue;
|
|
18
|
-
mixIn: IMixIn;
|
|
19
|
-
enumInversion: IEnumInversion;
|
|
20
|
-
isNotObject: (source: any, type: any) => boolean;
|
|
21
|
-
cloneDeep: ICloneDeep;
|
|
22
|
-
createObjectVariable: ICreateObjectVariable;
|
|
23
|
-
createObject: ICreateObject;
|
|
24
|
-
inherit: IInherit;
|
|
25
|
-
getInstance: IGetInstance;
|
|
26
|
-
classDecorator: IClassDecorator;
|
|
27
|
-
stringToJson: IStringToJson;
|
|
28
|
-
jsonToString: IJsonToString;
|
|
29
|
-
};
|
|
30
|
-
export default _default;
|
|
1
|
+
import { IGetValue, ISetValue, IMixIn, ICloneDeep, ICreateObjectVariable, IEnumInversion, IInherit, ICreateObject, IGetInstance, IClassDecorator, IStringToJson, IJsonToString } from "./index";
|
|
2
|
+
export declare const getValue: IGetValue;
|
|
3
|
+
export declare const setValue: ISetValue;
|
|
4
|
+
export declare const mixIn: IMixIn;
|
|
5
|
+
export declare const enumInversion: IEnumInversion;
|
|
6
|
+
export declare const isNotObject: (source: any, type: any) => boolean;
|
|
7
|
+
export declare const cloneDeep: ICloneDeep;
|
|
8
|
+
export declare const createObjectVariable: ICreateObjectVariable;
|
|
9
|
+
export declare const createObject: ICreateObject;
|
|
10
|
+
export declare const inherit: IInherit;
|
|
11
|
+
export declare const getInstance: IGetInstance;
|
|
12
|
+
export declare const classDecorator: IClassDecorator;
|
|
13
|
+
export declare const stringToJson: IStringToJson;
|
|
14
|
+
export declare const jsonToString: IJsonToString;
|
|
15
|
+
declare const _default: {
|
|
16
|
+
getValue: IGetValue;
|
|
17
|
+
setValue: ISetValue;
|
|
18
|
+
mixIn: IMixIn;
|
|
19
|
+
enumInversion: IEnumInversion;
|
|
20
|
+
isNotObject: (source: any, type: any) => boolean;
|
|
21
|
+
cloneDeep: ICloneDeep;
|
|
22
|
+
createObjectVariable: ICreateObjectVariable;
|
|
23
|
+
createObject: ICreateObject;
|
|
24
|
+
inherit: IInherit;
|
|
25
|
+
getInstance: IGetInstance;
|
|
26
|
+
classDecorator: IClassDecorator;
|
|
27
|
+
stringToJson: IStringToJson;
|
|
28
|
+
jsonToString: IJsonToString;
|
|
29
|
+
};
|
|
30
|
+
export default _default;
|
package/dist/cjs/request.d.ts
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import { IRequest, IRequestBase, IRequestInit, IInterceptors, IUrl, IObject, IRequestBody, IRequestOptions, IRequestBaseFn, IEnv } from "./index";
|
|
2
|
-
declare class Interceptors implements IInterceptors {
|
|
3
|
-
private requestSuccess;
|
|
4
|
-
private responseSuccess;
|
|
5
|
-
private error;
|
|
6
|
-
use(type: "request" | "response" | "error", fn: Function): IInterceptors;
|
|
7
|
-
get reqFn(): Function;
|
|
8
|
-
get resFn(): Function;
|
|
9
|
-
get errFn(): Function;
|
|
10
|
-
}
|
|
11
|
-
declare abstract class RequestBase extends Interceptors implements IRequestBase {
|
|
12
|
-
readonly origin: IUrl;
|
|
13
|
-
constructor(origin: IUrl);
|
|
14
|
-
abstract fetch(url: string, opts: IRequestOptions): Promise<void>;
|
|
15
|
-
abstract http(url: string, opts: IRequestOptions): Promise<void>;
|
|
16
|
-
chackUrl: (url: IUrl) => boolean;
|
|
17
|
-
checkIsHttps: (url: IUrl) => boolean;
|
|
18
|
-
fixOrigin: (fixStr: string) => string;
|
|
19
|
-
envDesc: () => IEnv;
|
|
20
|
-
errorFn: (reject: any) => (err: any) => any;
|
|
21
|
-
clearTimer: (opts: any) => any;
|
|
22
|
-
initAbort: (params: IRequestOptions) => IRequestOptions;
|
|
23
|
-
requestType: () => IRequestBaseFn;
|
|
24
|
-
getDataByType: (type: any, response: any) => any;
|
|
25
|
-
formatBodyString: (bodyString: string) => IObject<Function>;
|
|
26
|
-
}
|
|
27
|
-
declare abstract class RequestInit extends RequestBase implements IRequestInit {
|
|
28
|
-
constructor(origin: any);
|
|
29
|
-
abstract fetch(url: any, opts: any): Promise<void>;
|
|
30
|
-
abstract http(url: any, opts: any): Promise<void>;
|
|
31
|
-
initDefaultParams: (url: IUrl, { method, query, headers, body, timeout, controller, type, ...others }: {
|
|
32
|
-
[x: string]: any;
|
|
33
|
-
method?: string;
|
|
34
|
-
query?: {};
|
|
35
|
-
headers?: {};
|
|
36
|
-
body?: any;
|
|
37
|
-
timeout?: number;
|
|
38
|
-
controller?: any;
|
|
39
|
-
type?: string;
|
|
40
|
-
}) => IRequestOptions;
|
|
41
|
-
initFetchParams: (url: IUrl, opts: IRequestOptions) => any;
|
|
42
|
-
initHttpParams: (url: IUrl, opts: IRequestOptions) => any;
|
|
43
|
-
}
|
|
44
|
-
export declare class Request extends RequestInit implements IRequest {
|
|
45
|
-
private request;
|
|
46
|
-
constructor(origin: any);
|
|
47
|
-
fetch: (_url: string, _opts: IRequestOptions) => Promise<any>;
|
|
48
|
-
http: (_url: string, _opts: IRequestOptions) => Promise<any>;
|
|
49
|
-
GET: (url?: IUrl, query?: IObject<any>, _?: IRequestBody | void, opts?: IRequestOptions) => any;
|
|
50
|
-
POST: (url?: IUrl, query?: IObject<any>, body?: IRequestBody, opts?: IRequestOptions) => any;
|
|
51
|
-
PUT: (url?: IUrl, query?: IObject<any>, body?: IRequestBody, opts?: IRequestOptions) => any;
|
|
52
|
-
DELETE: (url?: IUrl, query?: IObject<any>, body?: IRequestBody, opts?: IRequestOptions) => any;
|
|
53
|
-
OPTIONS: (url?: IUrl, query?: IObject<any>, body?: IRequestBody, opts?: IRequestOptions) => any;
|
|
54
|
-
HEAD: (url?: IUrl, query?: IObject<any>, body?: IRequestBody, opts?: IRequestOptions) => any;
|
|
55
|
-
PATCH: (url?: IUrl, query?: IObject<any>, body?: IRequestBody, opts?: IRequestOptions) => any;
|
|
56
|
-
}
|
|
57
|
-
declare const _default: {
|
|
58
|
-
Request: typeof Request;
|
|
59
|
-
};
|
|
60
|
-
export default _default;
|
|
1
|
+
import { IRequest, IRequestBase, IRequestInit, IInterceptors, IUrl, IObject, IRequestBody, IRequestOptions, IRequestBaseFn, IEnv } from "./index";
|
|
2
|
+
declare class Interceptors implements IInterceptors {
|
|
3
|
+
private requestSuccess;
|
|
4
|
+
private responseSuccess;
|
|
5
|
+
private error;
|
|
6
|
+
use(type: "request" | "response" | "error", fn: Function): IInterceptors;
|
|
7
|
+
get reqFn(): Function;
|
|
8
|
+
get resFn(): Function;
|
|
9
|
+
get errFn(): Function;
|
|
10
|
+
}
|
|
11
|
+
declare abstract class RequestBase extends Interceptors implements IRequestBase {
|
|
12
|
+
readonly origin: IUrl;
|
|
13
|
+
constructor(origin: IUrl);
|
|
14
|
+
abstract fetch(url: string, opts: IRequestOptions): Promise<void>;
|
|
15
|
+
abstract http(url: string, opts: IRequestOptions): Promise<void>;
|
|
16
|
+
chackUrl: (url: IUrl) => boolean;
|
|
17
|
+
checkIsHttps: (url: IUrl) => boolean;
|
|
18
|
+
fixOrigin: (fixStr: string) => string;
|
|
19
|
+
envDesc: () => IEnv;
|
|
20
|
+
errorFn: (reject: any) => (err: any) => any;
|
|
21
|
+
clearTimer: (opts: any) => any;
|
|
22
|
+
initAbort: (params: IRequestOptions) => IRequestOptions;
|
|
23
|
+
requestType: () => IRequestBaseFn;
|
|
24
|
+
getDataByType: (type: any, response: any) => any;
|
|
25
|
+
formatBodyString: (bodyString: string) => IObject<Function>;
|
|
26
|
+
}
|
|
27
|
+
declare abstract class RequestInit extends RequestBase implements IRequestInit {
|
|
28
|
+
constructor(origin: any);
|
|
29
|
+
abstract fetch(url: any, opts: any): Promise<void>;
|
|
30
|
+
abstract http(url: any, opts: any): Promise<void>;
|
|
31
|
+
initDefaultParams: (url: IUrl, { method, query, headers, body, timeout, controller, type, ...others }: {
|
|
32
|
+
[x: string]: any;
|
|
33
|
+
method?: string;
|
|
34
|
+
query?: {};
|
|
35
|
+
headers?: {};
|
|
36
|
+
body?: any;
|
|
37
|
+
timeout?: number;
|
|
38
|
+
controller?: any;
|
|
39
|
+
type?: string;
|
|
40
|
+
}) => IRequestOptions;
|
|
41
|
+
initFetchParams: (url: IUrl, opts: IRequestOptions) => any;
|
|
42
|
+
initHttpParams: (url: IUrl, opts: IRequestOptions) => any;
|
|
43
|
+
}
|
|
44
|
+
export declare class Request extends RequestInit implements IRequest {
|
|
45
|
+
private request;
|
|
46
|
+
constructor(origin: any);
|
|
47
|
+
fetch: (_url: string, _opts: IRequestOptions) => Promise<any>;
|
|
48
|
+
http: (_url: string, _opts: IRequestOptions) => Promise<any>;
|
|
49
|
+
GET: (url?: IUrl, query?: IObject<any>, _?: IRequestBody | void, opts?: IRequestOptions) => any;
|
|
50
|
+
POST: (url?: IUrl, query?: IObject<any>, body?: IRequestBody, opts?: IRequestOptions) => any;
|
|
51
|
+
PUT: (url?: IUrl, query?: IObject<any>, body?: IRequestBody, opts?: IRequestOptions) => any;
|
|
52
|
+
DELETE: (url?: IUrl, query?: IObject<any>, body?: IRequestBody, opts?: IRequestOptions) => any;
|
|
53
|
+
OPTIONS: (url?: IUrl, query?: IObject<any>, body?: IRequestBody, opts?: IRequestOptions) => any;
|
|
54
|
+
HEAD: (url?: IUrl, query?: IObject<any>, body?: IRequestBody, opts?: IRequestOptions) => any;
|
|
55
|
+
PATCH: (url?: IUrl, query?: IObject<any>, body?: IRequestBody, opts?: IRequestOptions) => any;
|
|
56
|
+
}
|
|
57
|
+
declare const _default: {
|
|
58
|
+
Request: typeof Request;
|
|
59
|
+
};
|
|
60
|
+
export default _default;
|
package/dist/cjs/static.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export declare enum types {
|
|
2
|
-
"[object Array]" = "array",
|
|
3
|
-
"[object Object]" = "object",
|
|
4
|
-
"[object Function]" = "function",
|
|
5
|
-
"[object Set]" = "set",
|
|
6
|
-
"[object Map]" = "map",
|
|
7
|
-
"[object WeakMap]" = "weakMap",
|
|
8
|
-
"[object WeakSet]" = "weakSet",
|
|
9
|
-
"[object Date]" = "date",
|
|
10
|
-
"[object RegExp]" = "regExp",
|
|
11
|
-
"[object Math]" = "math"
|
|
12
|
-
}
|
|
13
|
-
declare const _default: {
|
|
14
|
-
types: typeof types;
|
|
15
|
-
};
|
|
16
|
-
export default _default;
|
|
1
|
+
export declare enum types {
|
|
2
|
+
"[object Array]" = "array",
|
|
3
|
+
"[object Object]" = "object",
|
|
4
|
+
"[object Function]" = "function",
|
|
5
|
+
"[object Set]" = "set",
|
|
6
|
+
"[object Map]" = "map",
|
|
7
|
+
"[object WeakMap]" = "weakMap",
|
|
8
|
+
"[object WeakSet]" = "weakSet",
|
|
9
|
+
"[object Date]" = "date",
|
|
10
|
+
"[object RegExp]" = "regExp",
|
|
11
|
+
"[object Math]" = "math"
|
|
12
|
+
}
|
|
13
|
+
declare const _default: {
|
|
14
|
+
types: typeof types;
|
|
15
|
+
};
|
|
16
|
+
export default _default;
|
package/dist/cjs/storage.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export declare const setStorage: (key: string, val: any) => void;
|
|
2
|
-
export declare const getStorage: (key: string) => any;
|
|
3
|
-
export declare const clearStorage: (key: string) => void;
|
|
4
|
-
declare const _default: {
|
|
5
|
-
setStorage: (key: string, val: any) => void;
|
|
6
|
-
getStorage: (key: string) => any;
|
|
7
|
-
clearStorage: (key: string) => void;
|
|
8
|
-
};
|
|
9
|
-
export default _default;
|
|
1
|
+
export declare const setStorage: (key: string, val: any) => void;
|
|
2
|
+
export declare const getStorage: (key: string) => any;
|
|
3
|
+
export declare const clearStorage: (key: string) => void;
|
|
4
|
+
declare const _default: {
|
|
5
|
+
setStorage: (key: string, val: any) => void;
|
|
6
|
+
getStorage: (key: string) => any;
|
|
7
|
+
clearStorage: (key: string) => void;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
export type IKey = string | symbol | number;
|
|
2
|
-
export interface IObject<T> {
|
|
3
|
-
[key: IKey]: T | IObject<any>;
|
|
4
|
-
}
|
|
5
|
-
export interface IPromise extends IObject<any> {
|
|
6
|
-
promise: Promise<void>;
|
|
7
|
-
resolve: (res: any) => unknown;
|
|
8
|
-
reject: (err: any) => unknown;
|
|
9
|
-
}
|
|
10
|
-
export type IInstance<T> = {
|
|
11
|
-
_instance: Function;
|
|
12
|
-
} & T;
|
|
13
|
-
export type IDemoteArray<T> = Array<IDemoteArray<T> | T>;
|
|
14
|
-
export type IRandomNum = (min: number, max: number, bool?: boolean) => number;
|
|
15
|
-
export type IUrlSplit = (url: string) => IObject<any>;
|
|
16
|
-
export type IUrlJoin = (url: string, query: object) => string;
|
|
17
|
-
export type IGetType<T> = (data: any) => typeof data | T[keyof T] | "null";
|
|
18
|
-
export type IGetTypeByList = (data: any, whiteList: string[]) => boolean;
|
|
19
|
-
export type IGetValue = <T, U = IObject<T> | IObject<T>[IKey]>(object: U, key: string, defaultValue?: any) => U;
|
|
20
|
-
export type ISetValue = <T>(object: IObject<T>, key: string, value?: any) => IObject<T>;
|
|
21
|
-
export type IMixIn = <U extends IObject<any>>(target?: U, source?: IObject<any>, overwrite?: boolean) => U;
|
|
22
|
-
export type IEnumInversion = (target: IObject<string>) => IObject<string>;
|
|
23
|
-
export type ICloneDeep = (target?: any) => any;
|
|
24
|
-
export type ICreateObjectVariable = (type: string, source?: any) => any;
|
|
25
|
-
export type ICreateObject = <T, U extends T>(source: T) => U;
|
|
26
|
-
export type IInherit = <T extends Function>(source: T, target?: Function) => Function;
|
|
27
|
-
export type IGetInstance = (classProto: IInstance<FunctionConstructor>, overwrite?: boolean, ...params: any[]) => Function;
|
|
28
|
-
export type IClassDecorator = (params: IObject<any>) => <TFunction extends Function>(target: TFunction) => void;
|
|
29
|
-
export type IStringToJson = (target: string) => IObject<any> | null;
|
|
30
|
-
export type IJsonToString = (target: IObject<any>) => string;
|
|
31
|
-
export type IThrottle = (fn: Function, time: number) => (...args: any[]) => void;
|
|
32
|
-
export type IDebounce = (fn: Function, time: number) => (...args: any[]) => void;
|
|
33
|
-
export type IDefer = () => IPromise;
|
|
34
|
-
export type ICatchAwait<T extends Promise<any>> = (defer: T) => T;
|
|
35
|
-
export type IArrayRandom<T extends any[]> = (arr: T) => T;
|
|
36
|
-
export type IArrayUniq<T extends any[]> = (arr: T) => T;
|
|
37
|
-
export type IArrayDemote<T extends IDemoteArray<any>> = (arr: T, result?: T) => T;
|
|
38
|
-
interface IElementParams<T> {
|
|
39
|
-
ele: T | string;
|
|
40
|
-
style: CSSStyleDeclaration;
|
|
41
|
-
attr: Attr;
|
|
42
|
-
parent: T;
|
|
43
|
-
}
|
|
44
|
-
export type ICreateElement<T = HTMLElement> = (params: IElementParams<T>) => T;
|
|
45
|
-
export type IAddHandler = <T extends Document>(ele: T, type: string, handler: (e: Event) => void) => void;
|
|
46
|
-
export type IStopBubble = (e: Event) => void;
|
|
47
|
-
export type IStopDefault = (e: Event) => void;
|
|
48
|
-
export type IRemoveHandler = <T extends Document>(ele: T, type: string, handler: (e: Event) => void) => void;
|
|
49
|
-
export type IDispatchEvent = <T extends Document>(ele: T, data: any) => void;
|
|
50
|
-
export type IRequestParams<T> = T | IObject<any> | null;
|
|
51
|
-
export type IUrl = string;
|
|
52
|
-
export type IEnv = 'Window' | 'Node';
|
|
53
|
-
export type IDataType = "text" | "json" | "blob" | "formData" | "arrayBuffer";
|
|
54
|
-
export type IRequestMethods = "GET" | "POST" | "DELETE" | "PUT" | "OPTION" | "HEAD" | "PATCH";
|
|
55
|
-
export type IRequestBody = IRequestParams<BodyInit>;
|
|
56
|
-
export type IRequestHeaders = IRequestParams<HeadersInit>;
|
|
57
|
-
export type IRequestBaseFn = (url: IUrl, opts: IRequestOptions) => Promise<any>;
|
|
58
|
-
export type IRequestFn = (url?: IUrl, query?: IObject<any>, body?: IRequestBody, opts?: IRequestOptions) => Promise<any>;
|
|
59
|
-
export type IRequestOptions = {
|
|
60
|
-
method?: IRequestMethods;
|
|
61
|
-
query?: IRequestParams<IObject<any>>;
|
|
62
|
-
body?: IRequestBody;
|
|
63
|
-
headers?: IRequestHeaders;
|
|
64
|
-
controller?: AbortController;
|
|
65
|
-
timeout?: number;
|
|
66
|
-
timer?: number | unknown | null;
|
|
67
|
-
[key: string]: any;
|
|
68
|
-
};
|
|
69
|
-
export type IInterceptors = {
|
|
70
|
-
use(type: "request" | "response" | "error", fn: Function): IInterceptors;
|
|
71
|
-
get reqFn(): Function;
|
|
72
|
-
get resFn(): Function;
|
|
73
|
-
get errFn(): Function;
|
|
74
|
-
};
|
|
75
|
-
export type IRequestBase = {
|
|
76
|
-
readonly origin: string;
|
|
77
|
-
chackUrl: (url: IUrl) => boolean;
|
|
78
|
-
envDesc: () => IEnv;
|
|
79
|
-
errorFn: <Err = any, R = Function>(reject: R) => (err: Err) => R;
|
|
80
|
-
clearTimer: (opts: IRequestOptions) => void;
|
|
81
|
-
initAbort: (opts: IRequestOptions) => IRequestOptions;
|
|
82
|
-
requestType: () => IRequestBaseFn;
|
|
83
|
-
fixOrigin: (fixStr: string) => string;
|
|
84
|
-
fetch: IRequestBaseFn;
|
|
85
|
-
http: IRequestBaseFn;
|
|
86
|
-
getDataByType: (type: IDataType, response: Response) => Promise<any>;
|
|
87
|
-
formatBodyString: (bodyString: string) => IObject<Function>;
|
|
88
|
-
};
|
|
89
|
-
export type IRequestInit = {
|
|
90
|
-
initDefaultParams: (url: IUrl, opts: IRequestOptions) => any;
|
|
91
|
-
initFetchParams: (url: IUrl, opts: IRequestOptions) => any;
|
|
92
|
-
initHttpParams: (url: IUrl, opts: IRequestOptions) => any;
|
|
93
|
-
};
|
|
94
|
-
export type IRequest = {
|
|
95
|
-
GET: IRequestFn;
|
|
96
|
-
POST: IRequestFn;
|
|
97
|
-
DELETE: IRequestFn;
|
|
98
|
-
PUT: IRequestFn;
|
|
99
|
-
OPTIONS: IRequestFn;
|
|
100
|
-
HEAD: IRequestFn;
|
|
101
|
-
PATCH: IRequestFn;
|
|
102
|
-
} & IRequestBase;
|
|
103
|
-
export {};
|
|
1
|
+
export type IKey = string | symbol | number;
|
|
2
|
+
export interface IObject<T> {
|
|
3
|
+
[key: IKey]: T | IObject<any>;
|
|
4
|
+
}
|
|
5
|
+
export interface IPromise extends IObject<any> {
|
|
6
|
+
promise: Promise<void>;
|
|
7
|
+
resolve: (res: any) => unknown;
|
|
8
|
+
reject: (err: any) => unknown;
|
|
9
|
+
}
|
|
10
|
+
export type IInstance<T> = {
|
|
11
|
+
_instance: Function;
|
|
12
|
+
} & T;
|
|
13
|
+
export type IDemoteArray<T> = Array<IDemoteArray<T> | T>;
|
|
14
|
+
export type IRandomNum = (min: number, max: number, bool?: boolean) => number;
|
|
15
|
+
export type IUrlSplit = (url: string) => IObject<any>;
|
|
16
|
+
export type IUrlJoin = (url: string, query: object) => string;
|
|
17
|
+
export type IGetType<T> = (data: any) => typeof data | T[keyof T] | "null";
|
|
18
|
+
export type IGetTypeByList = (data: any, whiteList: string[]) => boolean;
|
|
19
|
+
export type IGetValue = <T, U = IObject<T> | IObject<T>[IKey]>(object: U, key: string, defaultValue?: any) => U;
|
|
20
|
+
export type ISetValue = <T>(object: IObject<T>, key: string, value?: any) => IObject<T>;
|
|
21
|
+
export type IMixIn = <U extends IObject<any>>(target?: U, source?: IObject<any>, overwrite?: boolean) => U;
|
|
22
|
+
export type IEnumInversion = (target: IObject<string>) => IObject<string>;
|
|
23
|
+
export type ICloneDeep = (target?: any) => any;
|
|
24
|
+
export type ICreateObjectVariable = (type: string, source?: any) => any;
|
|
25
|
+
export type ICreateObject = <T, U extends T>(source: T) => U;
|
|
26
|
+
export type IInherit = <T extends Function>(source: T, target?: Function) => Function;
|
|
27
|
+
export type IGetInstance = (classProto: IInstance<FunctionConstructor>, overwrite?: boolean, ...params: any[]) => Function;
|
|
28
|
+
export type IClassDecorator = (params: IObject<any>) => <TFunction extends Function>(target: TFunction) => void;
|
|
29
|
+
export type IStringToJson = (target: string) => IObject<any> | null;
|
|
30
|
+
export type IJsonToString = (target: IObject<any>) => string;
|
|
31
|
+
export type IThrottle = (fn: Function, time: number) => (...args: any[]) => void;
|
|
32
|
+
export type IDebounce = (fn: Function, time: number) => (...args: any[]) => void;
|
|
33
|
+
export type IDefer = () => IPromise;
|
|
34
|
+
export type ICatchAwait<T extends Promise<any>> = (defer: T) => T;
|
|
35
|
+
export type IArrayRandom<T extends any[]> = (arr: T) => T;
|
|
36
|
+
export type IArrayUniq<T extends any[]> = (arr: T) => T;
|
|
37
|
+
export type IArrayDemote<T extends IDemoteArray<any>> = (arr: T, result?: T) => T;
|
|
38
|
+
interface IElementParams<T> {
|
|
39
|
+
ele: T | string;
|
|
40
|
+
style: CSSStyleDeclaration;
|
|
41
|
+
attr: Attr;
|
|
42
|
+
parent: T;
|
|
43
|
+
}
|
|
44
|
+
export type ICreateElement<T = HTMLElement> = (params: IElementParams<T>) => T;
|
|
45
|
+
export type IAddHandler = <T extends Document>(ele: T, type: string, handler: (e: Event) => void) => void;
|
|
46
|
+
export type IStopBubble = (e: Event) => void;
|
|
47
|
+
export type IStopDefault = (e: Event) => void;
|
|
48
|
+
export type IRemoveHandler = <T extends Document>(ele: T, type: string, handler: (e: Event) => void) => void;
|
|
49
|
+
export type IDispatchEvent = <T extends Document>(ele: T, data: any) => void;
|
|
50
|
+
export type IRequestParams<T> = T | IObject<any> | null;
|
|
51
|
+
export type IUrl = string;
|
|
52
|
+
export type IEnv = 'Window' | 'Node';
|
|
53
|
+
export type IDataType = "text" | "json" | "blob" | "formData" | "arrayBuffer";
|
|
54
|
+
export type IRequestMethods = "GET" | "POST" | "DELETE" | "PUT" | "OPTION" | "HEAD" | "PATCH";
|
|
55
|
+
export type IRequestBody = IRequestParams<BodyInit>;
|
|
56
|
+
export type IRequestHeaders = IRequestParams<HeadersInit>;
|
|
57
|
+
export type IRequestBaseFn = (url: IUrl, opts: IRequestOptions) => Promise<any>;
|
|
58
|
+
export type IRequestFn = (url?: IUrl, query?: IObject<any>, body?: IRequestBody, opts?: IRequestOptions) => Promise<any>;
|
|
59
|
+
export type IRequestOptions = {
|
|
60
|
+
method?: IRequestMethods;
|
|
61
|
+
query?: IRequestParams<IObject<any>>;
|
|
62
|
+
body?: IRequestBody;
|
|
63
|
+
headers?: IRequestHeaders;
|
|
64
|
+
controller?: AbortController;
|
|
65
|
+
timeout?: number;
|
|
66
|
+
timer?: number | unknown | null;
|
|
67
|
+
[key: string]: any;
|
|
68
|
+
};
|
|
69
|
+
export type IInterceptors = {
|
|
70
|
+
use(type: "request" | "response" | "error", fn: Function): IInterceptors;
|
|
71
|
+
get reqFn(): Function;
|
|
72
|
+
get resFn(): Function;
|
|
73
|
+
get errFn(): Function;
|
|
74
|
+
};
|
|
75
|
+
export type IRequestBase = {
|
|
76
|
+
readonly origin: string;
|
|
77
|
+
chackUrl: (url: IUrl) => boolean;
|
|
78
|
+
envDesc: () => IEnv;
|
|
79
|
+
errorFn: <Err = any, R = Function>(reject: R) => (err: Err) => R;
|
|
80
|
+
clearTimer: (opts: IRequestOptions) => void;
|
|
81
|
+
initAbort: (opts: IRequestOptions) => IRequestOptions;
|
|
82
|
+
requestType: () => IRequestBaseFn;
|
|
83
|
+
fixOrigin: (fixStr: string) => string;
|
|
84
|
+
fetch: IRequestBaseFn;
|
|
85
|
+
http: IRequestBaseFn;
|
|
86
|
+
getDataByType: (type: IDataType, response: Response) => Promise<any>;
|
|
87
|
+
formatBodyString: (bodyString: string) => IObject<Function>;
|
|
88
|
+
};
|
|
89
|
+
export type IRequestInit = {
|
|
90
|
+
initDefaultParams: (url: IUrl, opts: IRequestOptions) => any;
|
|
91
|
+
initFetchParams: (url: IUrl, opts: IRequestOptions) => any;
|
|
92
|
+
initHttpParams: (url: IUrl, opts: IRequestOptions) => any;
|
|
93
|
+
};
|
|
94
|
+
export type IRequest = {
|
|
95
|
+
GET: IRequestFn;
|
|
96
|
+
POST: IRequestFn;
|
|
97
|
+
DELETE: IRequestFn;
|
|
98
|
+
PUT: IRequestFn;
|
|
99
|
+
OPTIONS: IRequestFn;
|
|
100
|
+
HEAD: IRequestFn;
|
|
101
|
+
PATCH: IRequestFn;
|
|
102
|
+
} & IRequestBase;
|
|
103
|
+
export {};
|
package/dist/esm/array.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IArrayRandom, IArrayUniq, IArrayDemote, IDemoteArray } from "./index";
|
|
2
|
-
export declare const arrayRandom: IArrayRandom<any[]>;
|
|
3
|
-
export declare const arrayUniq: IArrayUniq<any[]>;
|
|
4
|
-
export declare const arrayDemote: IArrayDemote<IDemoteArray<any>>;
|
|
5
|
-
declare const _default: {
|
|
6
|
-
arrayRandom: IArrayRandom<any[]>;
|
|
7
|
-
arrayUniq: IArrayUniq<any[]>;
|
|
8
|
-
arrayDemote: IArrayDemote<IDemoteArray<any>>;
|
|
9
|
-
};
|
|
10
|
-
export default _default;
|
|
1
|
+
import { IArrayRandom, IArrayUniq, IArrayDemote, IDemoteArray } from "./index";
|
|
2
|
+
export declare const arrayRandom: IArrayRandom<any[]>;
|
|
3
|
+
export declare const arrayUniq: IArrayUniq<any[]>;
|
|
4
|
+
export declare const arrayDemote: IArrayDemote<IDemoteArray<any>>;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
arrayRandom: IArrayRandom<any[]>;
|
|
7
|
+
arrayUniq: IArrayUniq<any[]>;
|
|
8
|
+
arrayDemote: IArrayDemote<IDemoteArray<any>>;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
package/dist/esm/base.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { IRandomNum, IUrlSplit, IUrlJoin, IGetType, IGetTypeByList, types } from "./index";
|
|
2
|
-
export declare const randomNum: IRandomNum;
|
|
3
|
-
export declare const urlSplit: IUrlSplit;
|
|
4
|
-
export declare const urlJoin: IUrlJoin;
|
|
5
|
-
export declare const getType: IGetType<types>;
|
|
6
|
-
export declare const getTypeByList: IGetTypeByList;
|
|
7
|
-
declare const _default: {
|
|
8
|
-
randomNum: IRandomNum;
|
|
9
|
-
urlSplit: IUrlSplit;
|
|
10
|
-
urlJoin: IUrlJoin;
|
|
11
|
-
getType: IGetType<types>;
|
|
12
|
-
getTypeByList: IGetTypeByList;
|
|
13
|
-
};
|
|
14
|
-
export default _default;
|
|
1
|
+
import { IRandomNum, IUrlSplit, IUrlJoin, IGetType, IGetTypeByList, types } from "./index";
|
|
2
|
+
export declare const randomNum: IRandomNum;
|
|
3
|
+
export declare const urlSplit: IUrlSplit;
|
|
4
|
+
export declare const urlJoin: IUrlJoin;
|
|
5
|
+
export declare const getType: IGetType<types>;
|
|
6
|
+
export declare const getTypeByList: IGetTypeByList;
|
|
7
|
+
declare const _default: {
|
|
8
|
+
randomNum: IRandomNum;
|
|
9
|
+
urlSplit: IUrlSplit;
|
|
10
|
+
urlJoin: IUrlJoin;
|
|
11
|
+
getType: IGetType<types>;
|
|
12
|
+
getTypeByList: IGetTypeByList;
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
package/dist/esm/element.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ICreateElement } from "./index";
|
|
2
|
-
export declare const createElement: ICreateElement;
|
|
3
|
-
declare const _default: {
|
|
4
|
-
createElement: ICreateElement
|
|
5
|
-
};
|
|
6
|
-
export default _default;
|
|
1
|
+
import { ICreateElement } from "./index";
|
|
2
|
+
export declare const createElement: ICreateElement;
|
|
3
|
+
declare const _default: {
|
|
4
|
+
createElement: ICreateElement<HTMLElement>;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
package/dist/esm/event.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { IAddHandler, IStopBubble, IStopDefault, IRemoveHandler, IDispatchEvent } from "./index";
|
|
2
|
-
export declare const addHandler: IAddHandler;
|
|
3
|
-
export declare const stopBubble: IStopBubble;
|
|
4
|
-
export declare const stopDefault: IStopDefault;
|
|
5
|
-
export declare const removeHandler: IRemoveHandler;
|
|
6
|
-
export declare const dispatchEvent: IDispatchEvent;
|
|
7
|
-
declare const _default: {
|
|
8
|
-
addHandler: IAddHandler;
|
|
9
|
-
stopBubble: IStopBubble;
|
|
10
|
-
stopDefault: IStopDefault;
|
|
11
|
-
removeHandler: IRemoveHandler;
|
|
12
|
-
dispatchEvent: IDispatchEvent;
|
|
13
|
-
};
|
|
14
|
-
export default _default;
|
|
1
|
+
import { IAddHandler, IStopBubble, IStopDefault, IRemoveHandler, IDispatchEvent } from "./index";
|
|
2
|
+
export declare const addHandler: IAddHandler;
|
|
3
|
+
export declare const stopBubble: IStopBubble;
|
|
4
|
+
export declare const stopDefault: IStopDefault;
|
|
5
|
+
export declare const removeHandler: IRemoveHandler;
|
|
6
|
+
export declare const dispatchEvent: IDispatchEvent;
|
|
7
|
+
declare const _default: {
|
|
8
|
+
addHandler: IAddHandler;
|
|
9
|
+
stopBubble: IStopBubble;
|
|
10
|
+
stopDefault: IStopDefault;
|
|
11
|
+
removeHandler: IRemoveHandler;
|
|
12
|
+
dispatchEvent: IDispatchEvent;
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
package/dist/esm/function.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ICatchAwait, IThrottle, IDebounce, IDefer } from "./index";
|
|
2
|
-
export declare const throttle: IThrottle;
|
|
3
|
-
export declare const debounce: IDebounce;
|
|
4
|
-
export declare const defer: IDefer;
|
|
5
|
-
export declare const catchAwait: ICatchAwait<Promise<any>>;
|
|
6
|
-
declare const _default: {
|
|
7
|
-
throttle: IThrottle;
|
|
8
|
-
debounce: IDebounce;
|
|
9
|
-
defer: IDefer;
|
|
10
|
-
catchAwait: ICatchAwait<Promise<any>>;
|
|
11
|
-
};
|
|
12
|
-
export default _default;
|
|
1
|
+
import { ICatchAwait, IThrottle, IDebounce, IDefer } from "./index";
|
|
2
|
+
export declare const throttle: IThrottle;
|
|
3
|
+
export declare const debounce: IDebounce;
|
|
4
|
+
export declare const defer: IDefer;
|
|
5
|
+
export declare const catchAwait: ICatchAwait<Promise<any>>;
|
|
6
|
+
declare const _default: {
|
|
7
|
+
throttle: IThrottle;
|
|
8
|
+
debounce: IDebounce;
|
|
9
|
+
defer: IDefer;
|
|
10
|
+
catchAwait: ICatchAwait<Promise<any>>;
|
|
11
|
+
};
|
|
12
|
+
export default _default;
|