-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bundle.min.js
76 lines (67 loc) · 1.9 KB
/
bundle.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
var nx = (function (exports,_Array$isArray,type) {
'use strict';
_Array$isArray = _Array$isArray && _Array$isArray.hasOwnProperty('default') ? _Array$isArray['default'] : _Array$isArray;
function truncate(str, len) {
var omission = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '...';
str = String(str);
omission = String(omission);
len = Math.round(len);
if (isNaN(len)) {
return '';
}
if (str.length > len) {
str = str.slice(0, len - omission.length) + omission;
}
return str;
}
function range(start, stop) {
var step = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
start = isNaN(+start) ? 0 : +start;
stop = isNaN(+stop) ? 0 : +stop;
step = isNaN(+step) ? 1 : +step;
// 保证step正确
if (start > stop && step > 0) {
step = -step;
}
var arr = [];
for (var i = start; start > stop ? i > stop : i < stop; i += step) {
arr.push(i);
}
return arr;
}
// Object.create(null) 的对象,没有hasOwnProperty方法
function hasOwnProp(obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key);
}
function pick(obj, paths) {
if (type.type(obj) !== 'Object') {
return {};
}
if (!_Array$isArray(paths)) {
return {};
}
var res = {};
for (var i = 0; i < paths.length; i++) {
var key = paths[i];
console.log('key', key, obj[key]);
if (hasOwnProp(obj, key)) {
res[key] = obj[key];
}
}
return res;
}
function getParam(name, url) {
name = String(name);
url = String(url);
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(url);
if (!results) {
return '';
}
return results[1] || '';
}
exports.truncate = truncate;
exports.range = range;
exports.pick = pick;
exports.getParam = getParam;
return exports;
}({},_Array$isArray,type));