@pisell/utils 1.0.1 → 1.0.2
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/es/date.d.ts +28 -0
- package/es/date.js +59 -0
- package/es/document.d.ts +8 -0
- package/es/document.js +16 -0
- package/es/index.d.ts +3 -1
- package/es/index.js +4 -1
- package/es/otherUtils.d.ts +0 -1
- package/es/platform.d.ts +2 -0
- package/es/platform.js +26 -0
- package/es/typeUtils.d.ts +0 -1
- package/lib/date.d.ts +28 -0
- package/lib/date.js +68 -0
- package/lib/document.d.ts +8 -0
- package/lib/document.js +38 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +7 -1
- package/lib/otherUtils.d.ts +0 -1
- package/lib/platform.d.ts +2 -0
- package/lib/platform.js +58 -0
- package/lib/typeUtils.d.ts +0 -1
- package/package.json +13 -2
- package/.fatherrc.ts +0 -7
- package/CHANGELOG.md +0 -7
- package/es/index.d.ts.map +0 -1
- package/es/otherUtils.d.ts.map +0 -1
- package/es/typeUtils.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/otherUtils.d.ts.map +0 -1
- package/lib/typeUtils.d.ts.map +0 -1
- package/src/index.ts +0 -2
- package/src/otherUtils.ts +0 -13
- package/src/typeUtils.ts +0 -79
- package/tsconfig.json +0 -14
package/es/date.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @title: 格式化日期
|
|
3
|
+
* @description:
|
|
4
|
+
* @param {string} date
|
|
5
|
+
* @param {string} format
|
|
6
|
+
* @return {*}
|
|
7
|
+
* @Author: zhiwei.Wang
|
|
8
|
+
* @Date: 2023-07-21 10:49
|
|
9
|
+
*/
|
|
10
|
+
export declare const formatDate: (date: string | Date, format?: string) => string;
|
|
11
|
+
/**
|
|
12
|
+
* @title: excel日期 转 js日期
|
|
13
|
+
* @description:
|
|
14
|
+
* @param {number} excelDate
|
|
15
|
+
* @return {*}
|
|
16
|
+
* @Author: zhiwei.Wang
|
|
17
|
+
* @Date: 2023-07-21 10:49
|
|
18
|
+
*/
|
|
19
|
+
export declare const excelDateToJSDate: (excelDate: number) => string;
|
|
20
|
+
/**
|
|
21
|
+
* @title: js日期 转 excel日期
|
|
22
|
+
* @description:
|
|
23
|
+
* @param {string} jsDate
|
|
24
|
+
* @return {*}
|
|
25
|
+
* @Author: zhiwei.Wang
|
|
26
|
+
* @Date: 2023-07-21 10:49
|
|
27
|
+
*/
|
|
28
|
+
export declare const jsDateToExcelDate: (jsDate: string) => number;
|
package/es/date.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
var formatMaps = [
|
|
3
|
+
// 19 Jul 2023, 09:00am
|
|
4
|
+
'D MMM YYYY, hh:mma',
|
|
5
|
+
// 2023-07-19
|
|
6
|
+
'YYYY-MM-DD'];
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @title: 格式化日期
|
|
10
|
+
* @description:
|
|
11
|
+
* @param {string} date
|
|
12
|
+
* @param {string} format
|
|
13
|
+
* @return {*}
|
|
14
|
+
* @Author: zhiwei.Wang
|
|
15
|
+
* @Date: 2023-07-21 10:49
|
|
16
|
+
*/
|
|
17
|
+
export var formatDate = function formatDate(date, format) {
|
|
18
|
+
// 19 Jul 2023, 09:00am
|
|
19
|
+
var _format = format || formatMaps[0];
|
|
20
|
+
if (!date) {
|
|
21
|
+
return date;
|
|
22
|
+
}
|
|
23
|
+
return dayjs(date).format(_format);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @title: excel日期 转 js日期
|
|
28
|
+
* @description:
|
|
29
|
+
* @param {number} excelDate
|
|
30
|
+
* @return {*}
|
|
31
|
+
* @Author: zhiwei.Wang
|
|
32
|
+
* @Date: 2023-07-21 10:49
|
|
33
|
+
*/
|
|
34
|
+
export var excelDateToJSDate = function excelDateToJSDate(excelDate) {
|
|
35
|
+
// Excel日期的起始日期为1900年1月1日,JavaScript的起始日期为1970年1月1日
|
|
36
|
+
var dateOffset = (excelDate - 25569) * 86400000; // 将天数转换成毫秒数
|
|
37
|
+
|
|
38
|
+
var jsDate = formatDate(new Date(dateOffset), formatMaps[1]);
|
|
39
|
+
return jsDate;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @title: js日期 转 excel日期
|
|
44
|
+
* @description:
|
|
45
|
+
* @param {string} jsDate
|
|
46
|
+
* @return {*}
|
|
47
|
+
* @Author: zhiwei.Wang
|
|
48
|
+
* @Date: 2023-07-21 10:49
|
|
49
|
+
*/
|
|
50
|
+
export var jsDateToExcelDate = function jsDateToExcelDate(jsDate) {
|
|
51
|
+
var _jsDate = new Date(jsDate);
|
|
52
|
+
// Excel日期的起始日期为1900年1月1日,JavaScript的起始日期为1970年1月1日
|
|
53
|
+
var excelStartDate = new Date(Date.UTC(1900, 0, 1)); // Excel的起始日期为UTC的1900年1月1日
|
|
54
|
+
var dateOffset = _jsDate - excelStartDate; // 计算日期之间的偏移量(毫秒数)
|
|
55
|
+
|
|
56
|
+
var excelDate = dateOffset / 86400000 + 25569; // 将毫秒数转换回天数,并加上Excel的起始日期偏移量
|
|
57
|
+
|
|
58
|
+
return excelDate;
|
|
59
|
+
};
|
package/es/document.d.ts
ADDED
package/es/document.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @Title: 设置主题
|
|
3
|
+
* @Describe: 传入字符串键值对
|
|
4
|
+
* @Author: Wzw
|
|
5
|
+
*/
|
|
6
|
+
export var setTheme = function setTheme(themes) {
|
|
7
|
+
try {
|
|
8
|
+
var _themes = Object.entries(themes);
|
|
9
|
+
for (var _i = 0, _themes2 = _themes; _i < _themes2.length; _i++) {
|
|
10
|
+
var item = _themes2[_i];
|
|
11
|
+
document.documentElement.style.setProperty(item[0], item[1]);
|
|
12
|
+
}
|
|
13
|
+
} catch (err) {
|
|
14
|
+
console.error(err);
|
|
15
|
+
}
|
|
16
|
+
};
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/es/otherUtils.d.ts
CHANGED
package/es/platform.d.ts
ADDED
package/es/platform.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export var isIpad = function isIpad() {
|
|
2
|
+
var ua = navigator.userAgent;
|
|
3
|
+
var isSafari = ua.indexOf('Safari') != -1 && ua.indexOf('Version') != -1;
|
|
4
|
+
var isIphone = ua.indexOf('iPhone') != -1 && ua.indexOf('Version') != -1;
|
|
5
|
+
var isIPad = isSafari && !isIphone && 'ontouchend' in document;
|
|
6
|
+
if (!/iphone|ios|ipad|android|mobile/i.test(navigator.userAgent.toLowerCase()) && !isIPad) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
return true;
|
|
10
|
+
};
|
|
11
|
+
export var isMobile = function isMobile() {
|
|
12
|
+
var sUserAgent = window.navigator.userAgent.toLowerCase();
|
|
13
|
+
var bIsIpad = sUserAgent.match(/ipad/i) == 'ipad';
|
|
14
|
+
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == 'iphone os';
|
|
15
|
+
var bIsMidp = sUserAgent.match(/midp/i) == 'midp';
|
|
16
|
+
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == 'rv:1.2.3.4';
|
|
17
|
+
var bIsUc = sUserAgent.match(/ucweb/i) == 'ucweb';
|
|
18
|
+
var bIsAndroid = sUserAgent.match(/android/i) == 'android';
|
|
19
|
+
var bIsCE = sUserAgent.match(/windows ce/i) == 'windows ce';
|
|
20
|
+
var bIsWM = sUserAgent.match(/windows mobile/i) == 'windows mobile';
|
|
21
|
+
if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM || isIpad()) {
|
|
22
|
+
return true;
|
|
23
|
+
} else {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
};
|
package/es/typeUtils.d.ts
CHANGED
package/lib/date.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @title: 格式化日期
|
|
3
|
+
* @description:
|
|
4
|
+
* @param {string} date
|
|
5
|
+
* @param {string} format
|
|
6
|
+
* @return {*}
|
|
7
|
+
* @Author: zhiwei.Wang
|
|
8
|
+
* @Date: 2023-07-21 10:49
|
|
9
|
+
*/
|
|
10
|
+
export declare const formatDate: (date: string | Date, format?: string) => string;
|
|
11
|
+
/**
|
|
12
|
+
* @title: excel日期 转 js日期
|
|
13
|
+
* @description:
|
|
14
|
+
* @param {number} excelDate
|
|
15
|
+
* @return {*}
|
|
16
|
+
* @Author: zhiwei.Wang
|
|
17
|
+
* @Date: 2023-07-21 10:49
|
|
18
|
+
*/
|
|
19
|
+
export declare const excelDateToJSDate: (excelDate: number) => string;
|
|
20
|
+
/**
|
|
21
|
+
* @title: js日期 转 excel日期
|
|
22
|
+
* @description:
|
|
23
|
+
* @param {string} jsDate
|
|
24
|
+
* @return {*}
|
|
25
|
+
* @Author: zhiwei.Wang
|
|
26
|
+
* @Date: 2023-07-21 10:49
|
|
27
|
+
*/
|
|
28
|
+
export declare const jsDateToExcelDate: (jsDate: string) => number;
|
package/lib/date.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/date.ts
|
|
30
|
+
var date_exports = {};
|
|
31
|
+
__export(date_exports, {
|
|
32
|
+
excelDateToJSDate: () => excelDateToJSDate,
|
|
33
|
+
formatDate: () => formatDate,
|
|
34
|
+
jsDateToExcelDate: () => jsDateToExcelDate
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(date_exports);
|
|
37
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
38
|
+
var formatMaps = [
|
|
39
|
+
// 19 Jul 2023, 09:00am
|
|
40
|
+
"D MMM YYYY, hh:mma",
|
|
41
|
+
// 2023-07-19
|
|
42
|
+
"YYYY-MM-DD"
|
|
43
|
+
];
|
|
44
|
+
var formatDate = (date, format) => {
|
|
45
|
+
let _format = format || formatMaps[0];
|
|
46
|
+
if (!date) {
|
|
47
|
+
return date;
|
|
48
|
+
}
|
|
49
|
+
return (0, import_dayjs.default)(date).format(_format);
|
|
50
|
+
};
|
|
51
|
+
var excelDateToJSDate = (excelDate) => {
|
|
52
|
+
const dateOffset = (excelDate - 25569) * 864e5;
|
|
53
|
+
const jsDate = formatDate(new Date(dateOffset), formatMaps[1]);
|
|
54
|
+
return jsDate;
|
|
55
|
+
};
|
|
56
|
+
var jsDateToExcelDate = (jsDate) => {
|
|
57
|
+
const _jsDate = new Date(jsDate);
|
|
58
|
+
const excelStartDate = new Date(Date.UTC(1900, 0, 1));
|
|
59
|
+
const dateOffset = _jsDate - excelStartDate;
|
|
60
|
+
const excelDate = dateOffset / 864e5 + 25569;
|
|
61
|
+
return excelDate;
|
|
62
|
+
};
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
excelDateToJSDate,
|
|
66
|
+
formatDate,
|
|
67
|
+
jsDateToExcelDate
|
|
68
|
+
});
|
package/lib/document.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/document.ts
|
|
20
|
+
var document_exports = {};
|
|
21
|
+
__export(document_exports, {
|
|
22
|
+
setTheme: () => setTheme
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(document_exports);
|
|
25
|
+
var setTheme = (themes) => {
|
|
26
|
+
try {
|
|
27
|
+
let _themes = Object.entries(themes);
|
|
28
|
+
for (let item of _themes) {
|
|
29
|
+
document.documentElement.style.setProperty(item[0], item[1]);
|
|
30
|
+
}
|
|
31
|
+
} catch (err) {
|
|
32
|
+
console.error(err);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
setTheme
|
|
38
|
+
});
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -18,8 +18,14 @@ var src_exports = {};
|
|
|
18
18
|
module.exports = __toCommonJS(src_exports);
|
|
19
19
|
__reExport(src_exports, require("./otherUtils"), module.exports);
|
|
20
20
|
__reExport(src_exports, require("./typeUtils"), module.exports);
|
|
21
|
+
__reExport(src_exports, require("./document"), module.exports);
|
|
22
|
+
__reExport(src_exports, require("./date"), module.exports);
|
|
23
|
+
__reExport(src_exports, require("./platform"), module.exports);
|
|
21
24
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22
25
|
0 && (module.exports = {
|
|
23
26
|
...require("./otherUtils"),
|
|
24
|
-
...require("./typeUtils")
|
|
27
|
+
...require("./typeUtils"),
|
|
28
|
+
...require("./document"),
|
|
29
|
+
...require("./date"),
|
|
30
|
+
...require("./platform")
|
|
25
31
|
});
|
package/lib/otherUtils.d.ts
CHANGED
package/lib/platform.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/platform.ts
|
|
20
|
+
var platform_exports = {};
|
|
21
|
+
__export(platform_exports, {
|
|
22
|
+
isIpad: () => isIpad,
|
|
23
|
+
isMobile: () => isMobile
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(platform_exports);
|
|
26
|
+
var isIpad = () => {
|
|
27
|
+
var ua = navigator.userAgent;
|
|
28
|
+
var isSafari = ua.indexOf("Safari") != -1 && ua.indexOf("Version") != -1;
|
|
29
|
+
var isIphone = ua.indexOf("iPhone") != -1 && ua.indexOf("Version") != -1;
|
|
30
|
+
var isIPad = isSafari && !isIphone && "ontouchend" in document;
|
|
31
|
+
if (!/iphone|ios|ipad|android|mobile/i.test(
|
|
32
|
+
navigator.userAgent.toLowerCase()
|
|
33
|
+
) && !isIPad) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
};
|
|
38
|
+
var isMobile = () => {
|
|
39
|
+
let sUserAgent = window.navigator.userAgent.toLowerCase();
|
|
40
|
+
let bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
|
|
41
|
+
let bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
|
|
42
|
+
let bIsMidp = sUserAgent.match(/midp/i) == "midp";
|
|
43
|
+
let bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
|
|
44
|
+
let bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
|
|
45
|
+
let bIsAndroid = sUserAgent.match(/android/i) == "android";
|
|
46
|
+
let bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
|
|
47
|
+
let bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
|
|
48
|
+
if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM || isIpad()) {
|
|
49
|
+
return true;
|
|
50
|
+
} else {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
isIpad,
|
|
57
|
+
isMobile
|
|
58
|
+
});
|
package/lib/typeUtils.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"main": "./lib/index.js",
|
|
5
|
+
"module": "./es/index.js",
|
|
6
|
+
"types": "./lib/index.d.ts",
|
|
7
|
+
"typings": "./lib/index.d.ts",
|
|
4
8
|
"devDependencies": {
|
|
5
|
-
"father": "^4.1.0"
|
|
9
|
+
"father": "^4.1.0",
|
|
10
|
+
"dayjs": "^1.11.9"
|
|
6
11
|
},
|
|
12
|
+
"files": [
|
|
13
|
+
"es",
|
|
14
|
+
"lib",
|
|
15
|
+
"package.json",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
7
18
|
"publishConfig": {
|
|
8
19
|
"access": "public"
|
|
9
20
|
},
|
package/.fatherrc.ts
DELETED
package/CHANGELOG.md
DELETED
package/es/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|
package/es/otherUtils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"otherUtils.d.ts","sourceRoot":"","sources":["otherUtils.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,iDAIvB,CAAC"}
|
package/es/typeUtils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typeUtils.d.ts","sourceRoot":"","sources":["typeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,UAAU,QAAS,GAAG,oBACR,CAAC;AAE5B;;;GAGG;AACH,eAAO,MAAM,KAAK,QAAS,GAAG,iBAA0C,CAAC;AAEzE;;;GAGG;AACH,eAAO,MAAM,QAAQ,QAAS,GAAG,kBAA2C,CAAC;AAE7E;;;GAGG;AACH,eAAO,MAAM,QAAQ,QAAS,GAAG,kBAA2C,CAAC;AAE7E;;;GAGG;AACH,eAAO,MAAM,WAAW,QAAS,GAAG,qBACR,CAAC;AAE7B;;;GAGG;AACH,eAAO,MAAM,SAAS,QAAS,GAAG,mBAA6C,CAAC;AAEhF;;;GAGG;AACH,eAAO,MAAM,MAAM,MAAO,GAAG,KAAG,OAU/B,CAAC;AAOF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAS,GAAG,YAarC,CAAC"}
|
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|
package/lib/otherUtils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"otherUtils.d.ts","sourceRoot":"","sources":["otherUtils.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,iDAIvB,CAAC"}
|
package/lib/typeUtils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typeUtils.d.ts","sourceRoot":"","sources":["typeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,UAAU,QAAS,GAAG,oBACR,CAAC;AAE5B;;;GAGG;AACH,eAAO,MAAM,KAAK,QAAS,GAAG,iBAA0C,CAAC;AAEzE;;;GAGG;AACH,eAAO,MAAM,QAAQ,QAAS,GAAG,kBAA2C,CAAC;AAE7E;;;GAGG;AACH,eAAO,MAAM,QAAQ,QAAS,GAAG,kBAA2C,CAAC;AAE7E;;;GAGG;AACH,eAAO,MAAM,WAAW,QAAS,GAAG,qBACR,CAAC;AAE7B;;;GAGG;AACH,eAAO,MAAM,SAAS,QAAS,GAAG,mBAA6C,CAAC;AAEhF;;;GAGG;AACH,eAAO,MAAM,MAAM,MAAO,GAAG,KAAG,OAU/B,CAAC;AAOF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAS,GAAG,YAarC,CAAC"}
|
package/src/index.ts
DELETED
package/src/otherUtils.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @Description: 生成唯一id
|
|
4
|
-
* @Author: wzw
|
|
5
|
-
* @Date: 2020-12-01 14:20:29
|
|
6
|
-
* @param {*}
|
|
7
|
-
* @return {*}
|
|
8
|
-
*/
|
|
9
|
-
export const getUniqueId = (prefix = '', maxLength = 11) => {
|
|
10
|
-
return (
|
|
11
|
-
prefix + (Math.random() + '').replace(/\D/g, '').substring(0, maxLength)
|
|
12
|
-
);
|
|
13
|
-
};
|
package/src/typeUtils.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 判断是否是函数
|
|
3
|
-
* @param obj
|
|
4
|
-
*/
|
|
5
|
-
export const isFunction = (obj: any): obj is Function =>
|
|
6
|
-
typeof obj === 'function';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 判断是否是数组
|
|
10
|
-
* @param obj
|
|
11
|
-
*/
|
|
12
|
-
export const isArr = (obj: any): obj is Array<any> => Array.isArray(obj);
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 判断是否是字符串
|
|
16
|
-
* @param obj
|
|
17
|
-
*/
|
|
18
|
-
export const isString = (obj: any): obj is string => typeof obj === 'string';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* 判断是否是数字
|
|
22
|
-
* @param obj
|
|
23
|
-
*/
|
|
24
|
-
export const isNumber = (obj: any): obj is number => typeof obj === 'number';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* 判断是否是undefined
|
|
28
|
-
* @param obj
|
|
29
|
-
*/
|
|
30
|
-
export const isUndefined = (obj: any): obj is undefined =>
|
|
31
|
-
typeof obj === 'undefined';
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* 判断是否是boolean
|
|
35
|
-
* @param obj
|
|
36
|
-
*/
|
|
37
|
-
export const isBoolean = (obj: any): obj is boolean => typeof obj === 'boolean';
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 判断是否是json字符串
|
|
41
|
-
* @param v
|
|
42
|
-
*/
|
|
43
|
-
export const isJson = (v: any): boolean => {
|
|
44
|
-
if (typeof v === 'string') {
|
|
45
|
-
try {
|
|
46
|
-
return JSON.parse(v);
|
|
47
|
-
} catch (e) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const getProto = Object.getPrototypeOf;
|
|
56
|
-
const hasOwn = {}.hasOwnProperty;
|
|
57
|
-
const fnToString = hasOwn.toString;
|
|
58
|
-
const ObjectFunctionString = fnToString.call(Object);
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* @Title: 判断是否为对象
|
|
62
|
-
* @Describe:
|
|
63
|
-
* @Author: Wzw
|
|
64
|
-
* @param {any} obj
|
|
65
|
-
*/
|
|
66
|
-
export const isPlainObject = (obj: any) => {
|
|
67
|
-
var proto, Ctor;
|
|
68
|
-
if (!obj || toString.call(obj) !== '[object Object]') {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
proto = getProto(obj);
|
|
72
|
-
if (!proto) {
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
Ctor = hasOwn.call(proto, 'constructor') && proto.constructor;
|
|
76
|
-
return (
|
|
77
|
-
typeof Ctor === 'function' && fnToString.call(Ctor) === ObjectFunctionString
|
|
78
|
-
);
|
|
79
|
-
};
|