utils-lib-js 1.7.23 → 2.0.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.
Files changed (61) hide show
  1. package/README.en.md +12 -6
  2. package/README.md +8 -6
  3. package/package.json +13 -13
  4. package/rollup.config.js +1 -0
  5. package/dist/bundle/animate.d.ts +0 -25
  6. package/dist/bundle/array.d.ts +0 -10
  7. package/dist/bundle/base.d.ts +0 -15
  8. package/dist/bundle/element.d.ts +0 -6
  9. package/dist/bundle/event.d.ts +0 -14
  10. package/dist/bundle/function.d.ts +0 -12
  11. package/dist/bundle/index.d.ts +0 -66
  12. package/dist/bundle/index.js +0 -1
  13. package/dist/bundle/log.d.ts +0 -8
  14. package/dist/bundle/object.d.ts +0 -32
  15. package/dist/bundle/request.d.ts +0 -60
  16. package/dist/bundle/static.d.ts +0 -16
  17. package/dist/bundle/storage.d.ts +0 -9
  18. package/dist/bundle/types.d.ts +0 -122
  19. package/dist/cjs/animate.d.ts +0 -25
  20. package/dist/cjs/array.d.ts +0 -10
  21. package/dist/cjs/base.d.ts +0 -15
  22. package/dist/cjs/element.d.ts +0 -6
  23. package/dist/cjs/event.d.ts +0 -14
  24. package/dist/cjs/function.d.ts +0 -12
  25. package/dist/cjs/index.d.ts +0 -66
  26. package/dist/cjs/index.js +0 -1146
  27. package/dist/cjs/log.d.ts +0 -8
  28. package/dist/cjs/object.d.ts +0 -32
  29. package/dist/cjs/package.json +0 -3
  30. package/dist/cjs/request.d.ts +0 -60
  31. package/dist/cjs/static.d.ts +0 -16
  32. package/dist/cjs/storage.d.ts +0 -9
  33. package/dist/cjs/types.d.ts +0 -122
  34. package/dist/esm/animate.d.ts +0 -25
  35. package/dist/esm/array.d.ts +0 -10
  36. package/dist/esm/base.d.ts +0 -15
  37. package/dist/esm/element.d.ts +0 -6
  38. package/dist/esm/event.d.ts +0 -14
  39. package/dist/esm/function.d.ts +0 -12
  40. package/dist/esm/index.d.ts +0 -66
  41. package/dist/esm/index.js +0 -1093
  42. package/dist/esm/log.d.ts +0 -8
  43. package/dist/esm/object.d.ts +0 -32
  44. package/dist/esm/request.d.ts +0 -60
  45. package/dist/esm/static.d.ts +0 -16
  46. package/dist/esm/storage.d.ts +0 -9
  47. package/dist/esm/types.d.ts +0 -122
  48. package/dist/umd/animate.d.ts +0 -25
  49. package/dist/umd/array.d.ts +0 -10
  50. package/dist/umd/base.d.ts +0 -15
  51. package/dist/umd/element.d.ts +0 -6
  52. package/dist/umd/event.d.ts +0 -14
  53. package/dist/umd/function.d.ts +0 -12
  54. package/dist/umd/index.d.ts +0 -66
  55. package/dist/umd/index.js +0 -1152
  56. package/dist/umd/log.d.ts +0 -8
  57. package/dist/umd/object.d.ts +0 -32
  58. package/dist/umd/request.d.ts +0 -60
  59. package/dist/umd/static.d.ts +0 -16
  60. package/dist/umd/storage.d.ts +0 -9
  61. package/dist/umd/types.d.ts +0 -122
package/dist/cjs/log.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { ILogOneLine, ILogLoop } from "./types";
2
- export declare const logOneLine: ILogOneLine;
3
- export declare const logLoop: ILogLoop;
4
- declare const _default: {
5
- logOneLine: ILogOneLine;
6
- logLoop: ILogLoop;
7
- };
8
- export default _default;
@@ -1,32 +0,0 @@
1
- import { IGetValue, ISetValue, IMixIn, ICloneDeep, ICreateObjectVariable, IEnumInversion, IInherit, ICreateObject, IGetInstance, IClassDecorator, IStringToJson, IJsonToString } from "./types";
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
- export declare const isWindow: (win: any) => boolean;
16
- declare const _default: {
17
- getValue: IGetValue;
18
- setValue: ISetValue;
19
- mixIn: IMixIn;
20
- enumInversion: IEnumInversion;
21
- isNotObject: (source: any, type: any) => boolean;
22
- cloneDeep: ICloneDeep;
23
- createObjectVariable: ICreateObjectVariable;
24
- createObject: ICreateObject;
25
- inherit: IInherit;
26
- getInstance: IGetInstance;
27
- classDecorator: IClassDecorator;
28
- stringToJson: IStringToJson;
29
- jsonToString: IJsonToString;
30
- isWindow: (win: any) => boolean;
31
- };
32
- export default _default;
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -1,60 +0,0 @@
1
- import { IRequest, IRequestBase, IRequestInit, IInterceptors, IUrl, IObject, IRequestBody, IRequestOptions, IRequestBaseFn, IEnv } from "./types";
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,16 +0,0 @@
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,9 +0,0 @@
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,122 +0,0 @@
1
- import type { AbortController } from "abort-controller";
2
- export type IKey = string | symbol | number;
3
- export interface IObject<T> {
4
- [key: IKey]: T | IObject<any>;
5
- }
6
- export interface IPromise extends IObject<any> {
7
- promise: Promise<void>;
8
- resolve: (res: any) => unknown;
9
- reject: (err: any) => unknown;
10
- }
11
- export type IInstance<T> = {
12
- _instance: Function;
13
- } & T;
14
- export type IDemoteArray<T> = Array<IDemoteArray<T> | T>;
15
- export type IRandomNum = (min: number, max: number, bool?: boolean) => number;
16
- export type IUrlSplit = (url: string) => IObject<any>;
17
- export type IUrlJoin = (url: string, query: object) => string;
18
- export type IGetType<T> = (data: any) => typeof data | T[keyof T] | "null";
19
- export type IGetTypeByList = (data: any, whiteList: string[]) => boolean;
20
- export type IGetValue = <T, U = IObject<T> | IObject<T>[IKey]>(object: U, key: string, defaultValue?: any) => U;
21
- export type ISetValue = <T>(object: IObject<T>, key: string, value?: any) => IObject<T>;
22
- export type IMixIn = <U extends IObject<any>>(target?: U, source?: IObject<any>, overwrite?: boolean) => U;
23
- export type IEnumInversion = (target: IObject<string>) => IObject<string>;
24
- export type ICloneDeep = (target?: any) => any;
25
- export type ICreateObjectVariable = (type: string, source?: any) => any;
26
- export type ICreateObject = <T, U extends T>(source: T) => U;
27
- export type IInherit = <T extends Function>(source: T, target?: Function) => Function;
28
- export type IGetInstance = (classProto: IInstance<FunctionConstructor>, overwrite?: boolean, ...params: any[]) => Function;
29
- export type IClassDecorator = (params: IObject<any>) => <TFunction extends Function>(target: TFunction) => void;
30
- export type IStringToJson = (target: string) => IObject<any> | null;
31
- export type IJsonToString = (target: IObject<any>) => string;
32
- export type IThrottle = (fn: Function, time: number) => (...args: any[]) => void;
33
- export type IDebounce = (fn: Function, time: number) => (...args: any[]) => void;
34
- export type IDefer = (timer?: number) => IPromise;
35
- export type ICatchAwait<T extends Promise<any>> = (defer: T) => T;
36
- export type IArrayRandom<T extends any[]> = (arr: T) => T;
37
- export type IArrayUniq<T extends any[]> = (arr: T) => T;
38
- export type IArrayDemote<T extends IDemoteArray<any>> = (arr: T, result?: T) => T;
39
- type TagAttributes = Partial<Record<string, string | boolean>>;
40
- interface IElementParams<T> {
41
- ele: T | string;
42
- style?: Partial<CSSStyleDeclaration>;
43
- attr?: TagAttributes;
44
- parent?: T;
45
- }
46
- export type ICreateElement<T = HTMLElement> = (params: IElementParams<T>) => T;
47
- export type IAddHandler = <T extends Document>(ele: T, type: string, handler: (e: Event) => void) => void;
48
- export type IStopBubble = (e: Event) => void;
49
- export type IStopDefault = (e: Event) => void;
50
- export type IRemoveHandler = <T extends Document>(ele: T, type: string, handler: (e: Event) => void) => void;
51
- export type IDispatchEvent = <T extends Document>(ele: T, data: any) => void;
52
- export type ILogOneLine = (str: string, overwrite?: boolean, warp?: boolean) => void;
53
- export type ILogLoopParams = {
54
- loopList?: string[];
55
- index?: number;
56
- isStop?: boolean;
57
- timer?: number;
58
- };
59
- export type ILogLoop = (opts?: ILogLoopParams) => ILogLoopParams | void;
60
- export type IRequestParams<T> = T | IObject<any> | null;
61
- export type IUrl = string;
62
- export type IEnv = 'Window' | 'Node';
63
- export type IDataType = "text" | "json" | "blob" | "formData" | "arrayBuffer";
64
- export type IRequestMethods = "GET" | "POST" | "DELETE" | "PUT" | "OPTION" | "HEAD" | "PATCH";
65
- export type IRequestBody = IRequestParams<BodyInit>;
66
- export type IRequestHeaders = IRequestParams<HeadersInit>;
67
- export type IRequestBaseFn = (url: IUrl, opts: IRequestOptions) => Promise<any>;
68
- export type IRequestFn = (url?: IUrl, query?: IObject<any>, body?: IRequestBody, opts?: IRequestOptions) => Promise<any>;
69
- export type IRequestOptions = {
70
- method?: IRequestMethods;
71
- query?: IRequestParams<IObject<any>>;
72
- body?: IRequestBody;
73
- headers?: IRequestHeaders;
74
- controller?: AbortController;
75
- timeout?: number;
76
- timer?: number | unknown | null;
77
- [key: string]: any;
78
- };
79
- export type IInterceptors = {
80
- use(type: "request" | "response" | "error", fn: Function): IInterceptors;
81
- get reqFn(): Function;
82
- get resFn(): Function;
83
- get errFn(): Function;
84
- };
85
- export type IRequestBase = {
86
- readonly origin: string;
87
- chackUrl: (url: IUrl) => boolean;
88
- envDesc: () => IEnv;
89
- errorFn: <Err = any, R = Function>(reject: R) => (err: Err) => R;
90
- clearTimer: (opts: IRequestOptions) => void;
91
- initAbort: (opts: IRequestOptions) => IRequestOptions;
92
- requestType: () => IRequestBaseFn;
93
- fixOrigin: (fixStr: string) => string;
94
- fetch: IRequestBaseFn;
95
- http: IRequestBaseFn;
96
- getDataByType: (type: IDataType, response: Response) => Promise<any>;
97
- formatBodyString: (bodyString: string) => IObject<Function>;
98
- };
99
- export type IRequestInit = {
100
- initDefaultParams: (url: IUrl, opts: IRequestOptions) => any;
101
- initFetchParams: (url: IUrl, opts: IRequestOptions) => any;
102
- initHttpParams: (url: IUrl, opts: IRequestOptions) => any;
103
- };
104
- export type IRequest = {
105
- GET: IRequestFn;
106
- POST: IRequestFn;
107
- DELETE: IRequestFn;
108
- PUT: IRequestFn;
109
- OPTIONS: IRequestFn;
110
- HEAD: IRequestFn;
111
- PATCH: IRequestFn;
112
- } & IRequestBase;
113
- export type IAnimateFrame = {
114
- id: number | null;
115
- duration: number;
116
- isActive: boolean;
117
- fn(timer: number): void;
118
- start(duration: number): void;
119
- stop(): void;
120
- animate(timer: number): void;
121
- };
122
- export {};
@@ -1,25 +0,0 @@
1
- import { IAnimateFrame } from "./types";
2
- export declare class AnimateFrame implements IAnimateFrame {
3
- fn: any;
4
- id: any;
5
- duration: number;
6
- isActive: boolean;
7
- constructor(fn: any);
8
- start(duration: any): void;
9
- stop(): void;
10
- animate(timer?: number): void;
11
- }
12
- export declare function quadraticBezier(_x: number, _y: number, t: number): number[];
13
- export declare function cubicBezier(_x1: number, _y1: number, _x2: number, _y2: number, t: number): number[];
14
- export declare function factorial(n: number): any;
15
- export declare function combination(n: number, k: number): number;
16
- export declare function NBezier(points: number[][], t: number): number[];
17
- declare const _default: {
18
- AnimateFrame: typeof AnimateFrame;
19
- quadraticBezier: typeof quadraticBezier;
20
- cubicBezier: typeof cubicBezier;
21
- factorial: typeof factorial;
22
- combination: typeof combination;
23
- NBezier: typeof NBezier;
24
- };
25
- export default _default;
@@ -1,10 +0,0 @@
1
- import { IArrayRandom, IArrayUniq, IArrayDemote, IDemoteArray } from "./types";
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,15 +0,0 @@
1
- import { IRandomNum, IUrlSplit, IUrlJoin, IGetType, IGetTypeByList } from "./types";
2
- import { types } from "./static";
3
- export declare const randomNum: IRandomNum;
4
- export declare const urlSplit: IUrlSplit;
5
- export declare const urlJoin: IUrlJoin;
6
- export declare const getType: IGetType<types>;
7
- export declare const getTypeByList: IGetTypeByList;
8
- declare const _default: {
9
- randomNum: IRandomNum;
10
- urlSplit: IUrlSplit;
11
- urlJoin: IUrlJoin;
12
- getType: IGetType<types>;
13
- getTypeByList: IGetTypeByList;
14
- };
15
- export default _default;
@@ -1,6 +0,0 @@
1
- import { ICreateElement } from "./types";
2
- export declare const createElement: ICreateElement;
3
- declare const _default: {
4
- createElement: ICreateElement<HTMLElement>;
5
- };
6
- export default _default;
@@ -1,14 +0,0 @@
1
- import { IAddHandler, IStopBubble, IStopDefault, IRemoveHandler, IDispatchEvent } from "./types";
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,12 +0,0 @@
1
- import { ICatchAwait, IThrottle, IDebounce, IDefer } from "./types";
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,66 +0,0 @@
1
- export * from "./object";
2
- export * from "./base";
3
- export * from "./array";
4
- export * from "./function";
5
- export * from "./element";
6
- export * from "./static";
7
- export * from "./types";
8
- export * from "./request";
9
- export * from "./event";
10
- export * from "./storage";
11
- export * from "./log";
12
- export * from "./animate";
13
- export * from "event-message-center";
14
- export * from "task-queue-lib";
15
- import eventMessageCenter from "event-message-center";
16
- import taskQueueLib from "task-queue-lib";
17
- declare const _default: {
18
- eventMessageCenter: typeof eventMessageCenter;
19
- taskQueueLib: typeof taskQueueLib;
20
- AnimateFrame: typeof import("./animate").AnimateFrame;
21
- quadraticBezier: typeof import("./animate").quadraticBezier;
22
- cubicBezier: typeof import("./animate").cubicBezier;
23
- factorial: typeof import("./animate").factorial;
24
- combination: typeof import("./animate").combination;
25
- NBezier: typeof import("./animate").NBezier;
26
- logOneLine: import("./types").ILogOneLine;
27
- logLoop: import("./types").ILogLoop;
28
- setStorage: (key: string, val: any) => void;
29
- getStorage: (key: string) => any;
30
- clearStorage: (key: string) => void;
31
- addHandler: import("./types").IAddHandler;
32
- stopBubble: import("./types").IStopBubble;
33
- stopDefault: import("./types").IStopDefault;
34
- removeHandler: import("./types").IRemoveHandler;
35
- dispatchEvent: import("./types").IDispatchEvent;
36
- Request: typeof import("./request").Request;
37
- types: typeof import("./static").types;
38
- createElement: import("./types").ICreateElement<HTMLElement>;
39
- throttle: import("./types").IThrottle;
40
- debounce: import("./types").IDebounce;
41
- defer: import("./types").IDefer;
42
- catchAwait: import("./types").ICatchAwait<Promise<any>>;
43
- arrayRandom: import("./types").IArrayRandom<any[]>;
44
- arrayUniq: import("./types").IArrayUniq<any[]>;
45
- arrayDemote: import("./types").IArrayDemote<import("./types").IDemoteArray<any>>;
46
- randomNum: import("./types").IRandomNum;
47
- urlSplit: import("./types").IUrlSplit;
48
- urlJoin: import("./types").IUrlJoin;
49
- getType: import("./types").IGetType<import("./static").types>;
50
- getTypeByList: import("./types").IGetTypeByList;
51
- getValue: import("./types").IGetValue;
52
- setValue: import("./types").ISetValue;
53
- mixIn: import("./types").IMixIn;
54
- enumInversion: import("./types").IEnumInversion;
55
- isNotObject: (source: any, type: any) => boolean;
56
- cloneDeep: import("./types").ICloneDeep;
57
- createObjectVariable: import("./types").ICreateObjectVariable;
58
- createObject: import("./types").ICreateObject;
59
- inherit: import("./types").IInherit;
60
- getInstance: import("./types").IGetInstance;
61
- classDecorator: import("./types").IClassDecorator;
62
- stringToJson: import("./types").IStringToJson;
63
- jsonToString: import("./types").IJsonToString;
64
- isWindow: (win: any) => boolean;
65
- };
66
- export default _default;