tools-min-ns 1.18.16 → 1.18.18
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/README.md +4 -0
- package/esm/date/DateUtil.d.ts +7 -0
- package/esm/date/DateUtil.js +23 -0
- package/esm/file/FileUtil.d.ts +1 -0
- package/esm/file/FileUtil.js +11 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/lib/date/DateUtil.d.ts +7 -0
- package/lib/date/DateUtil.js +23 -0
- package/lib/file/FileUtil.d.ts +1 -0
- package/lib/file/FileUtil.js +11 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +8 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/esm/date/DateUtil.d.ts
CHANGED
|
@@ -74,6 +74,13 @@ declare namespace DateUtil {
|
|
|
74
74
|
* formatDateToFriendly2() => 2017年11月11日
|
|
75
75
|
*/
|
|
76
76
|
function formatDateToFriendly3(date?: Date | number | string): string;
|
|
77
|
+
/**
|
|
78
|
+
* 格式化时间为友好格式
|
|
79
|
+
* @param seconds
|
|
80
|
+
* @example
|
|
81
|
+
* formatBySeconds(10) => 10秒
|
|
82
|
+
*/
|
|
83
|
+
function formatBySeconds(seconds: number): string;
|
|
77
84
|
/**
|
|
78
85
|
* 判断是否为本周
|
|
79
86
|
* @param date
|
package/esm/date/DateUtil.js
CHANGED
|
@@ -233,6 +233,29 @@ var DateUtil;
|
|
|
233
233
|
return "".concat(years, "\u5E74\u524D");
|
|
234
234
|
}
|
|
235
235
|
DateUtil.formatDateToFriendly3 = formatDateToFriendly3;
|
|
236
|
+
/**
|
|
237
|
+
* 格式化时间为友好格式
|
|
238
|
+
* @param seconds
|
|
239
|
+
* @example
|
|
240
|
+
* formatBySeconds(10) => 10秒
|
|
241
|
+
*/
|
|
242
|
+
function formatBySeconds(seconds) {
|
|
243
|
+
if (!isFinite(seconds) || seconds < 0) return '计算中...';
|
|
244
|
+
var day = Math.floor(seconds / 3600 * 24);
|
|
245
|
+
var hours = Math.floor(seconds / 3600);
|
|
246
|
+
var minutes = Math.floor(seconds % 3600 / 60);
|
|
247
|
+
var secs = Math.floor(seconds % 60);
|
|
248
|
+
if (day > 0) {
|
|
249
|
+
return "".concat(day, "\u5929").concat(hours, "\u5C0F\u65F6").concat(minutes, "\u5206\u949F").concat(secs, "\u79D2");
|
|
250
|
+
} else if (hours > 0) {
|
|
251
|
+
return "".concat(hours, "\u5C0F\u65F6").concat(minutes, "\u5206\u949F").concat(secs, "\u79D2");
|
|
252
|
+
} else if (minutes > 0) {
|
|
253
|
+
return "".concat(minutes, "\u5206\u949F").concat(secs, "\u79D2");
|
|
254
|
+
} else {
|
|
255
|
+
return "".concat(secs, "\u79D2");
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
DateUtil.formatBySeconds = formatBySeconds;
|
|
236
259
|
/**
|
|
237
260
|
* 判断是否为本周
|
|
238
261
|
* @param date
|
package/esm/file/FileUtil.d.ts
CHANGED
|
@@ -11,5 +11,6 @@ declare namespace FileUtil {
|
|
|
11
11
|
*/
|
|
12
12
|
function getExt(url: string): string;
|
|
13
13
|
const ellisipsFileName: (fileName: string | undefined, maxLength?: number) => string;
|
|
14
|
+
const getFileName: (url: string, maxLength?: number) => string | undefined;
|
|
14
15
|
}
|
|
15
16
|
export default FileUtil;
|
package/esm/file/FileUtil.js
CHANGED
|
@@ -40,5 +40,16 @@ var FileUtil;
|
|
|
40
40
|
}
|
|
41
41
|
return fileName;
|
|
42
42
|
};
|
|
43
|
+
var _getFileName = function _getFileName(url) {
|
|
44
|
+
if (!url) return;
|
|
45
|
+
if (url.includes('*')) return url.split('*')[1];
|
|
46
|
+
return url.split('/').slice(-1).toString();
|
|
47
|
+
};
|
|
48
|
+
FileUtil.getFileName = function (url, maxLength) {
|
|
49
|
+
if (maxLength) {
|
|
50
|
+
return FileUtil.ellisipsFileName(_getFileName(url), maxLength);
|
|
51
|
+
}
|
|
52
|
+
return _getFileName(url);
|
|
53
|
+
};
|
|
43
54
|
})(FileUtil || (FileUtil = {}));
|
|
44
55
|
export default FileUtil;
|
package/esm/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { default as CheckUtil } from './check/CheckUtil';
|
|
|
6
6
|
export { default as CookieUtil } from './cookie/CookieUtil';
|
|
7
7
|
export { default as DateUtil } from './date/DateUtil';
|
|
8
8
|
export { default as EnvUtil } from './env/EnvUtil';
|
|
9
|
+
export { default as FileUtil } from './file/FileUtil';
|
|
9
10
|
export { default as FunctionUtil } from './func/FunctionUtil';
|
|
10
11
|
export { default as NumberUtil } from './number/NumberUtil';
|
|
11
12
|
export { default as ObjectUtil } from './object/ObjectUtil';
|
package/esm/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { default as CheckUtil } from './check/CheckUtil';
|
|
|
6
6
|
export { default as CookieUtil } from './cookie/CookieUtil';
|
|
7
7
|
export { default as DateUtil } from './date/DateUtil';
|
|
8
8
|
export { default as EnvUtil } from './env/EnvUtil';
|
|
9
|
+
export { default as FileUtil } from './file/FileUtil';
|
|
9
10
|
export { default as FunctionUtil } from './func/FunctionUtil';
|
|
10
11
|
export { default as NumberUtil } from './number/NumberUtil';
|
|
11
12
|
export { default as ObjectUtil } from './object/ObjectUtil';
|
package/lib/date/DateUtil.d.ts
CHANGED
|
@@ -74,6 +74,13 @@ declare namespace DateUtil {
|
|
|
74
74
|
* formatDateToFriendly2() => 2017年11月11日
|
|
75
75
|
*/
|
|
76
76
|
function formatDateToFriendly3(date?: Date | number | string): string;
|
|
77
|
+
/**
|
|
78
|
+
* 格式化时间为友好格式
|
|
79
|
+
* @param seconds
|
|
80
|
+
* @example
|
|
81
|
+
* formatBySeconds(10) => 10秒
|
|
82
|
+
*/
|
|
83
|
+
function formatBySeconds(seconds: number): string;
|
|
77
84
|
/**
|
|
78
85
|
* 判断是否为本周
|
|
79
86
|
* @param date
|
package/lib/date/DateUtil.js
CHANGED
|
@@ -243,6 +243,29 @@ var DateUtil;
|
|
|
243
243
|
return "".concat(years, "\u5E74\u524D");
|
|
244
244
|
}
|
|
245
245
|
DateUtil.formatDateToFriendly3 = formatDateToFriendly3;
|
|
246
|
+
/**
|
|
247
|
+
* 格式化时间为友好格式
|
|
248
|
+
* @param seconds
|
|
249
|
+
* @example
|
|
250
|
+
* formatBySeconds(10) => 10秒
|
|
251
|
+
*/
|
|
252
|
+
function formatBySeconds(seconds) {
|
|
253
|
+
if (!isFinite(seconds) || seconds < 0) return '计算中...';
|
|
254
|
+
var day = Math.floor(seconds / 3600 * 24);
|
|
255
|
+
var hours = Math.floor(seconds / 3600);
|
|
256
|
+
var minutes = Math.floor(seconds % 3600 / 60);
|
|
257
|
+
var secs = Math.floor(seconds % 60);
|
|
258
|
+
if (day > 0) {
|
|
259
|
+
return "".concat(day, "\u5929").concat(hours, "\u5C0F\u65F6").concat(minutes, "\u5206\u949F").concat(secs, "\u79D2");
|
|
260
|
+
} else if (hours > 0) {
|
|
261
|
+
return "".concat(hours, "\u5C0F\u65F6").concat(minutes, "\u5206\u949F").concat(secs, "\u79D2");
|
|
262
|
+
} else if (minutes > 0) {
|
|
263
|
+
return "".concat(minutes, "\u5206\u949F").concat(secs, "\u79D2");
|
|
264
|
+
} else {
|
|
265
|
+
return "".concat(secs, "\u79D2");
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
DateUtil.formatBySeconds = formatBySeconds;
|
|
246
269
|
/**
|
|
247
270
|
* 判断是否为本周
|
|
248
271
|
* @param date
|
package/lib/file/FileUtil.d.ts
CHANGED
|
@@ -11,5 +11,6 @@ declare namespace FileUtil {
|
|
|
11
11
|
*/
|
|
12
12
|
function getExt(url: string): string;
|
|
13
13
|
const ellisipsFileName: (fileName: string | undefined, maxLength?: number) => string;
|
|
14
|
+
const getFileName: (url: string, maxLength?: number) => string | undefined;
|
|
14
15
|
}
|
|
15
16
|
export default FileUtil;
|
package/lib/file/FileUtil.js
CHANGED
|
@@ -45,5 +45,16 @@ var FileUtil;
|
|
|
45
45
|
}
|
|
46
46
|
return fileName;
|
|
47
47
|
};
|
|
48
|
+
var _getFileName = function _getFileName(url) {
|
|
49
|
+
if (!url) return;
|
|
50
|
+
if (url.includes('*')) return url.split('*')[1];
|
|
51
|
+
return url.split('/').slice(-1).toString();
|
|
52
|
+
};
|
|
53
|
+
FileUtil.getFileName = function (url, maxLength) {
|
|
54
|
+
if (maxLength) {
|
|
55
|
+
return FileUtil.ellisipsFileName(_getFileName(url), maxLength);
|
|
56
|
+
}
|
|
57
|
+
return _getFileName(url);
|
|
58
|
+
};
|
|
48
59
|
})(FileUtil || (FileUtil = {}));
|
|
49
60
|
exports.default = FileUtil;
|
package/lib/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { default as CheckUtil } from './check/CheckUtil';
|
|
|
6
6
|
export { default as CookieUtil } from './cookie/CookieUtil';
|
|
7
7
|
export { default as DateUtil } from './date/DateUtil';
|
|
8
8
|
export { default as EnvUtil } from './env/EnvUtil';
|
|
9
|
+
export { default as FileUtil } from './file/FileUtil';
|
|
9
10
|
export { default as FunctionUtil } from './func/FunctionUtil';
|
|
10
11
|
export { default as NumberUtil } from './number/NumberUtil';
|
|
11
12
|
export { default as ObjectUtil } from './object/ObjectUtil';
|
package/lib/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var __importDefault = this && this.__importDefault || function (mod) {
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", {
|
|
9
9
|
value: true
|
|
10
10
|
});
|
|
11
|
-
exports.ExtractUtil = exports.UrlUtil = exports.TransferUtil = exports.MapTransferUtil = exports.SystemUtil = exports.StringUtil = exports.StorageUtil = exports.RequestUtil = exports.PasswordUtil = exports.ObjectUtil = exports.NumberUtil = exports.FunctionUtil = exports.EnvUtil = exports.DateUtil = exports.CookieUtil = exports.CheckUtil = exports.BrowserUtil = exports.BaseUtil = exports.TreeUtil = exports.ArrayUtil = void 0;
|
|
11
|
+
exports.ExtractUtil = exports.UrlUtil = exports.TransferUtil = exports.MapTransferUtil = exports.SystemUtil = exports.StringUtil = exports.StorageUtil = exports.RequestUtil = exports.PasswordUtil = exports.ObjectUtil = exports.NumberUtil = exports.FunctionUtil = exports.FileUtil = exports.EnvUtil = exports.DateUtil = exports.CookieUtil = exports.CheckUtil = exports.BrowserUtil = exports.BaseUtil = exports.TreeUtil = exports.ArrayUtil = void 0;
|
|
12
12
|
var ArrayUtil_1 = require("./array/ArrayUtil");
|
|
13
13
|
Object.defineProperty(exports, "ArrayUtil", {
|
|
14
14
|
enumerable: true,
|
|
@@ -65,6 +65,13 @@ Object.defineProperty(exports, "EnvUtil", {
|
|
|
65
65
|
return __importDefault(EnvUtil_1).default;
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
|
+
var FileUtil_1 = require("./file/FileUtil");
|
|
69
|
+
Object.defineProperty(exports, "FileUtil", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function get() {
|
|
72
|
+
return __importDefault(FileUtil_1).default;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
68
75
|
var FunctionUtil_1 = require("./func/FunctionUtil");
|
|
69
76
|
Object.defineProperty(exports, "FunctionUtil", {
|
|
70
77
|
enumerable: true,
|