mm_expand 1.5.1 → 1.5.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/base.js +1 -1
- package/index.js +18 -8
- package/lang.js +1 -1
- package/package.json +34 -34
- package/test.js +11 -1
package/base.js
CHANGED
package/index.js
CHANGED
|
@@ -644,6 +644,15 @@ if (typeof($) === "undefined") {
|
|
|
644
644
|
Number.prototype.toTime = function() {
|
|
645
645
|
return new Date(this * 1000);
|
|
646
646
|
};
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* @description 随机数
|
|
650
|
+
* @@param {Number} min 最小值
|
|
651
|
+
* @return {Number} 返回一个数值
|
|
652
|
+
*/
|
|
653
|
+
Number.prototype.rand = function(min = 1) {
|
|
654
|
+
return Math.floor(Math.random() * (this - min + 1) + min);
|
|
655
|
+
};
|
|
647
656
|
})();
|
|
648
657
|
|
|
649
658
|
/* == 时间原型函数 == */
|
|
@@ -1092,7 +1101,8 @@ if (typeof($) === "undefined") {
|
|
|
1092
1101
|
bl = /^((https|http|ftp|rtsp|mms)?:\/\/)[^\s]+/gi.test(value)
|
|
1093
1102
|
break;
|
|
1094
1103
|
case "date":
|
|
1095
|
-
bl = /^\d{4}(\-|\/|\.)(0[1-9]|1[012]|[1-9])(\-|\/|\.)([12][0-9]|0[1-9]|3[01]|[1-9])$/.test(
|
|
1104
|
+
bl = /^\d{4}(\-|\/|\.)(0[1-9]|1[012]|[1-9])(\-|\/|\.)([12][0-9]|0[1-9]|3[01]|[1-9])$/.test(
|
|
1105
|
+
value)
|
|
1096
1106
|
break;
|
|
1097
1107
|
case "time":
|
|
1098
1108
|
bl = /^([01][0-9]|2[0-3]):([0-4][0-9]|5[0-9])(:([0-4][0-9]|5[0-9]))?$/.test(value)
|
|
@@ -2234,7 +2244,7 @@ if (typeof($) === "undefined") {
|
|
|
2234
2244
|
getFile(list, dir, keyword);
|
|
2235
2245
|
return list;
|
|
2236
2246
|
};
|
|
2237
|
-
|
|
2247
|
+
|
|
2238
2248
|
/**
|
|
2239
2249
|
* @description 加载文件
|
|
2240
2250
|
* @param {String} file 编码方式
|
|
@@ -2269,17 +2279,17 @@ if (typeof($) === "undefined") {
|
|
|
2269
2279
|
}
|
|
2270
2280
|
$.file = new File();
|
|
2271
2281
|
$.dir = new Dir();
|
|
2272
|
-
|
|
2273
|
-
|
|
2282
|
+
|
|
2283
|
+
|
|
2274
2284
|
/**
|
|
2275
2285
|
* @description 获取当前目录下所有文件
|
|
2276
2286
|
* @param {String} keyword 搜索关键词
|
|
2277
2287
|
* @return {Array} 文件路径数组
|
|
2278
2288
|
*/
|
|
2279
|
-
String.prototype.getFile = function(keyword){
|
|
2280
|
-
|
|
2289
|
+
String.prototype.getFile = function(keyword) {
|
|
2290
|
+
return $.file.get(this + '', keyword);
|
|
2281
2291
|
};
|
|
2282
|
-
|
|
2292
|
+
|
|
2283
2293
|
/**
|
|
2284
2294
|
* @description 搜索当前目录下所有目录
|
|
2285
2295
|
* @param {String} keyword 搜索关键词
|
|
@@ -2288,7 +2298,7 @@ if (typeof($) === "undefined") {
|
|
|
2288
2298
|
String.prototype.getDir = function(keyword) {
|
|
2289
2299
|
return $.dir.get(this + '', keyword);
|
|
2290
2300
|
};
|
|
2291
|
-
|
|
2301
|
+
|
|
2292
2302
|
})();
|
|
2293
2303
|
|
|
2294
2304
|
/**
|
package/lang.js
CHANGED
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "mm_expand",
|
|
3
|
-
"version": "1.5.
|
|
4
|
-
"description": "这是超级美眉原型函数拓展模块,更有利于对string、array、object的操作,避免出错,简化业务逻辑。",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "node test.js"
|
|
8
|
-
},
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/qiuwenwu/mm_expand.git"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"string",
|
|
15
|
-
"array",
|
|
16
|
-
"object",
|
|
17
|
-
"date",
|
|
18
|
-
"get",
|
|
19
|
-
"set",
|
|
20
|
-
"prototype",
|
|
21
|
-
"expand",
|
|
22
|
-
"$"
|
|
23
|
-
],
|
|
24
|
-
"author": "邱文武",
|
|
25
|
-
"license": "ISC",
|
|
26
|
-
"bugs": {
|
|
27
|
-
"url": "https://github.com/qiuwenwu/mm_expand/issues"
|
|
28
|
-
},
|
|
29
|
-
"homepage": "https://github.com/qiuwenwu/mm_expand#readme",
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"fast-xml-parser": "^3.15.1",
|
|
32
|
-
"json5": "^2.1.1",
|
|
33
|
-
"pinyinlite": "^1.2.1"
|
|
34
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "mm_expand",
|
|
3
|
+
"version": "1.5.2",
|
|
4
|
+
"description": "这是超级美眉原型函数拓展模块,更有利于对string、array、object的操作,避免出错,简化业务逻辑。",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "node test.js"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/qiuwenwu/mm_expand.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"string",
|
|
15
|
+
"array",
|
|
16
|
+
"object",
|
|
17
|
+
"date",
|
|
18
|
+
"get",
|
|
19
|
+
"set",
|
|
20
|
+
"prototype",
|
|
21
|
+
"expand",
|
|
22
|
+
"$"
|
|
23
|
+
],
|
|
24
|
+
"author": "邱文武",
|
|
25
|
+
"license": "ISC",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/qiuwenwu/mm_expand/issues"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/qiuwenwu/mm_expand#readme",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"fast-xml-parser": "^3.15.1",
|
|
32
|
+
"json5": "^2.1.1",
|
|
33
|
+
"pinyinlite": "^1.2.1"
|
|
34
|
+
}
|
|
35
35
|
}
|
package/test.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
require('./index.js');
|
|
2
2
|
|
|
3
|
+
|
|
4
|
+
var num = 5;
|
|
5
|
+
console.log(num.rand());
|
|
6
|
+
console.log(num.rand());
|
|
7
|
+
console.log(num.rand());
|
|
8
|
+
console.log(num.rand());
|
|
9
|
+
console.log(num.rand());
|
|
10
|
+
console.log(num.rand());
|
|
11
|
+
console.log(num.rand());
|
|
12
|
+
|
|
3
13
|
// /**
|
|
4
14
|
// * 测试重载模块
|
|
5
15
|
// */
|
|
@@ -348,7 +358,7 @@ require('./index.js');
|
|
|
348
358
|
// sex: 0
|
|
349
359
|
// }
|
|
350
360
|
// ];
|
|
351
|
-
|
|
361
|
+
|
|
352
362
|
// var list2 = [
|
|
353
363
|
// {
|
|
354
364
|
// id: 2,
|