utils-lib-js 1.5.1 → 1.6.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/commonjs.json +3 -0
- package/dist/{common → cjs}/array.d.ts +6 -0
- package/dist/{common → cjs}/array.js +6 -1
- package/dist/{common → cjs}/base.d.ts +8 -0
- package/dist/{common → cjs}/base.js +8 -1
- package/dist/cjs/element.d.ts +6 -0
- package/dist/{common → cjs}/element.js +4 -1
- package/dist/{common → cjs}/event.d.ts +8 -0
- package/dist/{common → cjs}/event.js +8 -1
- package/dist/{common → cjs}/function.d.ts +7 -0
- package/dist/{common → cjs}/function.js +7 -1
- package/dist/cjs/index.d.ts +49 -0
- package/dist/cjs/index.js +52 -0
- package/dist/{common → cjs}/object.d.ts +16 -0
- package/dist/{common → cjs}/object.js +16 -1
- package/dist/cjs/package.json +3 -0
- package/dist/{common → cjs}/request.d.ts +4 -1
- package/dist/{common → cjs}/request.js +2 -1
- package/dist/{common → cjs}/static.d.ts +4 -0
- package/dist/{common → cjs}/static.js +2 -1
- package/dist/cjs/storage.d.ts +9 -0
- package/dist/{common → cjs}/storage.js +6 -1
- package/dist/{common → cjs}/types.d.ts +0 -0
- package/dist/{common → cjs}/types.js +0 -0
- package/dist/esm/array.d.ts +6 -0
- package/dist/esm/array.js +23 -8
- package/dist/esm/base.d.ts +8 -0
- package/dist/esm/base.js +54 -41
- package/dist/esm/element.d.ts +4 -0
- package/dist/esm/element.js +19 -9
- package/dist/esm/event.d.ts +8 -0
- package/dist/esm/event.js +41 -38
- package/dist/esm/function.d.ts +7 -0
- package/dist/esm/function.js +64 -53
- package/dist/esm/index.d.ts +39 -0
- package/dist/esm/index.js +30 -10
- package/dist/esm/object.d.ts +16 -0
- package/dist/esm/object.js +183 -159
- package/dist/esm/request.d.ts +4 -1
- package/dist/esm/request.js +300 -235
- package/dist/esm/static.d.ts +4 -0
- package/dist/esm/static.js +15 -14
- package/dist/esm/storage.d.ts +6 -0
- package/dist/esm/storage.js +32 -30
- package/dist/esm/types.js +1 -1
- package/package.json +44 -42
- package/tsconfig.json +1 -1
- package/dist/common/element.d.ts +0 -2
- package/dist/common/index.d.ts +0 -10
- package/dist/common/index.js +0 -29
- package/dist/common/storage.d.ts +0 -3
- package/dist/esm/index.mjs +0 -692
package/commonjs.json
ADDED
|
@@ -2,3 +2,9 @@ import { IArrayRandom, IArrayUniq, IArrayDemote, IDemoteArray } from "./index.js
|
|
|
2
2
|
export declare const arrayRandom: IArrayRandom<any[]>;
|
|
3
3
|
export declare const arrayUniq: IArrayUniq<any[]>;
|
|
4
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;
|
|
@@ -22,4 +22,9 @@ var arrayDemote = function (arr, result) {
|
|
|
22
22
|
});
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
exports.arrayDemote = arrayDemote;
|
|
25
|
+
exports.arrayDemote = arrayDemote;
|
|
26
|
+
exports.default = {
|
|
27
|
+
arrayRandom: exports.arrayRandom,
|
|
28
|
+
arrayUniq: exports.arrayUniq,
|
|
29
|
+
arrayDemote: exports.arrayDemote
|
|
30
|
+
};
|
|
@@ -4,3 +4,11 @@ export declare const urlSplit: IUrlSplit;
|
|
|
4
4
|
export declare const urlJoin: IUrlJoin;
|
|
5
5
|
export declare const getType: IGetType<types>;
|
|
6
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;
|
|
@@ -53,4 +53,11 @@ var getTypeByList = function (data, whiteList) {
|
|
|
53
53
|
var __type = (0, exports.getType)(data);
|
|
54
54
|
return whiteList.indexOf(__type) > 0;
|
|
55
55
|
};
|
|
56
|
-
exports.getTypeByList = getTypeByList;
|
|
56
|
+
exports.getTypeByList = getTypeByList;
|
|
57
|
+
exports.default = {
|
|
58
|
+
randomNum: exports.randomNum,
|
|
59
|
+
urlSplit: exports.urlSplit,
|
|
60
|
+
urlJoin: exports.urlJoin,
|
|
61
|
+
getType: exports.getType,
|
|
62
|
+
getTypeByList: exports.getTypeByList
|
|
63
|
+
};
|
|
@@ -4,3 +4,11 @@ export declare const stopBubble: IStopBubble;
|
|
|
4
4
|
export declare const stopDefault: IStopDefault;
|
|
5
5
|
export declare const removeHandler: IRemoveHandler;
|
|
6
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;
|
|
@@ -40,4 +40,11 @@ var dispatchEvent = function (ele, data) {
|
|
|
40
40
|
var evts = new Event(data);
|
|
41
41
|
ele.dispatchEvent(evts);
|
|
42
42
|
};
|
|
43
|
-
exports.dispatchEvent = dispatchEvent;
|
|
43
|
+
exports.dispatchEvent = dispatchEvent;
|
|
44
|
+
exports.default = {
|
|
45
|
+
addHandler: exports.addHandler,
|
|
46
|
+
stopBubble: exports.stopBubble,
|
|
47
|
+
stopDefault: exports.stopDefault,
|
|
48
|
+
removeHandler: exports.removeHandler,
|
|
49
|
+
dispatchEvent: exports.dispatchEvent
|
|
50
|
+
};
|
|
@@ -3,3 +3,10 @@ export declare const throttle: IThrottle;
|
|
|
3
3
|
export declare const debounce: IDebounce;
|
|
4
4
|
export declare const defer: IDefer;
|
|
5
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;
|
|
@@ -63,4 +63,10 @@ var catchAwait = function (defer) {
|
|
|
63
63
|
return [err];
|
|
64
64
|
});
|
|
65
65
|
};
|
|
66
|
-
exports.catchAwait = catchAwait;
|
|
66
|
+
exports.catchAwait = catchAwait;
|
|
67
|
+
exports.default = {
|
|
68
|
+
throttle: exports.throttle,
|
|
69
|
+
debounce: exports.debounce,
|
|
70
|
+
defer: exports.defer,
|
|
71
|
+
catchAwait: exports.catchAwait
|
|
72
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export * from "./object.js";
|
|
2
|
+
export * from "./base.js";
|
|
3
|
+
export * from "./array.js";
|
|
4
|
+
export * from "./function.js";
|
|
5
|
+
export * from "./element.js";
|
|
6
|
+
export * from "./static.js";
|
|
7
|
+
export * from "./types.js";
|
|
8
|
+
export * from "./request.js";
|
|
9
|
+
export * from "./event.js";
|
|
10
|
+
export * from "./storage.js";
|
|
11
|
+
declare const _default: {
|
|
12
|
+
setStorage: (key: string, val: any) => void;
|
|
13
|
+
getStorage: (key: string) => any;
|
|
14
|
+
clearStorage: (key: string) => void;
|
|
15
|
+
addHandler: import("./types.js").IAddHandler;
|
|
16
|
+
stopBubble: import("./types.js").IStopBubble;
|
|
17
|
+
stopDefault: import("./types.js").IStopDefault;
|
|
18
|
+
removeHandler: import("./types.js").IRemoveHandler;
|
|
19
|
+
dispatchEvent: import("./types.js").IDispatchEvent;
|
|
20
|
+
Request: typeof import("./request.js").Request;
|
|
21
|
+
types: typeof import("./static.js").types;
|
|
22
|
+
createElement: import("./types.js").ICreateElement<HTMLElement>;
|
|
23
|
+
throttle: import("./types.js").IThrottle;
|
|
24
|
+
debounce: import("./types.js").IDebounce;
|
|
25
|
+
defer: import("./types.js").IDefer;
|
|
26
|
+
catchAwait: import("./types.js").ICatchAwait<Promise<any>>;
|
|
27
|
+
arrayRandom: import("./types.js").IArrayRandom<any[]>;
|
|
28
|
+
arrayUniq: import("./types.js").IArrayUniq<any[]>;
|
|
29
|
+
arrayDemote: import("./types.js").IArrayDemote<import("./types.js").IDemoteArray<any>>;
|
|
30
|
+
randomNum: import("./types.js").IRandomNum;
|
|
31
|
+
urlSplit: import("./types.js").IUrlSplit;
|
|
32
|
+
urlJoin: import("./types.js").IUrlJoin;
|
|
33
|
+
getType: import("./types.js").IGetType<import("./static.js").types>;
|
|
34
|
+
getTypeByList: import("./types.js").IGetTypeByList;
|
|
35
|
+
getValue: import("./types.js").IGetValue;
|
|
36
|
+
setValue: import("./types.js").ISetValue;
|
|
37
|
+
mixIn: import("./types.js").IMixIn;
|
|
38
|
+
enumInversion: import("./types.js").IEnumInversion;
|
|
39
|
+
isNotObject: (source: any, type: any) => boolean;
|
|
40
|
+
cloneDeep: import("./types.js").ICloneDeep;
|
|
41
|
+
createObjectVariable: import("./types.js").ICreateObjectVariable;
|
|
42
|
+
createObject: import("./types.js").ICreateObject;
|
|
43
|
+
inherit: import("./types.js").IInherit;
|
|
44
|
+
getInstance: import("./types.js").IGetInstance;
|
|
45
|
+
classDecorator: import("./types.js").IClassDecorator;
|
|
46
|
+
stringToJson: import("./types.js").IStringToJson;
|
|
47
|
+
jsonToString: import("./types.js").IJsonToString;
|
|
48
|
+
};
|
|
49
|
+
export default _default;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __assign = this && this.__assign || function () {
|
|
4
|
+
__assign = Object.assign || function (t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function () {
|
|
18
|
+
return m[k];
|
|
19
|
+
} };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
} : function (o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
});
|
|
26
|
+
var __exportStar = this && this.__exportStar || function (m, exports) {
|
|
27
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
28
|
+
};
|
|
29
|
+
var __importDefault = this && this.__importDefault || function (mod) {
|
|
30
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
__exportStar(require("./object.js"), exports);
|
|
34
|
+
__exportStar(require("./base.js"), exports);
|
|
35
|
+
__exportStar(require("./array.js"), exports);
|
|
36
|
+
__exportStar(require("./function.js"), exports);
|
|
37
|
+
__exportStar(require("./element.js"), exports);
|
|
38
|
+
__exportStar(require("./static.js"), exports);
|
|
39
|
+
__exportStar(require("./types.js"), exports);
|
|
40
|
+
__exportStar(require("./request.js"), exports);
|
|
41
|
+
__exportStar(require("./event.js"), exports);
|
|
42
|
+
__exportStar(require("./storage.js"), exports);
|
|
43
|
+
var object_js_1 = __importDefault(require("./object.js"));
|
|
44
|
+
var base_js_1 = __importDefault(require("./base.js"));
|
|
45
|
+
var array_js_1 = __importDefault(require("./array.js"));
|
|
46
|
+
var function_js_1 = __importDefault(require("./function.js"));
|
|
47
|
+
var element_js_1 = __importDefault(require("./element.js"));
|
|
48
|
+
var static_js_1 = __importDefault(require("./static.js"));
|
|
49
|
+
var request_js_1 = __importDefault(require("./request.js"));
|
|
50
|
+
var event_js_1 = __importDefault(require("./event.js"));
|
|
51
|
+
var storage_js_1 = __importDefault(require("./storage.js"));
|
|
52
|
+
exports.default = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, object_js_1.default), base_js_1.default), array_js_1.default), function_js_1.default), element_js_1.default), static_js_1.default), request_js_1.default), event_js_1.default), storage_js_1.default);
|
|
@@ -12,3 +12,19 @@ export declare const getInstance: IGetInstance;
|
|
|
12
12
|
export declare const classDecorator: IClassDecorator;
|
|
13
13
|
export declare const stringToJson: IStringToJson;
|
|
14
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;
|
|
@@ -182,4 +182,19 @@ var jsonToString = function (target) {
|
|
|
182
182
|
return "";
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
|
-
exports.jsonToString = jsonToString;
|
|
185
|
+
exports.jsonToString = jsonToString;
|
|
186
|
+
exports.default = {
|
|
187
|
+
getValue: exports.getValue,
|
|
188
|
+
setValue: exports.setValue,
|
|
189
|
+
mixIn: exports.mixIn,
|
|
190
|
+
enumInversion: exports.enumInversion,
|
|
191
|
+
isNotObject: exports.isNotObject,
|
|
192
|
+
cloneDeep: exports.cloneDeep,
|
|
193
|
+
createObjectVariable: exports.createObjectVariable,
|
|
194
|
+
createObject: exports.createObject,
|
|
195
|
+
inherit: exports.inherit,
|
|
196
|
+
getInstance: exports.getInstance,
|
|
197
|
+
classDecorator: exports.classDecorator,
|
|
198
|
+
stringToJson: exports.stringToJson,
|
|
199
|
+
jsonToString: exports.jsonToString
|
|
200
|
+
};
|
|
@@ -54,4 +54,7 @@ export declare class Request extends RequestInit implements IRequest {
|
|
|
54
54
|
HEAD: (url?: IUrl, query?: IObject<any>, body?: IRequestBody, opts?: IRequestOptions) => any;
|
|
55
55
|
PATCH: (url?: IUrl, query?: IObject<any>, body?: IRequestBody, opts?: IRequestOptions) => any;
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
declare const _default: {
|
|
58
|
+
Request: typeof Request;
|
|
59
|
+
};
|
|
60
|
+
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;
|
|
@@ -31,4 +31,9 @@ var clearStorage = function (key) {
|
|
|
31
31
|
console.error(error);
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
-
exports.clearStorage = clearStorage;
|
|
34
|
+
exports.clearStorage = clearStorage;
|
|
35
|
+
exports.default = {
|
|
36
|
+
setStorage: exports.setStorage,
|
|
37
|
+
getStorage: exports.getStorage,
|
|
38
|
+
clearStorage: exports.clearStorage
|
|
39
|
+
};
|
|
File without changes
|
|
File without changes
|
package/dist/esm/array.d.ts
CHANGED
|
@@ -2,3 +2,9 @@ import { IArrayRandom, IArrayUniq, IArrayDemote, IDemoteArray } from "./index.js
|
|
|
2
2
|
export declare const arrayRandom: IArrayRandom<any[]>;
|
|
3
3
|
export declare const arrayUniq: IArrayUniq<any[]>;
|
|
4
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/array.js
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
|
-
import { getType } from "./index.js";
|
|
2
|
-
export var arrayRandom = function (arr) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { getType } from "./index.js";
|
|
2
|
+
export var arrayRandom = function (arr) {
|
|
3
|
+
return arr.sort(function () {
|
|
4
|
+
return Math.random() - 0.5;
|
|
5
|
+
});
|
|
6
|
+
};
|
|
7
|
+
export var arrayUniq = function (arr) {
|
|
8
|
+
return Array.from(new Set(arr));
|
|
9
|
+
};
|
|
10
|
+
export var arrayDemote = function (arr, result) {
|
|
11
|
+
if (result === void 0) {
|
|
12
|
+
result = [];
|
|
13
|
+
}
|
|
14
|
+
arr.forEach(function (i) {
|
|
15
|
+
return getType(i) === "array" ? arrayDemote(i, result) : result.push(i);
|
|
16
|
+
});
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
19
|
+
export default {
|
|
20
|
+
arrayRandom: arrayRandom,
|
|
21
|
+
arrayUniq: arrayUniq,
|
|
22
|
+
arrayDemote: arrayDemote
|
|
23
|
+
};
|
package/dist/esm/base.d.ts
CHANGED
|
@@ -4,3 +4,11 @@ export declare const urlSplit: IUrlSplit;
|
|
|
4
4
|
export declare const urlJoin: IUrlJoin;
|
|
5
5
|
export declare const getType: IGetType<types>;
|
|
6
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/base.js
CHANGED
|
@@ -1,41 +1,54 @@
|
|
|
1
|
-
import { types } from "./index.js";
|
|
2
|
-
export var randomNum = function (min, max, bool) {
|
|
3
|
-
if (bool === void 0) {
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
1
|
+
import { types } from "./index.js";
|
|
2
|
+
export var randomNum = function (min, max, bool) {
|
|
3
|
+
if (bool === void 0) {
|
|
4
|
+
bool = false;
|
|
5
|
+
}
|
|
6
|
+
return Math.floor(Math.random() * (max - min + (bool ? 1 : 0)) + min);
|
|
7
|
+
};
|
|
8
|
+
export var urlSplit = function (url) {
|
|
9
|
+
var result = {};
|
|
10
|
+
if (!url.includes("?")) {
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
var params = url.split("?")[1].split("&");
|
|
14
|
+
params.forEach(function (i) {
|
|
15
|
+
var key = i.split("=")[0];
|
|
16
|
+
result[key] = i.split("=")[1];
|
|
17
|
+
});
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
20
|
+
export var urlJoin = function (url, query) {
|
|
21
|
+
if (query === void 0) {
|
|
22
|
+
query = {};
|
|
23
|
+
}
|
|
24
|
+
var queryObject = Object.keys(query);
|
|
25
|
+
if (queryObject.length === 0) return url;
|
|
26
|
+
var params = queryObject.map(function (i) {
|
|
27
|
+
return "".concat(i, "=").concat(query[i]);
|
|
28
|
+
});
|
|
29
|
+
return "".concat(url).concat(url.includes("?") ? "&" : '?').concat(params.join("&"));
|
|
30
|
+
};
|
|
31
|
+
export var getType = function (data) {
|
|
32
|
+
var type = typeof data;
|
|
33
|
+
if (data === null) {
|
|
34
|
+
return "null";
|
|
35
|
+
} else if (type === "object") {
|
|
36
|
+
var key = Object.prototype.toString.call(data);
|
|
37
|
+
return types[key];
|
|
38
|
+
}
|
|
39
|
+
return type;
|
|
40
|
+
};
|
|
41
|
+
export var getTypeByList = function (data, whiteList) {
|
|
42
|
+
if (whiteList === void 0) {
|
|
43
|
+
whiteList = [];
|
|
44
|
+
}
|
|
45
|
+
var __type = getType(data);
|
|
46
|
+
return whiteList.indexOf(__type) > 0;
|
|
47
|
+
};
|
|
48
|
+
export default {
|
|
49
|
+
randomNum: randomNum,
|
|
50
|
+
urlSplit: urlSplit,
|
|
51
|
+
urlJoin: urlJoin,
|
|
52
|
+
getType: getType,
|
|
53
|
+
getTypeByList: getTypeByList
|
|
54
|
+
};
|
package/dist/esm/element.d.ts
CHANGED
package/dist/esm/element.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
export var createElement = function (_a) {
|
|
2
|
-
var _b, _c;
|
|
3
|
-
var ele = _a.ele,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
export var createElement = function (_a) {
|
|
2
|
+
var _b, _c;
|
|
3
|
+
var ele = _a.ele,
|
|
4
|
+
style = _a.style,
|
|
5
|
+
attr = _a.attr,
|
|
6
|
+
parent = _a.parent;
|
|
7
|
+
var element = ele instanceof HTMLElement ? ele : document.createElement(ele !== null && ele !== void 0 ? ele : 'div');
|
|
8
|
+
style && ((_b = Object.keys(style)) === null || _b === void 0 ? void 0 : _b.forEach(function (key) {
|
|
9
|
+
return element.style[key] = style[key];
|
|
10
|
+
}));
|
|
11
|
+
attr && ((_c = Object.keys(style)) === null || _c === void 0 ? void 0 : _c.forEach(function (key) {
|
|
12
|
+
return element[key] = attr[key];
|
|
13
|
+
}));
|
|
14
|
+
parent && parent.appendChild(element);
|
|
15
|
+
return element;
|
|
16
|
+
};
|
|
17
|
+
export default {
|
|
18
|
+
createElement: createElement
|
|
19
|
+
};
|
package/dist/esm/event.d.ts
CHANGED
|
@@ -4,3 +4,11 @@ export declare const stopBubble: IStopBubble;
|
|
|
4
4
|
export declare const stopDefault: IStopDefault;
|
|
5
5
|
export declare const removeHandler: IRemoveHandler;
|
|
6
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/event.js
CHANGED
|
@@ -1,38 +1,41 @@
|
|
|
1
|
-
export var addHandler = function (ele, type, handler) {
|
|
2
|
-
if (ele.addEventListener) {
|
|
3
|
-
ele.addEventListener(type, handler, false);
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
event.
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
export
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
export var addHandler = function (ele, type, handler) {
|
|
2
|
+
if (ele.addEventListener) {
|
|
3
|
+
ele.addEventListener(type, handler, false);
|
|
4
|
+
} else {
|
|
5
|
+
ele["on" + type] = handler;
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
export var stopBubble = function (event) {
|
|
9
|
+
event = event || window.event;
|
|
10
|
+
if (event.stopPropagation) {
|
|
11
|
+
event.stopPropagation();
|
|
12
|
+
} else {
|
|
13
|
+
event.cancelBubble = false;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export var stopDefault = function (event) {
|
|
17
|
+
event = event || window.event;
|
|
18
|
+
if (event.preventDefault) {
|
|
19
|
+
event.preventDefault();
|
|
20
|
+
} else {
|
|
21
|
+
event.returnValue = false;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export var removeHandler = function (ele, type, handler) {
|
|
25
|
+
if (ele.removeEventListener) {
|
|
26
|
+
ele.removeEventListener(type, handler, false);
|
|
27
|
+
} else {
|
|
28
|
+
ele["on" + type] = null;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export var dispatchEvent = function (ele, data) {
|
|
32
|
+
var evts = new Event(data);
|
|
33
|
+
ele.dispatchEvent(evts);
|
|
34
|
+
};
|
|
35
|
+
export default {
|
|
36
|
+
addHandler: addHandler,
|
|
37
|
+
stopBubble: stopBubble,
|
|
38
|
+
stopDefault: stopDefault,
|
|
39
|
+
removeHandler: removeHandler,
|
|
40
|
+
dispatchEvent: dispatchEvent
|
|
41
|
+
};
|
package/dist/esm/function.d.ts
CHANGED
|
@@ -3,3 +3,10 @@ export declare const throttle: IThrottle;
|
|
|
3
3
|
export declare const debounce: IDebounce;
|
|
4
4
|
export declare const defer: IDefer;
|
|
5
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;
|