@daysnap/utils 0.0.35 → 0.0.37
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/docs/modules.md +273 -56
- package/es/filterCRLF.d.ts +4 -0
- package/es/filterCRLF.js +6 -0
- package/es/getBlobByUrl.js +1 -0
- package/es/getRandomColor.d.ts +4 -0
- package/es/getRandomColor.js +6 -0
- package/es/index.d.ts +9 -0
- package/es/index.js +10 -1
- package/es/isArray.d.ts +6 -0
- package/es/isArray.js +8 -0
- package/es/isWeixin.d.ts +4 -0
- package/es/isWeixin.js +6 -0
- package/es/loadResource.d.ts +7 -0
- package/es/loadResource.js +31 -0
- package/es/padding.d.ts +7 -0
- package/es/padding.js +11 -0
- package/es/parseObject.d.ts +4 -0
- package/es/parseObject.js +12 -0
- package/es/stringTrim.d.ts +4 -0
- package/es/stringTrim.js +21 -0
- package/es/typeOf.d.ts +6 -0
- package/es/typeOf.js +8 -0
- package/lib/filterCRLF.d.ts +4 -0
- package/lib/filterCRLF.js +12 -0
- package/lib/getBlobByUrl.js +1 -0
- package/lib/getRandomColor.d.ts +4 -0
- package/lib/getRandomColor.js +12 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +99 -0
- package/lib/isArray.d.ts +6 -0
- package/lib/isArray.js +14 -0
- package/lib/isWeixin.d.ts +4 -0
- package/lib/isWeixin.js +12 -0
- package/lib/loadResource.d.ts +7 -0
- package/lib/loadResource.js +37 -0
- package/lib/padding.d.ts +7 -0
- package/lib/padding.js +17 -0
- package/lib/parseObject.d.ts +4 -0
- package/lib/parseObject.js +18 -0
- package/lib/stringTrim.d.ts +4 -0
- package/lib/stringTrim.js +27 -0
- package/lib/typeOf.d.ts +6 -0
- package/lib/typeOf.js +14 -0
- package/package.json +1 -1
package/es/filterCRLF.js
ADDED
package/es/getBlobByUrl.js
CHANGED
package/es/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './createHexColorByHash';
|
|
|
7
7
|
export * from './downloadFile';
|
|
8
8
|
export * from './each';
|
|
9
9
|
export * from './filterBankCardNo';
|
|
10
|
+
export * from './filterCRLF';
|
|
10
11
|
export * from './filterEmoji';
|
|
11
12
|
export * from './filterIdCard';
|
|
12
13
|
export * from './filterName';
|
|
@@ -16,9 +17,11 @@ export * from './formatDate';
|
|
|
16
17
|
export * from './getBlobByUrl';
|
|
17
18
|
export * from './getDayMillisecond';
|
|
18
19
|
export * from './getImageInfo';
|
|
20
|
+
export * from './getRandomColor';
|
|
19
21
|
export * from './getVideoInfo';
|
|
20
22
|
export * from './inBrowser';
|
|
21
23
|
export * from './isAndroid';
|
|
24
|
+
export * from './isArray';
|
|
22
25
|
export * from './isBoolean';
|
|
23
26
|
export * from './isEmail';
|
|
24
27
|
export * from './isEmpty';
|
|
@@ -39,10 +42,14 @@ export * from './isPromise';
|
|
|
39
42
|
export * from './isRegExp';
|
|
40
43
|
export * from './isString';
|
|
41
44
|
export * from './isUndefined';
|
|
45
|
+
export * from './isWeixin';
|
|
42
46
|
export * from './isWindow';
|
|
47
|
+
export * from './loadResource';
|
|
43
48
|
export * from './omit';
|
|
49
|
+
export * from './padding';
|
|
44
50
|
export * from './parseDate';
|
|
45
51
|
export * from './parseError';
|
|
52
|
+
export * from './parseObject';
|
|
46
53
|
export * from './parsePath';
|
|
47
54
|
export * from './parseQuery';
|
|
48
55
|
export * from './pick';
|
|
@@ -51,4 +58,6 @@ export * from './reserve';
|
|
|
51
58
|
export * from './round';
|
|
52
59
|
export * from './sleep';
|
|
53
60
|
export * from './storage';
|
|
61
|
+
export * from './stringTrim';
|
|
54
62
|
export * from './stringifyQuery';
|
|
63
|
+
export * from './typeOf';
|
package/es/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export * from './createHexColorByHash';
|
|
|
8
8
|
export * from './downloadFile';
|
|
9
9
|
export * from './each';
|
|
10
10
|
export * from './filterBankCardNo';
|
|
11
|
+
export * from './filterCRLF';
|
|
11
12
|
export * from './filterEmoji';
|
|
12
13
|
export * from './filterIdCard';
|
|
13
14
|
export * from './filterName';
|
|
@@ -17,9 +18,11 @@ export * from './formatDate';
|
|
|
17
18
|
export * from './getBlobByUrl';
|
|
18
19
|
export * from './getDayMillisecond';
|
|
19
20
|
export * from './getImageInfo';
|
|
21
|
+
export * from './getRandomColor';
|
|
20
22
|
export * from './getVideoInfo';
|
|
21
23
|
export * from './inBrowser';
|
|
22
24
|
export * from './isAndroid';
|
|
25
|
+
export * from './isArray';
|
|
23
26
|
export * from './isBoolean';
|
|
24
27
|
export * from './isEmail';
|
|
25
28
|
export * from './isEmpty';
|
|
@@ -40,10 +43,14 @@ export * from './isPromise';
|
|
|
40
43
|
export * from './isRegExp';
|
|
41
44
|
export * from './isString';
|
|
42
45
|
export * from './isUndefined';
|
|
46
|
+
export * from './isWeixin';
|
|
43
47
|
export * from './isWindow';
|
|
48
|
+
export * from './loadResource';
|
|
44
49
|
export * from './omit';
|
|
50
|
+
export * from './padding';
|
|
45
51
|
export * from './parseDate';
|
|
46
52
|
export * from './parseError';
|
|
53
|
+
export * from './parseObject';
|
|
47
54
|
export * from './parsePath';
|
|
48
55
|
export * from './parseQuery';
|
|
49
56
|
export * from './pick';
|
|
@@ -52,4 +59,6 @@ export * from './reserve';
|
|
|
52
59
|
export * from './round';
|
|
53
60
|
export * from './sleep';
|
|
54
61
|
export * from './storage';
|
|
55
|
-
export * from './
|
|
62
|
+
export * from './stringTrim';
|
|
63
|
+
export * from './stringifyQuery';
|
|
64
|
+
export * from './typeOf';
|
package/es/isArray.d.ts
ADDED
package/es/isArray.js
ADDED
package/es/isWeixin.d.ts
ADDED
package/es/isWeixin.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { isFunction } from './isFunction';
|
|
2
|
+
/**
|
|
3
|
+
* 加载外部js、css、写入style样式
|
|
4
|
+
* @param res 资源url或内容
|
|
5
|
+
* @param type 类型
|
|
6
|
+
* @param callback 回调函数
|
|
7
|
+
*/
|
|
8
|
+
export function loadResource(res, type, callback) {
|
|
9
|
+
var ref;
|
|
10
|
+
if (type === 'js') {
|
|
11
|
+
// 外部js
|
|
12
|
+
ref = document.createElement('js');
|
|
13
|
+
ref.setAttribute('type', 'text/javascript');
|
|
14
|
+
ref.setAttribute('src', res);
|
|
15
|
+
} else if (type === 'css') {
|
|
16
|
+
// 外部css
|
|
17
|
+
ref = document.createElement('link');
|
|
18
|
+
ref.setAttribute('rel', 'stylesheet');
|
|
19
|
+
ref.setAttribute('type', 'text/css');
|
|
20
|
+
ref.setAttribute('href', res);
|
|
21
|
+
} else if (type === 'style') {
|
|
22
|
+
ref = document.createElement('style');
|
|
23
|
+
ref.innerHTML = res;
|
|
24
|
+
}
|
|
25
|
+
if (ref) {
|
|
26
|
+
document.querySelector('head').appendChild(ref);
|
|
27
|
+
ref.onload = function () {
|
|
28
|
+
if (isFunction(callback)) callback();
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
package/es/padding.d.ts
ADDED
package/es/padding.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 增添空格
|
|
3
|
+
* @param message 文字信息
|
|
4
|
+
* @param before 前空格个数
|
|
5
|
+
* @param after 后空格个数
|
|
6
|
+
*/
|
|
7
|
+
export function padding(message) {
|
|
8
|
+
var before = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
9
|
+
var after = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
10
|
+
return "".concat(new Array(before).fill(' ').join('')).concat(message).concat(new Array(after).fill(' ').join(''));
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 返回对象
|
|
3
|
+
*/
|
|
4
|
+
export function parseObject(path, value) {
|
|
5
|
+
var result = {};
|
|
6
|
+
var segments = path ? path.split('.') : [];
|
|
7
|
+
segments.reduce(function (res, key, index, arr) {
|
|
8
|
+
res[key] = index === arr.length - 1 ? value : {};
|
|
9
|
+
return res[key];
|
|
10
|
+
}, result);
|
|
11
|
+
return result;
|
|
12
|
+
}
|
package/es/stringTrim.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*去除字符串空格
|
|
3
|
+
*/
|
|
4
|
+
export function stringTrim(str, type) {
|
|
5
|
+
var _type;
|
|
6
|
+
// 1-所有空格,2-前后空格,3-前空格,4-后空格
|
|
7
|
+
// eslint-disable-next-line no-param-reassign
|
|
8
|
+
type = (_type = type) !== null && _type !== void 0 ? _type : 1;
|
|
9
|
+
switch (type) {
|
|
10
|
+
case 1:
|
|
11
|
+
return str.replace(/\s+/g, '');
|
|
12
|
+
case 2:
|
|
13
|
+
return str.replace(/(^\s*)|(\s*$)/g, '');
|
|
14
|
+
case 3:
|
|
15
|
+
return str.replace(/(^\s*)/g, '');
|
|
16
|
+
case 4:
|
|
17
|
+
return str.replace(/(\s*$)/g, '');
|
|
18
|
+
default:
|
|
19
|
+
return str;
|
|
20
|
+
}
|
|
21
|
+
}
|
package/es/typeOf.d.ts
ADDED
package/es/typeOf.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 判断类型
|
|
3
|
+
* @param val 待判断数据
|
|
4
|
+
* @returns 'undefined'|'null'|'boolean'|'string'|'number'|'object'|'array'|'function'|'symbol'|'map'|'weakmap'|'bigint'|'regexp'|'date'
|
|
5
|
+
*/
|
|
6
|
+
export function typeOf(val) {
|
|
7
|
+
return Object.prototype.toString.call(val).slice(8, -1).toLowerCase();
|
|
8
|
+
}
|
package/lib/getBlobByUrl.js
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './createHexColorByHash';
|
|
|
7
7
|
export * from './downloadFile';
|
|
8
8
|
export * from './each';
|
|
9
9
|
export * from './filterBankCardNo';
|
|
10
|
+
export * from './filterCRLF';
|
|
10
11
|
export * from './filterEmoji';
|
|
11
12
|
export * from './filterIdCard';
|
|
12
13
|
export * from './filterName';
|
|
@@ -16,9 +17,11 @@ export * from './formatDate';
|
|
|
16
17
|
export * from './getBlobByUrl';
|
|
17
18
|
export * from './getDayMillisecond';
|
|
18
19
|
export * from './getImageInfo';
|
|
20
|
+
export * from './getRandomColor';
|
|
19
21
|
export * from './getVideoInfo';
|
|
20
22
|
export * from './inBrowser';
|
|
21
23
|
export * from './isAndroid';
|
|
24
|
+
export * from './isArray';
|
|
22
25
|
export * from './isBoolean';
|
|
23
26
|
export * from './isEmail';
|
|
24
27
|
export * from './isEmpty';
|
|
@@ -39,10 +42,14 @@ export * from './isPromise';
|
|
|
39
42
|
export * from './isRegExp';
|
|
40
43
|
export * from './isString';
|
|
41
44
|
export * from './isUndefined';
|
|
45
|
+
export * from './isWeixin';
|
|
42
46
|
export * from './isWindow';
|
|
47
|
+
export * from './loadResource';
|
|
43
48
|
export * from './omit';
|
|
49
|
+
export * from './padding';
|
|
44
50
|
export * from './parseDate';
|
|
45
51
|
export * from './parseError';
|
|
52
|
+
export * from './parseObject';
|
|
46
53
|
export * from './parsePath';
|
|
47
54
|
export * from './parseQuery';
|
|
48
55
|
export * from './pick';
|
|
@@ -51,4 +58,6 @@ export * from './reserve';
|
|
|
51
58
|
export * from './round';
|
|
52
59
|
export * from './sleep';
|
|
53
60
|
export * from './storage';
|
|
61
|
+
export * from './stringTrim';
|
|
54
62
|
export * from './stringifyQuery';
|
|
63
|
+
export * from './typeOf';
|
package/lib/index.js
CHANGED
|
@@ -102,6 +102,17 @@ Object.keys(_filterBankCardNo).forEach(function (key) {
|
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
|
+
var _filterCRLF = require("./filterCRLF");
|
|
106
|
+
Object.keys(_filterCRLF).forEach(function (key) {
|
|
107
|
+
if (key === "default" || key === "__esModule") return;
|
|
108
|
+
if (key in exports && exports[key] === _filterCRLF[key]) return;
|
|
109
|
+
Object.defineProperty(exports, key, {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function get() {
|
|
112
|
+
return _filterCRLF[key];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
105
116
|
var _filterEmoji = require("./filterEmoji");
|
|
106
117
|
Object.keys(_filterEmoji).forEach(function (key) {
|
|
107
118
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -201,6 +212,17 @@ Object.keys(_getImageInfo).forEach(function (key) {
|
|
|
201
212
|
}
|
|
202
213
|
});
|
|
203
214
|
});
|
|
215
|
+
var _getRandomColor = require("./getRandomColor");
|
|
216
|
+
Object.keys(_getRandomColor).forEach(function (key) {
|
|
217
|
+
if (key === "default" || key === "__esModule") return;
|
|
218
|
+
if (key in exports && exports[key] === _getRandomColor[key]) return;
|
|
219
|
+
Object.defineProperty(exports, key, {
|
|
220
|
+
enumerable: true,
|
|
221
|
+
get: function get() {
|
|
222
|
+
return _getRandomColor[key];
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
});
|
|
204
226
|
var _getVideoInfo = require("./getVideoInfo");
|
|
205
227
|
Object.keys(_getVideoInfo).forEach(function (key) {
|
|
206
228
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -234,6 +256,17 @@ Object.keys(_isAndroid).forEach(function (key) {
|
|
|
234
256
|
}
|
|
235
257
|
});
|
|
236
258
|
});
|
|
259
|
+
var _isArray = require("./isArray");
|
|
260
|
+
Object.keys(_isArray).forEach(function (key) {
|
|
261
|
+
if (key === "default" || key === "__esModule") return;
|
|
262
|
+
if (key in exports && exports[key] === _isArray[key]) return;
|
|
263
|
+
Object.defineProperty(exports, key, {
|
|
264
|
+
enumerable: true,
|
|
265
|
+
get: function get() {
|
|
266
|
+
return _isArray[key];
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
});
|
|
237
270
|
var _isBoolean = require("./isBoolean");
|
|
238
271
|
Object.keys(_isBoolean).forEach(function (key) {
|
|
239
272
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -454,6 +487,17 @@ Object.keys(_isUndefined).forEach(function (key) {
|
|
|
454
487
|
}
|
|
455
488
|
});
|
|
456
489
|
});
|
|
490
|
+
var _isWeixin = require("./isWeixin");
|
|
491
|
+
Object.keys(_isWeixin).forEach(function (key) {
|
|
492
|
+
if (key === "default" || key === "__esModule") return;
|
|
493
|
+
if (key in exports && exports[key] === _isWeixin[key]) return;
|
|
494
|
+
Object.defineProperty(exports, key, {
|
|
495
|
+
enumerable: true,
|
|
496
|
+
get: function get() {
|
|
497
|
+
return _isWeixin[key];
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
});
|
|
457
501
|
var _isWindow = require("./isWindow");
|
|
458
502
|
Object.keys(_isWindow).forEach(function (key) {
|
|
459
503
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -465,6 +509,17 @@ Object.keys(_isWindow).forEach(function (key) {
|
|
|
465
509
|
}
|
|
466
510
|
});
|
|
467
511
|
});
|
|
512
|
+
var _loadResource = require("./loadResource");
|
|
513
|
+
Object.keys(_loadResource).forEach(function (key) {
|
|
514
|
+
if (key === "default" || key === "__esModule") return;
|
|
515
|
+
if (key in exports && exports[key] === _loadResource[key]) return;
|
|
516
|
+
Object.defineProperty(exports, key, {
|
|
517
|
+
enumerable: true,
|
|
518
|
+
get: function get() {
|
|
519
|
+
return _loadResource[key];
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
});
|
|
468
523
|
var _omit = require("./omit");
|
|
469
524
|
Object.keys(_omit).forEach(function (key) {
|
|
470
525
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -476,6 +531,17 @@ Object.keys(_omit).forEach(function (key) {
|
|
|
476
531
|
}
|
|
477
532
|
});
|
|
478
533
|
});
|
|
534
|
+
var _padding = require("./padding");
|
|
535
|
+
Object.keys(_padding).forEach(function (key) {
|
|
536
|
+
if (key === "default" || key === "__esModule") return;
|
|
537
|
+
if (key in exports && exports[key] === _padding[key]) return;
|
|
538
|
+
Object.defineProperty(exports, key, {
|
|
539
|
+
enumerable: true,
|
|
540
|
+
get: function get() {
|
|
541
|
+
return _padding[key];
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
});
|
|
479
545
|
var _parseDate = require("./parseDate");
|
|
480
546
|
Object.keys(_parseDate).forEach(function (key) {
|
|
481
547
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -498,6 +564,17 @@ Object.keys(_parseError).forEach(function (key) {
|
|
|
498
564
|
}
|
|
499
565
|
});
|
|
500
566
|
});
|
|
567
|
+
var _parseObject = require("./parseObject");
|
|
568
|
+
Object.keys(_parseObject).forEach(function (key) {
|
|
569
|
+
if (key === "default" || key === "__esModule") return;
|
|
570
|
+
if (key in exports && exports[key] === _parseObject[key]) return;
|
|
571
|
+
Object.defineProperty(exports, key, {
|
|
572
|
+
enumerable: true,
|
|
573
|
+
get: function get() {
|
|
574
|
+
return _parseObject[key];
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
});
|
|
501
578
|
var _parsePath = require("./parsePath");
|
|
502
579
|
Object.keys(_parsePath).forEach(function (key) {
|
|
503
580
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -586,6 +663,17 @@ Object.keys(_storage).forEach(function (key) {
|
|
|
586
663
|
}
|
|
587
664
|
});
|
|
588
665
|
});
|
|
666
|
+
var _stringTrim = require("./stringTrim");
|
|
667
|
+
Object.keys(_stringTrim).forEach(function (key) {
|
|
668
|
+
if (key === "default" || key === "__esModule") return;
|
|
669
|
+
if (key in exports && exports[key] === _stringTrim[key]) return;
|
|
670
|
+
Object.defineProperty(exports, key, {
|
|
671
|
+
enumerable: true,
|
|
672
|
+
get: function get() {
|
|
673
|
+
return _stringTrim[key];
|
|
674
|
+
}
|
|
675
|
+
});
|
|
676
|
+
});
|
|
589
677
|
var _stringifyQuery = require("./stringifyQuery");
|
|
590
678
|
Object.keys(_stringifyQuery).forEach(function (key) {
|
|
591
679
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -596,4 +684,15 @@ Object.keys(_stringifyQuery).forEach(function (key) {
|
|
|
596
684
|
return _stringifyQuery[key];
|
|
597
685
|
}
|
|
598
686
|
});
|
|
687
|
+
});
|
|
688
|
+
var _typeOf = require("./typeOf");
|
|
689
|
+
Object.keys(_typeOf).forEach(function (key) {
|
|
690
|
+
if (key === "default" || key === "__esModule") return;
|
|
691
|
+
if (key in exports && exports[key] === _typeOf[key]) return;
|
|
692
|
+
Object.defineProperty(exports, key, {
|
|
693
|
+
enumerable: true,
|
|
694
|
+
get: function get() {
|
|
695
|
+
return _typeOf[key];
|
|
696
|
+
}
|
|
697
|
+
});
|
|
599
698
|
});
|
package/lib/isArray.d.ts
ADDED
package/lib/isArray.js
ADDED
package/lib/isWeixin.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.loadResource = loadResource;
|
|
7
|
+
var _isFunction = require("./isFunction");
|
|
8
|
+
/**
|
|
9
|
+
* 加载外部js、css、写入style样式
|
|
10
|
+
* @param res 资源url或内容
|
|
11
|
+
* @param type 类型
|
|
12
|
+
* @param callback 回调函数
|
|
13
|
+
*/
|
|
14
|
+
function loadResource(res, type, callback) {
|
|
15
|
+
var ref;
|
|
16
|
+
if (type === 'js') {
|
|
17
|
+
// 外部js
|
|
18
|
+
ref = document.createElement('js');
|
|
19
|
+
ref.setAttribute('type', 'text/javascript');
|
|
20
|
+
ref.setAttribute('src', res);
|
|
21
|
+
} else if (type === 'css') {
|
|
22
|
+
// 外部css
|
|
23
|
+
ref = document.createElement('link');
|
|
24
|
+
ref.setAttribute('rel', 'stylesheet');
|
|
25
|
+
ref.setAttribute('type', 'text/css');
|
|
26
|
+
ref.setAttribute('href', res);
|
|
27
|
+
} else if (type === 'style') {
|
|
28
|
+
ref = document.createElement('style');
|
|
29
|
+
ref.innerHTML = res;
|
|
30
|
+
}
|
|
31
|
+
if (ref) {
|
|
32
|
+
document.querySelector('head').appendChild(ref);
|
|
33
|
+
ref.onload = function () {
|
|
34
|
+
if ((0, _isFunction.isFunction)(callback)) callback();
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
package/lib/padding.d.ts
ADDED
package/lib/padding.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.padding = padding;
|
|
7
|
+
/**
|
|
8
|
+
* 增添空格
|
|
9
|
+
* @param message 文字信息
|
|
10
|
+
* @param before 前空格个数
|
|
11
|
+
* @param after 后空格个数
|
|
12
|
+
*/
|
|
13
|
+
function padding(message) {
|
|
14
|
+
var before = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
15
|
+
var after = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
16
|
+
return "".concat(new Array(before).fill(' ').join('')).concat(message).concat(new Array(after).fill(' ').join(''));
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.parseObject = parseObject;
|
|
7
|
+
/**
|
|
8
|
+
* 返回对象
|
|
9
|
+
*/
|
|
10
|
+
function parseObject(path, value) {
|
|
11
|
+
var result = {};
|
|
12
|
+
var segments = path ? path.split('.') : [];
|
|
13
|
+
segments.reduce(function (res, key, index, arr) {
|
|
14
|
+
res[key] = index === arr.length - 1 ? value : {};
|
|
15
|
+
return res[key];
|
|
16
|
+
}, result);
|
|
17
|
+
return result;
|
|
18
|
+
}
|