utils-lib-js 2.0.23 → 2.0.24
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/animate.d.ts +25 -0
- package/dist/bundle/array.d.ts +12 -0
- package/dist/bundle/base.d.ts +17 -0
- package/dist/bundle/element.d.ts +6 -0
- package/dist/bundle/event.d.ts +14 -0
- package/dist/bundle/function.d.ts +13 -0
- package/dist/bundle/index.d.ts +77 -0
- package/dist/bundle/index.js +97 -0
- package/dist/bundle/log.d.ts +8 -0
- package/dist/bundle/object.d.ts +36 -0
- package/dist/bundle/static.d.ts +16 -0
- package/dist/bundle/storage.d.ts +9 -0
- package/dist/bundle/types.d.ts +73 -0
- package/dist/cjs/animate.d.ts +25 -0
- package/dist/cjs/array.d.ts +12 -0
- package/dist/cjs/base.d.ts +17 -0
- package/dist/cjs/element.d.ts +6 -0
- package/dist/cjs/event.d.ts +14 -0
- package/dist/cjs/function.d.ts +13 -0
- package/dist/cjs/index.d.ts +77 -0
- package/dist/cjs/index.js +97 -0
- package/dist/cjs/log.d.ts +8 -0
- package/dist/cjs/object.d.ts +36 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/static.d.ts +16 -0
- package/dist/cjs/storage.d.ts +9 -0
- package/dist/cjs/types.d.ts +73 -0
- package/dist/esm/animate.d.ts +25 -0
- package/dist/esm/array.d.ts +12 -0
- package/dist/esm/base.d.ts +17 -0
- package/dist/esm/element.d.ts +6 -0
- package/dist/esm/event.d.ts +14 -0
- package/dist/esm/function.d.ts +13 -0
- package/dist/esm/index.d.ts +77 -0
- package/dist/esm/index.js +97 -0
- package/dist/esm/log.d.ts +8 -0
- package/dist/esm/object.d.ts +36 -0
- package/dist/esm/static.d.ts +16 -0
- package/dist/esm/storage.d.ts +9 -0
- package/dist/esm/types.d.ts +73 -0
- package/dist/umd/animate.d.ts +25 -0
- package/dist/umd/array.d.ts +12 -0
- package/dist/umd/base.d.ts +17 -0
- package/dist/umd/element.d.ts +6 -0
- package/dist/umd/event.d.ts +14 -0
- package/dist/umd/function.d.ts +13 -0
- package/dist/umd/index.d.ts +77 -0
- package/dist/umd/index.js +97 -0
- package/dist/umd/log.d.ts +8 -0
- package/dist/umd/object.d.ts +36 -0
- package/dist/umd/static.d.ts +16 -0
- package/dist/umd/storage.d.ts +9 -0
- package/dist/umd/types.d.ts +73 -0
- package/package.json +2 -2
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IGetValue, ISetValue, IMixIn, ICloneDeep, ICreateObjectVariable, IEnumInversion, IInherit, ICreateObject, IGetInstance, IClassDecorator, IStringToJson, IJsonToString, IObject } 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
|
+
export declare const emptyObject: (init?: IObject<unknown>) => any;
|
|
17
|
+
export declare const isEmptyObject: (object?: IObject<unknown>) => boolean;
|
|
18
|
+
declare const _default: {
|
|
19
|
+
getValue: IGetValue;
|
|
20
|
+
setValue: ISetValue;
|
|
21
|
+
mixIn: IMixIn;
|
|
22
|
+
enumInversion: IEnumInversion;
|
|
23
|
+
isNotObject: (source: any, type: any) => boolean;
|
|
24
|
+
cloneDeep: ICloneDeep;
|
|
25
|
+
createObjectVariable: ICreateObjectVariable;
|
|
26
|
+
createObject: ICreateObject;
|
|
27
|
+
inherit: IInherit;
|
|
28
|
+
getInstance: IGetInstance;
|
|
29
|
+
classDecorator: IClassDecorator;
|
|
30
|
+
stringToJson: IStringToJson;
|
|
31
|
+
jsonToString: IJsonToString;
|
|
32
|
+
isWindow: (win: any) => boolean;
|
|
33
|
+
emptyObject: (init?: IObject<unknown>) => any;
|
|
34
|
+
isEmptyObject: (object?: IObject<unknown>) => boolean;
|
|
35
|
+
};
|
|
36
|
+
export default _default;
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1,73 @@
|
|
|
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 = (timer?: number) => IPromise;
|
|
34
|
+
export type ICatchAwait<T extends Promise<any>> = (defer: T) => T;
|
|
35
|
+
export type IRequestFrame = (callback: (start: number) => void, delay: number) => () => void;
|
|
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
|
+
export type IArrayLoop = (list: unknown[], current?: number) => {
|
|
40
|
+
item: unknown;
|
|
41
|
+
current: number;
|
|
42
|
+
};
|
|
43
|
+
type TagAttributes = Partial<Record<string, string | boolean>>;
|
|
44
|
+
interface IElementParams<T> {
|
|
45
|
+
ele: T | string;
|
|
46
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
47
|
+
attr?: TagAttributes;
|
|
48
|
+
parent?: T;
|
|
49
|
+
}
|
|
50
|
+
export type ICreateElement<T = HTMLElement> = (params: IElementParams<T>) => T;
|
|
51
|
+
export type IAddHandler = <T extends Document>(ele: T, type: string, handler: (e: Event) => void) => void;
|
|
52
|
+
export type IStopBubble = (e: Event) => void;
|
|
53
|
+
export type IStopDefault = (e: Event) => void;
|
|
54
|
+
export type IRemoveHandler = <T extends Document>(ele: T, type: string, handler: (e: Event) => void) => void;
|
|
55
|
+
export type IDispatchEvent = <T extends Document>(ele: T, data: any) => void;
|
|
56
|
+
export type ILogOneLine = (str: string, overwrite?: boolean, warp?: boolean) => void;
|
|
57
|
+
export type ILogLoopParams = {
|
|
58
|
+
loopList?: string[];
|
|
59
|
+
index?: number;
|
|
60
|
+
isStop?: boolean;
|
|
61
|
+
timer?: number;
|
|
62
|
+
};
|
|
63
|
+
export type ILogLoop = (opts?: ILogLoopParams) => ILogLoopParams | void;
|
|
64
|
+
export type IAnimateFrame = {
|
|
65
|
+
id: number | null;
|
|
66
|
+
duration: number;
|
|
67
|
+
isActive: boolean;
|
|
68
|
+
fn(timer: number): void;
|
|
69
|
+
start(duration: number): void;
|
|
70
|
+
stop(id?: number): void;
|
|
71
|
+
animate(timer: number): void;
|
|
72
|
+
};
|
|
73
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "utils-lib-js",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.24",
|
|
4
4
|
"description": "JavaScript工具函数,封装的一些常用的js函数",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"types": "./dist/cjs/index.d.ts",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"event-message-center": "^1.4.0",
|
|
45
45
|
"js-log-lib": "^1.1.2",
|
|
46
|
-
"js-request-lib": "^1.0.
|
|
46
|
+
"js-request-lib": "^1.0.10",
|
|
47
47
|
"task-queue-lib": "^1.4.2",
|
|
48
48
|
"timer-manager-lib": "^1.0.0"
|
|
49
49
|
},
|