@antv/util
Advanced tools
Comparing version 1.0.6 to 1.0.7
1633
build/util.js
@@ -73,3 +73,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 31); | ||
/******/ return __webpack_require__(__webpack_require__.s = 22); | ||
/******/ }) | ||
@@ -93,3 +93,3 @@ /************************************************************************/ | ||
var isObject = __webpack_require__(17); | ||
var isObject = __webpack_require__(12); | ||
var isArray = __webpack_require__(0); | ||
@@ -155,19 +155,2 @@ | ||
/** | ||
* 是否为函数 | ||
* @param {*} fn 对象 | ||
* @return {Boolean} 是否函数 | ||
*/ | ||
var isType = __webpack_require__(3); | ||
var isFunction = function isFunction(value) { | ||
return isType(value, 'Function'); | ||
}; | ||
module.exports = isFunction; | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/** | ||
* 判断是否数字 | ||
@@ -184,15 +167,20 @@ * @return {Boolean} 是否数字 | ||
/***/ }), | ||
/* 6 */ | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/** | ||
* 是否为函数 | ||
* @param {*} fn 对象 | ||
* @return {Boolean} 是否函数 | ||
*/ | ||
var isType = __webpack_require__(3); | ||
var isString = function isString(str) { | ||
return isType(str, 'String'); | ||
var isFunction = function isFunction(value) { | ||
return isType(value, 'Function'); | ||
}; | ||
module.exports = isString; | ||
module.exports = isFunction; | ||
/***/ }), | ||
/* 7 */ | ||
/* 6 */ | ||
/***/ (function(module, exports) { | ||
@@ -212,6 +200,6 @@ | ||
/***/ }), | ||
/* 8 */ | ||
/* 7 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isObjectLike = __webpack_require__(12); | ||
var isObjectLike = __webpack_require__(8); | ||
var isType = __webpack_require__(3); | ||
@@ -242,20 +230,21 @@ | ||
/***/ }), | ||
/* 9 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/* 8 */ | ||
/***/ (function(module, exports) { | ||
var isArrayLike = __webpack_require__(2); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var indexOf = Array.prototype.indexOf; | ||
var contains = function contains(arr, value) { | ||
if (!isArrayLike(arr)) { | ||
return false; | ||
} | ||
return indexOf.call(arr, value) > -1; | ||
var isObjectLike = function isObjectLike(value) { | ||
/** | ||
* isObjectLike({}) => true | ||
* isObjectLike([1, 2, 3]) => true | ||
* isObjectLike(Function) => false | ||
* isObjectLike(null) => false | ||
*/ | ||
return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null; | ||
}; | ||
module.exports = contains; | ||
module.exports = isObjectLike; | ||
/***/ }), | ||
/* 10 */ | ||
/* 9 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -265,30 +254,2 @@ | ||
var splice = Array.prototype.splice; | ||
var pullAt = function pullAt(arr, indexes) { | ||
if (!isArrayLike(arr)) { | ||
return []; | ||
} | ||
var length = arr ? indexes.length : 0; | ||
var last = length - 1; | ||
while (length--) { | ||
var previous = void 0; | ||
var index = indexes[length]; | ||
if (length === last || index !== previous) { | ||
previous = index; | ||
splice.call(arr, index, 1); | ||
} | ||
} | ||
return arr; | ||
}; | ||
module.exports = pullAt; | ||
/***/ }), | ||
/* 11 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isArrayLike = __webpack_require__(2); | ||
function toArray(value) { | ||
@@ -301,23 +262,5 @@ return isArrayLike(value) ? Array.prototype.slice.call(value) : []; | ||
/***/ }), | ||
/* 12 */ | ||
/* 10 */ | ||
/***/ (function(module, exports) { | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var isObjectLike = function isObjectLike(value) { | ||
/** | ||
* isObjectLike({}) => true | ||
* isObjectLike([1, 2, 3]) => true | ||
* isObjectLike(Function) => false | ||
* isObjectLike(null) => false | ||
*/ | ||
return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null; | ||
}; | ||
module.exports = isObjectLike; | ||
/***/ }), | ||
/* 13 */ | ||
/***/ (function(module, exports) { | ||
function _mix(dist, obj) { | ||
@@ -341,65 +284,39 @@ for (var key in obj) { | ||
/***/ }), | ||
/* 14 */ | ||
/* 11 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isNil = __webpack_require__(7); | ||
var isArray = __webpack_require__(0); | ||
var isArrayLike = __webpack_require__(2); | ||
var firstValue = function firstValue(data, name) { | ||
var rst = null; | ||
for (var i = 0; i < data.length; i++) { | ||
var obj = data[i]; | ||
var value = obj[name]; | ||
if (!isNil(value)) { | ||
if (isArray(value)) { | ||
rst = value[0]; | ||
} else { | ||
rst = value; | ||
} | ||
break; | ||
} | ||
var indexOf = Array.prototype.indexOf; | ||
var contains = function contains(arr, value) { | ||
if (!isArrayLike(arr)) { | ||
return false; | ||
} | ||
return rst; | ||
return indexOf.call(arr, value) > -1; | ||
}; | ||
module.exports = firstValue; | ||
module.exports = contains; | ||
/***/ }), | ||
/* 15 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/* 12 */ | ||
/***/ (function(module, exports) { | ||
var filter = __webpack_require__(16); | ||
var isArray = __webpack_require__(0); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var getRange = function getRange(values) { | ||
// 存在 NaN 时,min,max 判定会出问题 | ||
values = filter(values, function (v) { | ||
return !isNaN(v); | ||
}); | ||
if (!values.length) { | ||
// 如果没有数值则直接返回0 | ||
return { | ||
min: 0, | ||
max: 0 | ||
}; | ||
} | ||
if (isArray(values[0])) { | ||
var tmp = []; | ||
for (var i = 0; i < values.length; i++) { | ||
tmp = tmp.concat(values[i]); | ||
} | ||
values = tmp; | ||
} | ||
var max = Math.max.apply(null, values); | ||
var min = Math.min.apply(null, values); | ||
return { | ||
min: min, | ||
max: max | ||
}; | ||
var isObject = function isObject(value) { | ||
/** | ||
* isObject({}) => true | ||
* isObject([1, 2, 3]) => true | ||
* isObject(Function) => true | ||
* isObject(null) => false | ||
*/ | ||
var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); | ||
return value !== null && type === 'object' || type === 'function'; | ||
}; | ||
module.exports = getRange; | ||
module.exports = isObject; | ||
/***/ }), | ||
/* 16 */ | ||
/* 13 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -426,36 +343,22 @@ | ||
/***/ }), | ||
/* 17 */ | ||
/***/ (function(module, exports) { | ||
/* 14 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var isArrayLike = __webpack_require__(2); | ||
var isObject = function isObject(value) { | ||
/** | ||
* isObject({}) => true | ||
* isObject([1, 2, 3]) => true | ||
* isObject(Function) => true | ||
* isObject(null) => false | ||
*/ | ||
var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); | ||
return value !== null && type === 'object' || type === 'function'; | ||
}; | ||
var splice = Array.prototype.splice; | ||
module.exports = isObject; | ||
var pullAt = function pullAt(arr, indexes) { | ||
if (!isArrayLike(arr)) { | ||
return []; | ||
} | ||
var length = arr ? indexes.length : 0; | ||
var last = length - 1; | ||
/***/ }), | ||
/* 18 */ | ||
/***/ (function(module, exports) { | ||
var arrPrototype = Array.prototype; | ||
var splice = arrPrototype.splice; | ||
var indexOf = arrPrototype.indexOf; | ||
var slice = arrPrototype.slice; | ||
var pull = function pull(arr) { | ||
var values = slice.call(arguments, 1); | ||
for (var i = 0; i < values.length; i++) { | ||
var value = values[i]; | ||
var fromIndex = -1; | ||
while ((fromIndex = indexOf.call(arr, value)) > -1) { | ||
splice.call(arr, fromIndex, 1); | ||
while (length--) { | ||
var previous = void 0; | ||
var index = indexes[length]; | ||
if (length === last || index !== previous) { | ||
previous = index; | ||
splice.call(arr, index, 1); | ||
} | ||
@@ -466,159 +369,97 @@ } | ||
module.exports = pull; | ||
module.exports = pullAt; | ||
/***/ }), | ||
/* 19 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/* 15 */ | ||
/***/ (function(module, exports) { | ||
var isArrayLike = __webpack_require__(2); | ||
var pullAt = __webpack_require__(10); | ||
module.exports = parseInt; | ||
var remove = function remove(arr, predicate) { | ||
/** | ||
* const arr = [1, 2, 3, 4] | ||
* const evens = remove(arr, n => n % 2 == 0) | ||
* console.log(arr) // => [1, 3] | ||
* console.log(evens) // => [2, 4] | ||
*/ | ||
var result = []; | ||
if (!isArrayLike(arr)) { | ||
return result; | ||
} | ||
var i = -1; | ||
var indexes = []; | ||
var length = arr.length; | ||
/***/ }), | ||
/* 16 */ | ||
/***/ (function(module, exports) { | ||
while (++i < length) { | ||
var value = arr[i]; | ||
if (predicate(value, i, arr)) { | ||
result.push(value); | ||
indexes.push(i); | ||
} | ||
} | ||
pullAt(arr, indexes); | ||
return result; | ||
var toString = {}.toString; | ||
var getType = function getType(value) { | ||
return toString.call(value).replace(/^\[object /, '').replace(/\]$/, ''); | ||
}; | ||
module.exports = remove; | ||
module.exports = getType; | ||
/***/ }), | ||
/* 20 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/* 17 */ | ||
/***/ (function(module, exports) { | ||
var contains = __webpack_require__(9); | ||
var uniq = function uniq(arr) { | ||
var resultArr = []; | ||
arr.forEach(function (item) { | ||
if (!contains(resultArr, item)) { | ||
resultArr.push(item); | ||
} | ||
}); | ||
return resultArr; | ||
var objectProto = Object.prototype; | ||
var isPrototype = function isPrototype(value) { | ||
var Ctor = value && value.constructor; | ||
var proto = typeof Ctor === 'function' && Ctor.prototype || objectProto; | ||
return value === proto; | ||
}; | ||
module.exports = uniq; | ||
module.exports = isPrototype; | ||
/***/ }), | ||
/* 21 */ | ||
/* 18 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var each = __webpack_require__(1); | ||
var isNil = __webpack_require__(7); | ||
var isArray = __webpack_require__(0); | ||
var isType = __webpack_require__(3); | ||
var values = function values(data, name) { | ||
var rst = []; | ||
var tmpMap = {}; | ||
for (var i = 0; i < data.length; i++) { | ||
var obj = data[i]; | ||
var value = obj[name]; | ||
if (!isNil(value)) { | ||
if (!isArray(value)) { | ||
value = [value]; | ||
} | ||
each(value, function (val) { | ||
if (!tmpMap[val]) { | ||
rst.push(val); | ||
tmpMap[val] = true; | ||
} | ||
}); | ||
} | ||
} | ||
return rst; | ||
var isString = function isString(str) { | ||
return isType(str, 'String'); | ||
}; | ||
module.exports = values; | ||
module.exports = isString; | ||
/***/ }), | ||
/* 22 */ | ||
/* 19 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isFunction = __webpack_require__(5); | ||
var isArray = __webpack_require__(0); | ||
var each = __webpack_require__(1); | ||
var groupBy = __webpack_require__(20); | ||
/** | ||
* Flattens `array` a single level deep. | ||
* | ||
* @param {Array} arr The array to flatten. | ||
* @return {Array} Returns the new flattened array. | ||
* @example | ||
* | ||
* _.flatten([1, [2, [3, [4]], 5]]); // => [1, 2, [3, [4]], 5] | ||
*/ | ||
var flatten = function flatten(arr) { | ||
if (!isArray(arr)) { | ||
return arr; | ||
var groupToMap = function groupToMap(data, condition) { | ||
if (!condition) { | ||
return { | ||
0: data | ||
}; | ||
} | ||
var result = []; | ||
each(arr, function (item) { | ||
if (isArray(item)) { | ||
each(item, function (subItem) { | ||
result.push(subItem); | ||
}); | ||
} else { | ||
result.push(item); | ||
} | ||
}); | ||
return result; | ||
if (!isFunction(condition)) { | ||
var paramsCondition = isArray(condition) ? condition : condition.replace(/\s+/g, '').split('*'); | ||
condition = function condition(row) { | ||
var unique = '_'; // 避免出现数字作为Key的情况,会进行按照数字的排序 | ||
for (var i = 0, l = paramsCondition.length; i < l; i++) { | ||
unique += row[paramsCondition[i]] && row[paramsCondition[i]].toString(); | ||
} | ||
return unique; | ||
}; | ||
} | ||
var groups = groupBy(data, condition); | ||
return groups; | ||
}; | ||
module.exports = flatten; | ||
module.exports = groupToMap; | ||
/***/ }), | ||
/* 23 */ | ||
/* 20 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var each = __webpack_require__(1); | ||
var toArray = __webpack_require__(11); | ||
var union = function union() { | ||
var result = new Set(); | ||
var values = []; | ||
each(arguments, function (arg) { | ||
values = toArray(arg); | ||
each(values, function (val) { | ||
result.add(val); | ||
}); | ||
}); | ||
return Array.from(result); | ||
}; | ||
module.exports = union; | ||
/***/ }), | ||
/* 24 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isArray = __webpack_require__(0); | ||
var isPlainObject = __webpack_require__(8); | ||
var each = __webpack_require__(1); | ||
var reduce = function reduce(arr, fn, init) { | ||
if (!isArray(arr) && !isPlainObject(arr)) { | ||
return arr; | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
var groupBy = function groupBy(data, condition) { | ||
if (!condition || !isArray(data)) { | ||
return data; | ||
} | ||
var result = init; | ||
each(arr, function (data, i) { | ||
result = fn(result, data, i); | ||
var result = {}; | ||
var key = null; | ||
each(data, function (item) { | ||
key = condition(item); | ||
if (hasOwnProperty.call(result, key)) { | ||
result[key].push(item); | ||
} else { | ||
result[key] = [item]; | ||
} | ||
}); | ||
@@ -628,36 +469,11 @@ return result; | ||
module.exports = reduce; | ||
module.exports = groupBy; | ||
/***/ }), | ||
/* 25 */ | ||
/***/ (function(module, exports) { | ||
var toString = {}.toString; | ||
var getType = function getType(value) { | ||
return toString.call(value).replace(/^\[object /, '').replace(/\]$/, ''); | ||
}; | ||
module.exports = getType; | ||
/***/ }), | ||
/* 26 */ | ||
/***/ (function(module, exports) { | ||
var objectProto = Object.prototype; | ||
var isPrototype = function isPrototype(value) { | ||
var Ctor = value && value.constructor; | ||
var proto = typeof Ctor === 'function' && Ctor.prototype || objectProto; | ||
return value === proto; | ||
}; | ||
module.exports = isPrototype; | ||
/***/ }), | ||
/* 27 */ | ||
/* 21 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isObjectLike = __webpack_require__(12); | ||
var isObjectLike = __webpack_require__(8); | ||
var isArrayLike = __webpack_require__(2); | ||
var isString = __webpack_require__(6); | ||
var isString = __webpack_require__(18); | ||
@@ -708,26 +524,121 @@ var isEqual = function isEqual(value, other) { | ||
/***/ }), | ||
/* 28 */ | ||
/***/ (function(module, exports) { | ||
/* 22 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
module.exports = parseInt; | ||
var arrayUtil = __webpack_require__(23); | ||
var eventUtil = __webpack_require__(34); | ||
var mathUtil = __webpack_require__(37); | ||
var stringUtil = __webpack_require__(52); | ||
var typeUtil = __webpack_require__(53); | ||
var each = __webpack_require__(1); | ||
var mix = __webpack_require__(10); | ||
var util = { | ||
// collections | ||
arrayUtil: arrayUtil, | ||
eventUtil: eventUtil, | ||
mathUtil: mathUtil, | ||
stringUtil: stringUtil, | ||
typeUtil: typeUtil, | ||
// others | ||
augment: __webpack_require__(58), | ||
clone: __webpack_require__(59), | ||
deepMix: __webpack_require__(60), | ||
each: each, | ||
extend: __webpack_require__(61), | ||
filter: __webpack_require__(13), | ||
group: __webpack_require__(62), | ||
groupBy: __webpack_require__(20), | ||
groupToMap: __webpack_require__(19), | ||
indexOf: __webpack_require__(63), | ||
isEmpty: __webpack_require__(64), | ||
isEqual: __webpack_require__(21), | ||
isEqualWith: __webpack_require__(65), | ||
map: __webpack_require__(66), | ||
mix: mix, | ||
pick: __webpack_require__(67), | ||
toArray: __webpack_require__(9), | ||
uniqueId: __webpack_require__(68) | ||
}; | ||
each([arrayUtil, eventUtil, mathUtil, stringUtil, typeUtil], function (collection) { | ||
mix(util, collection); | ||
}); | ||
module.exports = util; | ||
/***/ }), | ||
/* 29 */ | ||
/* 23 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var each = __webpack_require__(1); | ||
module.exports = { | ||
contains: __webpack_require__(11), | ||
firstValue: __webpack_require__(24), | ||
flatten: __webpack_require__(25), | ||
getRange: __webpack_require__(26), | ||
merge: __webpack_require__(27), | ||
pull: __webpack_require__(28), | ||
pullAt: __webpack_require__(14), | ||
reduce: __webpack_require__(29), | ||
remove: __webpack_require__(30), | ||
union: __webpack_require__(31), | ||
uniq: __webpack_require__(32), | ||
values: __webpack_require__(33) | ||
}; | ||
/***/ }), | ||
/* 24 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isNil = __webpack_require__(6); | ||
var isArray = __webpack_require__(0); | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
var groupBy = function groupBy(data, condition) { | ||
if (!condition || !isArray(data)) { | ||
return data; | ||
var firstValue = function firstValue(data, name) { | ||
var rst = null; | ||
for (var i = 0; i < data.length; i++) { | ||
var obj = data[i]; | ||
var value = obj[name]; | ||
if (!isNil(value)) { | ||
if (isArray(value)) { | ||
rst = value[0]; | ||
} else { | ||
rst = value; | ||
} | ||
break; | ||
} | ||
} | ||
var result = {}; | ||
var key = null; | ||
each(data, function (item) { | ||
key = condition(item); | ||
if (hasOwnProperty.call(result, key)) { | ||
result[key].push(item); | ||
return rst; | ||
}; | ||
module.exports = firstValue; | ||
/***/ }), | ||
/* 25 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isArray = __webpack_require__(0); | ||
var each = __webpack_require__(1); | ||
/** | ||
* Flattens `array` a single level deep. | ||
* | ||
* @param {Array} arr The array to flatten. | ||
* @return {Array} Returns the new flattened array. | ||
* @example | ||
* | ||
* _.flatten([1, [2, [3, [4]], 5]]); // => [1, 2, [3, [4]], 5] | ||
*/ | ||
var flatten = function flatten(arr) { | ||
if (!isArray(arr)) { | ||
return arr; | ||
} | ||
var result = []; | ||
each(arr, function (item) { | ||
if (isArray(item)) { | ||
each(item, function (subItem) { | ||
result.push(subItem); | ||
}); | ||
} else { | ||
result[key] = [item]; | ||
result.push(item); | ||
} | ||
@@ -738,459 +649,279 @@ }); | ||
module.exports = groupBy; | ||
module.exports = flatten; | ||
/***/ }), | ||
/* 30 */ | ||
/* 26 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isFunction = __webpack_require__(4); | ||
var filter = __webpack_require__(13); | ||
var isArray = __webpack_require__(0); | ||
var groupBy = __webpack_require__(29); | ||
var groupToMap = function groupToMap(data, condition) { | ||
if (!condition) { | ||
var getRange = function getRange(values) { | ||
// 存在 NaN 时,min,max 判定会出问题 | ||
values = filter(values, function (v) { | ||
return !isNaN(v); | ||
}); | ||
if (!values.length) { | ||
// 如果没有数值则直接返回0 | ||
return { | ||
0: data | ||
min: 0, | ||
max: 0 | ||
}; | ||
} | ||
if (!isFunction(condition)) { | ||
var paramsCondition = isArray(condition) ? condition : condition.replace(/\s+/g, '').split('*'); | ||
condition = function condition(row) { | ||
var unique = '_'; // 避免出现数字作为Key的情况,会进行按照数字的排序 | ||
for (var i = 0, l = paramsCondition.length; i < l; i++) { | ||
unique += row[paramsCondition[i]] && row[paramsCondition[i]].toString(); | ||
} | ||
return unique; | ||
}; | ||
if (isArray(values[0])) { | ||
var tmp = []; | ||
for (var i = 0; i < values.length; i++) { | ||
tmp = tmp.concat(values[i]); | ||
} | ||
values = tmp; | ||
} | ||
var groups = groupBy(data, condition); | ||
return groups; | ||
var max = Math.max.apply(null, values); | ||
var min = Math.min.apply(null, values); | ||
return { | ||
min: min, | ||
max: max | ||
}; | ||
}; | ||
module.exports = groupToMap; | ||
module.exports = getRange; | ||
/***/ }), | ||
/* 31 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/* 27 */ | ||
/***/ (function(module, exports) { | ||
module.exports = { | ||
arrayUtil: __webpack_require__(32), | ||
stringUtil: __webpack_require__(33), | ||
clone: __webpack_require__(34), | ||
each: __webpack_require__(1), | ||
filter: __webpack_require__(16), | ||
indexOf: __webpack_require__(35), | ||
isEmpty: __webpack_require__(36), | ||
isEqual: __webpack_require__(27), | ||
isEqualWith: __webpack_require__(37), | ||
map: __webpack_require__(38), | ||
toArray: __webpack_require__(11), | ||
uniqueId: __webpack_require__(39), | ||
extend: __webpack_require__(40), | ||
augment: __webpack_require__(41), | ||
deepMix: __webpack_require__(42), | ||
mix: __webpack_require__(13), | ||
clamp: __webpack_require__(43), | ||
fixedBase: __webpack_require__(44), | ||
isDecimal: __webpack_require__(45), | ||
isEven: __webpack_require__(46), | ||
isInteger: __webpack_require__(47), | ||
isNegative: __webpack_require__(48), | ||
isNumberEqual: __webpack_require__(49), | ||
isOdd: __webpack_require__(50), | ||
isPositive: __webpack_require__(51), | ||
mod: __webpack_require__(52), | ||
toDegree: __webpack_require__(53), | ||
toInt: __webpack_require__(28), | ||
toInteger: __webpack_require__(28), | ||
toRadian: __webpack_require__(54), | ||
maxBy: __webpack_require__(55), | ||
minBy: __webpack_require__(56), | ||
getType: __webpack_require__(25), | ||
isArray: __webpack_require__(0), | ||
isArrayLike: __webpack_require__(2), | ||
isBoolean: __webpack_require__(57), | ||
isDate: __webpack_require__(58), | ||
isFunction: __webpack_require__(4), | ||
isNil: __webpack_require__(7), | ||
isNull: __webpack_require__(59), | ||
isNumber: __webpack_require__(5), | ||
isObject: __webpack_require__(17), | ||
isObjectLike: __webpack_require__(12), | ||
isPlainObject: __webpack_require__(8), | ||
isPrototype: __webpack_require__(26), | ||
isType: __webpack_require__(3), | ||
isUndefined: __webpack_require__(60), | ||
isString: __webpack_require__(6), | ||
isRegExp: __webpack_require__(61), | ||
lowerCase: __webpack_require__(62), | ||
lowerFirst: __webpack_require__(63), | ||
substitute: __webpack_require__(64), | ||
upperCase: __webpack_require__(65), | ||
upperFirst: __webpack_require__(66), | ||
contains: __webpack_require__(9), | ||
firstValue: __webpack_require__(14), | ||
flatten: __webpack_require__(22), | ||
getRange: __webpack_require__(15), | ||
pull: __webpack_require__(18), | ||
pullAt: __webpack_require__(10), | ||
reduce: __webpack_require__(24), | ||
remove: __webpack_require__(19), | ||
union: __webpack_require__(23), | ||
uniq: __webpack_require__(20), | ||
values: __webpack_require__(21), | ||
groupBy: __webpack_require__(29), | ||
groupToMap: __webpack_require__(30), | ||
group: __webpack_require__(67), | ||
pick: __webpack_require__(68) | ||
var merge = function merge(dataArray) { | ||
var rst = []; | ||
for (var i = 0; i < dataArray.length; i++) { | ||
rst = rst.concat(dataArray[i]); | ||
} | ||
return rst; | ||
}; | ||
/***/ }), | ||
/* 32 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
module.exports = merge; | ||
module.exports = { | ||
contains: __webpack_require__(9), | ||
firstValue: __webpack_require__(14), | ||
getRange: __webpack_require__(15), | ||
pull: __webpack_require__(18), | ||
pullAt: __webpack_require__(10), | ||
remove: __webpack_require__(19), | ||
uniq: __webpack_require__(20), | ||
values: __webpack_require__(21), | ||
flatten: __webpack_require__(22), | ||
union: __webpack_require__(23), | ||
reduce: __webpack_require__(24) | ||
}; | ||
/***/ }), | ||
/* 33 */ | ||
/* 28 */ | ||
/***/ (function(module, exports) { | ||
var arrPrototype = Array.prototype; | ||
var splice = arrPrototype.splice; | ||
var indexOf = arrPrototype.indexOf; | ||
var slice = arrPrototype.slice; | ||
function toString(value) { | ||
return value.toString(); | ||
} | ||
function upperCase(value) { | ||
return toString(value).toUpperCase(); | ||
} | ||
function lowerCase(value) { | ||
return toString(value).toLowerCase(); | ||
} | ||
var strUtil = { | ||
lc: lowerCase, | ||
lowerCase: lowerCase, | ||
lowerFirst: function lowerFirst(value) { | ||
value = toString(value); | ||
return lowerCase(value.charAt(0)) + value.substring(1); | ||
}, | ||
uc: upperCase, | ||
upperCase: upperCase, | ||
upperFirst: function upperFirst(value) { | ||
value = toString(value); | ||
return upperCase(value.charAt(0)) + value.substring(1); | ||
var pull = function pull(arr) { | ||
var values = slice.call(arguments, 1); | ||
for (var i = 0; i < values.length; i++) { | ||
var value = values[i]; | ||
var fromIndex = -1; | ||
while ((fromIndex = indexOf.call(arr, value)) > -1) { | ||
splice.call(arr, fromIndex, 1); | ||
} | ||
} | ||
return arr; | ||
}; | ||
module.exports = strUtil; | ||
module.exports = pull; | ||
/***/ }), | ||
/* 34 */ | ||
/* 29 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var isArray = __webpack_require__(0); | ||
var isPlainObject = __webpack_require__(7); | ||
var each = __webpack_require__(1); | ||
var clone = function clone(obj) { | ||
if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || obj === null) { | ||
return obj; | ||
var reduce = function reduce(arr, fn, init) { | ||
if (!isArray(arr) && !isPlainObject(arr)) { | ||
return arr; | ||
} | ||
var rst = void 0; | ||
if (isArray(obj)) { | ||
rst = []; | ||
for (var i = 0, l = obj.length; i < l; i++) { | ||
if (_typeof(obj[i]) === 'object' && obj[i] != null) { | ||
rst[i] = clone(obj[i]); | ||
} else { | ||
rst[i] = obj[i]; | ||
} | ||
} | ||
} else { | ||
rst = {}; | ||
for (var k in obj) { | ||
if (_typeof(obj[k]) === 'object' && obj[k] != null) { | ||
rst[k] = clone(obj[k]); | ||
} else { | ||
rst[k] = obj[k]; | ||
} | ||
} | ||
} | ||
return rst; | ||
var result = init; | ||
each(arr, function (data, i) { | ||
result = fn(result, data, i); | ||
}); | ||
return result; | ||
}; | ||
module.exports = clone; | ||
module.exports = reduce; | ||
/***/ }), | ||
/* 35 */ | ||
/* 30 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isArrayLike = __webpack_require__(2); | ||
var pullAt = __webpack_require__(14); | ||
var indexOf = function indexOf(arr, obj) { | ||
var remove = function remove(arr, predicate) { | ||
/** | ||
* const arr = [1, 2, 3, 4] | ||
* const evens = remove(arr, n => n % 2 == 0) | ||
* console.log(arr) // => [1, 3] | ||
* console.log(evens) // => [2, 4] | ||
*/ | ||
var result = []; | ||
if (!isArrayLike(arr)) { | ||
return -1; | ||
return result; | ||
} | ||
var m = Array.prototype.indexOf; | ||
if (m) { | ||
return m.call(arr, obj); | ||
} | ||
var index = -1; | ||
var i = -1; | ||
var indexes = []; | ||
var length = arr.length; | ||
for (var i = 0; i < arr.length; i++) { | ||
if (arr[i] === obj) { | ||
index = i; | ||
break; | ||
while (++i < length) { | ||
var value = arr[i]; | ||
if (predicate(value, i, arr)) { | ||
result.push(value); | ||
indexes.push(i); | ||
} | ||
} | ||
return index; | ||
pullAt(arr, indexes); | ||
return result; | ||
}; | ||
module.exports = indexOf; | ||
module.exports = remove; | ||
/***/ }), | ||
/* 36 */ | ||
/* 31 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isNil = __webpack_require__(7); | ||
var isArrayLike = __webpack_require__(2); | ||
var getType = __webpack_require__(25); | ||
var isPrototype = __webpack_require__(26); | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
var each = __webpack_require__(1); | ||
var toArray = __webpack_require__(9); | ||
function isEmpty(value) { | ||
/** | ||
* isEmpty(null) => true | ||
* isEmpty() => true | ||
* isEmpty(true) => true | ||
* isEmpty(1) => true | ||
* isEmpty([1, 2, 3]) => false | ||
* isEmpty('abc') => false | ||
* isEmpty({ a: 1 }) => false | ||
*/ | ||
if (isNil(value)) { | ||
return true; | ||
} | ||
if (isArrayLike(value)) { | ||
return !value.length; | ||
} | ||
var type = getType(value); | ||
if (type === 'Map' || type === 'Set') { | ||
return !value.size; | ||
} | ||
if (isPrototype(value)) { | ||
return !Object.keys(value).length; | ||
} | ||
for (var key in value) { | ||
if (hasOwnProperty.call(value, key)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
var union = function union() { | ||
var result = new Set(); | ||
var values = []; | ||
each(arguments, function (arg) { | ||
values = toArray(arg); | ||
each(values, function (val) { | ||
result.add(val); | ||
}); | ||
}); | ||
return Array.from(result); | ||
}; | ||
module.exports = isEmpty; | ||
module.exports = union; | ||
/***/ }), | ||
/* 37 */ | ||
/* 32 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isFunction = __webpack_require__(4); | ||
var isEqual = __webpack_require__(27); | ||
/** | ||
* @param {*} value The value to compare. | ||
* @param {*} other The other value to compare. | ||
* @param {Function} [fn] The function to customize comparisons. | ||
* @returns {boolean} Returns `true` if the values are equivalent, else `false`. | ||
* @example | ||
* | ||
* function isGreeting(value) { | ||
* return /^h(?:i|ello)$/.test(value); | ||
* } | ||
* | ||
* function customizer(objValue, othValue) { | ||
* if (isGreeting(objValue) && isGreeting(othValue)) { | ||
* return true; | ||
* } | ||
* } | ||
* | ||
* var array = ['hello', 'goodbye']; | ||
* var other = ['hi', 'goodbye']; | ||
* | ||
* _.isEqualWith(array, other, customizer); // => true | ||
*/ | ||
var contains = __webpack_require__(11); | ||
var isEqualWith = function isEqualWith(value, other, fn) { | ||
if (!isFunction(fn)) { | ||
return isEqual(value, other); | ||
} | ||
return !!fn(value, other); | ||
var uniq = function uniq(arr) { | ||
var resultArr = []; | ||
arr.forEach(function (item) { | ||
if (!contains(resultArr, item)) { | ||
resultArr.push(item); | ||
} | ||
}); | ||
return resultArr; | ||
}; | ||
module.exports = isEqualWith; | ||
module.exports = uniq; | ||
/***/ }), | ||
/* 38 */ | ||
/* 33 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var each = __webpack_require__(1); | ||
var isArrayLike = __webpack_require__(2); | ||
var isNil = __webpack_require__(6); | ||
var isArray = __webpack_require__(0); | ||
var map = function map(arr, func) { | ||
if (!isArrayLike(arr)) { | ||
return arr; | ||
var values = function values(data, name) { | ||
var rst = []; | ||
var tmpMap = {}; | ||
for (var i = 0; i < data.length; i++) { | ||
var obj = data[i]; | ||
var value = obj[name]; | ||
if (!isNil(value)) { | ||
if (!isArray(value)) { | ||
value = [value]; | ||
} | ||
each(value, function (val) { | ||
if (!tmpMap[val]) { | ||
rst.push(val); | ||
tmpMap[val] = true; | ||
} | ||
}); | ||
} | ||
} | ||
var result = []; | ||
each(arr, function (value, index) { | ||
result.push(func(value, index)); | ||
}); | ||
return result; | ||
return rst; | ||
}; | ||
module.exports = map; | ||
module.exports = values; | ||
/***/ }), | ||
/* 39 */ | ||
/***/ (function(module, exports) { | ||
/* 34 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var uniqueId = function () { | ||
var map = {}; | ||
return function (prefix) { | ||
prefix = prefix || 'g'; | ||
if (!map[prefix]) { | ||
map[prefix] = 1; | ||
} else { | ||
map[prefix] += 1; | ||
} | ||
return prefix + map[prefix]; | ||
}; | ||
}(); | ||
module.exports = uniqueId; | ||
module.exports = { | ||
getWrapBehavior: __webpack_require__(35), | ||
wrapBehavior: __webpack_require__(36) | ||
}; | ||
/***/ }), | ||
/* 40 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/* 35 */ | ||
/***/ (function(module, exports) { | ||
var isFunction = __webpack_require__(4); | ||
var mix = __webpack_require__(13); | ||
/** | ||
* 获取封装的事件 | ||
* @protected | ||
* @param {Object} obj 对象 | ||
* @param {String} action 事件名称 | ||
* @return {Function} 返回事件处理函数 | ||
*/ | ||
function getWrapBehavior(obj, action) { | ||
return obj['_wrap_' + action]; | ||
} | ||
var extend = function extend(subclass, superclass, overrides, staticOverrides) { | ||
// 如果只提供父类构造函数,则自动生成子类构造函数 | ||
if (!isFunction(superclass)) { | ||
overrides = superclass; | ||
superclass = subclass; | ||
subclass = function subclass() {}; | ||
} | ||
module.exports = getWrapBehavior; | ||
var create = Object.create ? function (proto, c) { | ||
return Object.create(proto, { | ||
constructor: { | ||
value: c | ||
} | ||
}); | ||
} : function (proto, c) { | ||
function Tmp() {} | ||
Tmp.prototype = proto; | ||
var o = new Tmp(); | ||
o.constructor = c; | ||
return o; | ||
}; | ||
var superObj = create(superclass.prototype, subclass); // new superclass(),//实例化父类作为子类的prototype | ||
subclass.prototype = mix(superObj, subclass.prototype); // 指定子类的prototype | ||
subclass.superclass = create(superclass.prototype, superclass); | ||
mix(superObj, overrides); | ||
mix(subclass, staticOverrides); | ||
return subclass; | ||
}; | ||
module.exports = extend; | ||
/***/ }), | ||
/* 41 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/* 36 */ | ||
/***/ (function(module, exports) { | ||
var isFunction = __webpack_require__(4); | ||
var toArray = __webpack_require__(11); | ||
var mix = __webpack_require__(13); | ||
var augment = function augment(c) { | ||
var args = toArray(arguments); | ||
for (var i = 1; i < args.length; i++) { | ||
var obj = args[i]; | ||
if (isFunction(obj)) { | ||
obj = obj.prototype; | ||
} | ||
mix(c.prototype, obj); | ||
/** | ||
* 封装事件,便于使用上下文this,和便于解除事件时使用 | ||
* @protected | ||
* @param {Object} obj 对象 | ||
* @param {String} action 事件名称 | ||
* @return {Function} 返回事件处理函数 | ||
*/ | ||
function wrapBehavior(obj, action) { | ||
if (obj['_wrap_' + action]) { | ||
return obj['_wrap_' + action]; | ||
} | ||
}; | ||
var method = function method(e) { | ||
obj[action](e); | ||
}; | ||
obj['_wrap_' + action] = method; | ||
return method; | ||
} | ||
module.exports = augment; | ||
module.exports = wrapBehavior; | ||
/***/ }), | ||
/* 42 */ | ||
/* 37 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isPlainObject = __webpack_require__(8); | ||
var isArray = __webpack_require__(0); | ||
var MAX_MIX_LEVEL = 5; | ||
function _deepMix(dist, src, level, maxLevel) { | ||
level = level || 0; | ||
maxLevel = maxLevel || MAX_MIX_LEVEL; | ||
for (var key in src) { | ||
if (src.hasOwnProperty(key)) { | ||
var value = src[key]; | ||
if (value !== null && isPlainObject(value)) { | ||
if (!isPlainObject(dist[key])) { | ||
dist[key] = {}; | ||
} | ||
if (level < maxLevel) { | ||
_deepMix(dist[key], value, level + 1, maxLevel); | ||
} else { | ||
dist[key] = src[key]; | ||
} | ||
} else if (isArray(value)) { | ||
dist[key] = []; | ||
dist[key] = dist[key].concat(value); | ||
} else if (value !== undefined) { | ||
dist[key] = value; | ||
} | ||
} | ||
} | ||
} | ||
var deepMix = function deepMix() { | ||
var args = new Array(arguments.length); | ||
var length = args.length; | ||
for (var i = 0; i < length; i++) { | ||
args[i] = arguments[i]; | ||
} | ||
var rst = args[0]; | ||
for (var _i = 1; _i < length; _i++) { | ||
_deepMix(rst, args[_i]); | ||
} | ||
return rst; | ||
module.exports = { | ||
clamp: __webpack_require__(38), | ||
fixedBase: __webpack_require__(39), | ||
isDecimal: __webpack_require__(40), | ||
isEven: __webpack_require__(41), | ||
isInteger: __webpack_require__(42), | ||
isNegative: __webpack_require__(43), | ||
isNumberEqual: __webpack_require__(44), | ||
isOdd: __webpack_require__(45), | ||
isPositive: __webpack_require__(46), | ||
maxBy: __webpack_require__(47), | ||
minBy: __webpack_require__(48), | ||
mod: __webpack_require__(49), | ||
toDegree: __webpack_require__(50), | ||
toInt: __webpack_require__(15), | ||
toInteger: __webpack_require__(15), | ||
toRadian: __webpack_require__(51) | ||
}; | ||
module.exports = deepMix; | ||
/***/ }), | ||
/* 43 */ | ||
/* 38 */ | ||
/***/ (function(module, exports) { | ||
@@ -1210,3 +941,3 @@ | ||
/***/ }), | ||
/* 44 */ | ||
/* 39 */ | ||
/***/ (function(module, exports) { | ||
@@ -1230,6 +961,6 @@ | ||
/***/ }), | ||
/* 45 */ | ||
/* 40 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isNumber = __webpack_require__(5); | ||
var isNumber = __webpack_require__(4); | ||
@@ -1243,6 +974,6 @@ var isDecimal = function isDecimal(num) { | ||
/***/ }), | ||
/* 46 */ | ||
/* 41 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isNumber = __webpack_require__(5); | ||
var isNumber = __webpack_require__(4); | ||
@@ -1256,6 +987,6 @@ var isEven = function isEven(num) { | ||
/***/ }), | ||
/* 47 */ | ||
/* 42 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isNumber = __webpack_require__(5); | ||
var isNumber = __webpack_require__(4); | ||
@@ -1269,6 +1000,6 @@ var isInteger = Number.isInteger ? Number.isInteger : function (num) { | ||
/***/ }), | ||
/* 48 */ | ||
/* 43 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isNumber = __webpack_require__(5); | ||
var isNumber = __webpack_require__(4); | ||
@@ -1282,3 +1013,3 @@ var isNagative = function isNagative(num) { | ||
/***/ }), | ||
/* 49 */ | ||
/* 44 */ | ||
/***/ (function(module, exports) { | ||
@@ -1295,6 +1026,6 @@ | ||
/***/ }), | ||
/* 50 */ | ||
/* 45 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isNumber = __webpack_require__(5); | ||
var isNumber = __webpack_require__(4); | ||
@@ -1308,6 +1039,6 @@ var isOdd = function isOdd(num) { | ||
/***/ }), | ||
/* 51 */ | ||
/* 46 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isNumber = __webpack_require__(5); | ||
var isNumber = __webpack_require__(4); | ||
@@ -1321,41 +1052,7 @@ var isPositive = function isPositive(num) { | ||
/***/ }), | ||
/* 52 */ | ||
/***/ (function(module, exports) { | ||
var mod = function mod(n, m) { | ||
return (n % m + m) % m; | ||
}; | ||
module.exports = mod; | ||
/***/ }), | ||
/* 53 */ | ||
/***/ (function(module, exports) { | ||
var DEGREE = 180 / Math.PI; | ||
var toDegree = function toDegree(radian) { | ||
return DEGREE * radian; | ||
}; | ||
module.exports = toDegree; | ||
/***/ }), | ||
/* 54 */ | ||
/***/ (function(module, exports) { | ||
var RADIAN = Math.PI / 180; | ||
var toRadian = function toRadian(degree) { | ||
return RADIAN * degree; | ||
}; | ||
module.exports = toRadian; | ||
/***/ }), | ||
/* 55 */ | ||
/* 47 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isArray = __webpack_require__(0); | ||
var isFunction = __webpack_require__(4); | ||
var isFunction = __webpack_require__(5); | ||
var each = __webpack_require__(1); | ||
@@ -1405,7 +1102,7 @@ /** | ||
/***/ }), | ||
/* 56 */ | ||
/* 48 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isArray = __webpack_require__(0); | ||
var isFunction = __webpack_require__(4); | ||
var isFunction = __webpack_require__(5); | ||
var each = __webpack_require__(1); | ||
@@ -1455,5 +1152,107 @@ /** | ||
/***/ }), | ||
/* 57 */ | ||
/* 49 */ | ||
/***/ (function(module, exports) { | ||
var mod = function mod(n, m) { | ||
return (n % m + m) % m; | ||
}; | ||
module.exports = mod; | ||
/***/ }), | ||
/* 50 */ | ||
/***/ (function(module, exports) { | ||
var DEGREE = 180 / Math.PI; | ||
var toDegree = function toDegree(radian) { | ||
return DEGREE * radian; | ||
}; | ||
module.exports = toDegree; | ||
/***/ }), | ||
/* 51 */ | ||
/***/ (function(module, exports) { | ||
var RADIAN = Math.PI / 180; | ||
var toRadian = function toRadian(degree) { | ||
return RADIAN * degree; | ||
}; | ||
module.exports = toRadian; | ||
/***/ }), | ||
/* 52 */ | ||
/***/ (function(module, exports) { | ||
function toString(value) { | ||
return value.toString(); | ||
} | ||
function upperCase(value) { | ||
return toString(value).toUpperCase(); | ||
} | ||
function lowerCase(value) { | ||
return toString(value).toLowerCase(); | ||
} | ||
var strUtil = { | ||
lc: lowerCase, | ||
lowerCase: lowerCase, | ||
lowerFirst: function lowerFirst(value) { | ||
value = toString(value); | ||
return lowerCase(value.charAt(0)) + value.substring(1); | ||
}, | ||
uc: upperCase, | ||
upperCase: upperCase, | ||
upperFirst: function upperFirst(value) { | ||
value = toString(value); | ||
return upperCase(value.charAt(0)) + value.substring(1); | ||
} | ||
}; | ||
module.exports = strUtil; | ||
/***/ }), | ||
/* 53 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isType = __webpack_require__(3); | ||
var checkType = { | ||
getType: __webpack_require__(16), | ||
isArray: __webpack_require__(0), | ||
isArrayLike: __webpack_require__(2), | ||
isBoolean: __webpack_require__(54), | ||
isFunction: __webpack_require__(5), | ||
isNil: __webpack_require__(6), | ||
isNull: __webpack_require__(55), | ||
isNumber: __webpack_require__(4), | ||
isObject: __webpack_require__(12), | ||
isObjectLike: __webpack_require__(8), | ||
isPlainObject: __webpack_require__(7), | ||
isPrototype: __webpack_require__(17), | ||
isType: isType, | ||
isUndefined: __webpack_require__(56), | ||
isString: __webpack_require__(18), | ||
isRegExp: __webpack_require__(57) | ||
}; | ||
['Arguments', 'Date', 'Error'].forEach(function (type) { | ||
checkType['is' + type] = function (value) { | ||
return isType(value, type); | ||
}; | ||
}); | ||
module.exports = checkType; | ||
/***/ }), | ||
/* 54 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/** | ||
@@ -1474,15 +1273,3 @@ * 是否是布尔类型 | ||
/***/ }), | ||
/* 58 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isType = __webpack_require__(3); | ||
var isDate = function isDate(value) { | ||
return isType(value, 'Date'); | ||
}; | ||
module.exports = isDate; | ||
/***/ }), | ||
/* 59 */ | ||
/* 55 */ | ||
/***/ (function(module, exports) { | ||
@@ -1497,3 +1284,3 @@ | ||
/***/ }), | ||
/* 60 */ | ||
/* 56 */ | ||
/***/ (function(module, exports) { | ||
@@ -1508,3 +1295,3 @@ | ||
/***/ }), | ||
/* 61 */ | ||
/* 57 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1521,84 +1308,153 @@ | ||
/***/ }), | ||
/* 62 */ | ||
/* 58 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isString = __webpack_require__(6); | ||
var isFunction = __webpack_require__(5); | ||
var toArray = __webpack_require__(9); | ||
var mix = __webpack_require__(10); | ||
var lowerCase = function lowerCase(str) { | ||
if (!isString(str)) { | ||
return str; | ||
var augment = function augment(c) { | ||
var args = toArray(arguments); | ||
for (var i = 1; i < args.length; i++) { | ||
var obj = args[i]; | ||
if (isFunction(obj)) { | ||
obj = obj.prototype; | ||
} | ||
mix(c.prototype, obj); | ||
} | ||
return str.toString().toLowerCase(); | ||
}; | ||
module.exports = lowerCase; | ||
module.exports = augment; | ||
/***/ }), | ||
/* 63 */ | ||
/* 59 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isString = __webpack_require__(6); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var lowerFirst = function lowerFirst(value) { | ||
if (!isString(value)) { | ||
return value; | ||
} | ||
return value.charAt(0).toLowerCase() + value.substring(1); | ||
}; | ||
var isArray = __webpack_require__(0); | ||
module.exports = lowerFirst; | ||
/***/ }), | ||
/* 64 */ | ||
/***/ (function(module, exports) { | ||
var substitute = function substitute(str, o) { | ||
if (!str || !o) { | ||
return str; | ||
var clone = function clone(obj) { | ||
if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || obj === null) { | ||
return obj; | ||
} | ||
return str.replace(/\\?\{([^{}]+)\}/g, function (match, name) { | ||
if (match.charAt(0) === '\\') { | ||
return match.slice(1); | ||
var rst = void 0; | ||
if (isArray(obj)) { | ||
rst = []; | ||
for (var i = 0, l = obj.length; i < l; i++) { | ||
if (_typeof(obj[i]) === 'object' && obj[i] != null) { | ||
rst[i] = clone(obj[i]); | ||
} else { | ||
rst[i] = obj[i]; | ||
} | ||
} | ||
return o[name] === undefined ? '' : o[name]; | ||
}); | ||
} else { | ||
rst = {}; | ||
for (var k in obj) { | ||
if (_typeof(obj[k]) === 'object' && obj[k] != null) { | ||
rst[k] = clone(obj[k]); | ||
} else { | ||
rst[k] = obj[k]; | ||
} | ||
} | ||
} | ||
return rst; | ||
}; | ||
module.exports = substitute; | ||
module.exports = clone; | ||
/***/ }), | ||
/* 65 */ | ||
/* 60 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isString = __webpack_require__(6); | ||
var isPlainObject = __webpack_require__(7); | ||
var isArray = __webpack_require__(0); | ||
var upperCase = function upperCase(str) { | ||
if (!isString(str)) { | ||
return str; | ||
var MAX_MIX_LEVEL = 5; | ||
function _deepMix(dist, src, level, maxLevel) { | ||
level = level || 0; | ||
maxLevel = maxLevel || MAX_MIX_LEVEL; | ||
for (var key in src) { | ||
if (src.hasOwnProperty(key)) { | ||
var value = src[key]; | ||
if (value !== null && isPlainObject(value)) { | ||
if (!isPlainObject(dist[key])) { | ||
dist[key] = {}; | ||
} | ||
if (level < maxLevel) { | ||
_deepMix(dist[key], value, level + 1, maxLevel); | ||
} else { | ||
dist[key] = src[key]; | ||
} | ||
} else if (isArray(value)) { | ||
dist[key] = []; | ||
dist[key] = dist[key].concat(value); | ||
} else if (value !== undefined) { | ||
dist[key] = value; | ||
} | ||
} | ||
} | ||
return str.toString().toUpperCase(); | ||
} | ||
var deepMix = function deepMix() { | ||
var args = new Array(arguments.length); | ||
var length = args.length; | ||
for (var i = 0; i < length; i++) { | ||
args[i] = arguments[i]; | ||
} | ||
var rst = args[0]; | ||
for (var _i = 1; _i < length; _i++) { | ||
_deepMix(rst, args[_i]); | ||
} | ||
return rst; | ||
}; | ||
module.exports = upperCase; | ||
module.exports = deepMix; | ||
/***/ }), | ||
/* 66 */ | ||
/* 61 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isString = __webpack_require__(6); | ||
var isFunction = __webpack_require__(5); | ||
var mix = __webpack_require__(10); | ||
var upperFirst = function upperFirst(value) { | ||
if (!isString(value)) { | ||
return value; | ||
var extend = function extend(subclass, superclass, overrides, staticOverrides) { | ||
// 如果只提供父类构造函数,则自动生成子类构造函数 | ||
if (!isFunction(superclass)) { | ||
overrides = superclass; | ||
superclass = subclass; | ||
subclass = function subclass() {}; | ||
} | ||
return value.charAt(0).toUpperCase() + value.substring(1); | ||
var create = Object.create ? function (proto, c) { | ||
return Object.create(proto, { | ||
constructor: { | ||
value: c | ||
} | ||
}); | ||
} : function (proto, c) { | ||
function Tmp() {} | ||
Tmp.prototype = proto; | ||
var o = new Tmp(); | ||
o.constructor = c; | ||
return o; | ||
}; | ||
var superObj = create(superclass.prototype, subclass); // new superclass(),//实例化父类作为子类的prototype | ||
subclass.prototype = mix(superObj, subclass.prototype); // 指定子类的prototype | ||
subclass.superclass = create(superclass.prototype, superclass); | ||
mix(superObj, overrides); | ||
mix(subclass, staticOverrides); | ||
return subclass; | ||
}; | ||
module.exports = upperFirst; | ||
module.exports = extend; | ||
/***/ }), | ||
/* 67 */ | ||
/* 62 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var groupToMap = __webpack_require__(30); | ||
var groupToMap = __webpack_require__(19); | ||
@@ -1620,8 +1476,136 @@ var group = function group(data, condition) { | ||
/***/ }), | ||
/* 68 */ | ||
/* 63 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isArrayLike = __webpack_require__(2); | ||
var indexOf = function indexOf(arr, obj) { | ||
if (!isArrayLike(arr)) { | ||
return -1; | ||
} | ||
var m = Array.prototype.indexOf; | ||
if (m) { | ||
return m.call(arr, obj); | ||
} | ||
var index = -1; | ||
for (var i = 0; i < arr.length; i++) { | ||
if (arr[i] === obj) { | ||
index = i; | ||
break; | ||
} | ||
} | ||
return index; | ||
}; | ||
module.exports = indexOf; | ||
/***/ }), | ||
/* 64 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isNil = __webpack_require__(6); | ||
var isArrayLike = __webpack_require__(2); | ||
var getType = __webpack_require__(16); | ||
var isPrototype = __webpack_require__(17); | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
function isEmpty(value) { | ||
/** | ||
* isEmpty(null) => true | ||
* isEmpty() => true | ||
* isEmpty(true) => true | ||
* isEmpty(1) => true | ||
* isEmpty([1, 2, 3]) => false | ||
* isEmpty('abc') => false | ||
* isEmpty({ a: 1 }) => false | ||
*/ | ||
if (isNil(value)) { | ||
return true; | ||
} | ||
if (isArrayLike(value)) { | ||
return !value.length; | ||
} | ||
var type = getType(value); | ||
if (type === 'Map' || type === 'Set') { | ||
return !value.size; | ||
} | ||
if (isPrototype(value)) { | ||
return !Object.keys(value).length; | ||
} | ||
for (var key in value) { | ||
if (hasOwnProperty.call(value, key)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
module.exports = isEmpty; | ||
/***/ }), | ||
/* 65 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var isFunction = __webpack_require__(5); | ||
var isEqual = __webpack_require__(21); | ||
/** | ||
* @param {*} value The value to compare. | ||
* @param {*} other The other value to compare. | ||
* @param {Function} [fn] The function to customize comparisons. | ||
* @returns {boolean} Returns `true` if the values are equivalent, else `false`. | ||
* @example | ||
* | ||
* function isGreeting(value) { | ||
* return /^h(?:i|ello)$/.test(value); | ||
* } | ||
* | ||
* function customizer(objValue, othValue) { | ||
* if (isGreeting(objValue) && isGreeting(othValue)) { | ||
* return true; | ||
* } | ||
* } | ||
* | ||
* var array = ['hello', 'goodbye']; | ||
* var other = ['hi', 'goodbye']; | ||
* | ||
* _.isEqualWith(array, other, customizer); // => true | ||
*/ | ||
var isEqualWith = function isEqualWith(value, other, fn) { | ||
if (!isFunction(fn)) { | ||
return isEqual(value, other); | ||
} | ||
return !!fn(value, other); | ||
}; | ||
module.exports = isEqualWith; | ||
/***/ }), | ||
/* 66 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var each = __webpack_require__(1); | ||
var isPlaineObject = __webpack_require__(8); | ||
var isArrayLike = __webpack_require__(2); | ||
var map = function map(arr, func) { | ||
if (!isArrayLike(arr)) { | ||
return arr; | ||
} | ||
var result = []; | ||
each(arr, function (value, index) { | ||
result.push(func(value, index)); | ||
}); | ||
return result; | ||
}; | ||
module.exports = map; | ||
/***/ }), | ||
/* 67 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var each = __webpack_require__(1); | ||
var isPlaineObject = __webpack_require__(7); | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
@@ -1655,4 +1639,23 @@ /** | ||
/***/ }), | ||
/* 68 */ | ||
/***/ (function(module, exports) { | ||
var uniqueId = function () { | ||
var map = {}; | ||
return function (prefix) { | ||
prefix = prefix || 'g'; | ||
if (!map[prefix]) { | ||
map[prefix] = 1; | ||
} else { | ||
map[prefix] += 1; | ||
} | ||
return prefix + map[prefix]; | ||
}; | ||
}(); | ||
module.exports = uniqueId; | ||
/***/ }) | ||
/******/ ]); | ||
}); |
module.exports = { | ||
contains: require('./contains'), | ||
firstValue: require('./firstValue'), | ||
flatten: require('./flatten'), | ||
getRange: require('./getRange'), | ||
merge: require('./merge'), | ||
pull: require('./pull'), | ||
pullAt: require('./pullAt'), | ||
reduce: require('./reduce'), | ||
remove: require('./remove'), | ||
union: require('./union'), | ||
uniq: require('./uniq'), | ||
values: require('./values'), | ||
flatten: require('./flatten'), | ||
union: require('./union'), | ||
reduce: require('./reduce') | ||
values: require('./values') | ||
}; |
@@ -1,7 +0,27 @@ | ||
module.exports = { | ||
arrayUtil: require('./array/index'), | ||
stringUtil: require('./string'), | ||
var arrayUtil = require('./array'); | ||
var eventUtil = require('./event'); | ||
var mathUtil = require('./math'); | ||
var stringUtil = require('./string'); | ||
var typeUtil = require('./type'); | ||
var each = require('./each'); | ||
var mix = require('./mix'); | ||
var util = { | ||
// collections | ||
arrayUtil: arrayUtil, | ||
eventUtil: eventUtil, | ||
mathUtil: mathUtil, | ||
stringUtil: stringUtil, | ||
typeUtil: typeUtil, | ||
// others | ||
augment: require('./augment'), | ||
clone: require('./clone'), | ||
each: require('./each'), | ||
deepMix: require('./deepMix'), | ||
each: each, | ||
extend: require('./extend'), | ||
filter: require('./filter'), | ||
group: require('./group'), | ||
groupBy: require('./groupBy'), | ||
groupToMap: require('./groupToMap'), | ||
indexOf: require('./indexOf'), | ||
@@ -12,61 +32,12 @@ isEmpty: require('./isEmpty'), | ||
map: require('./map'), | ||
mix: mix, | ||
pick: require('./pick'), | ||
toArray: require('./toArray'), | ||
uniqueId: require('./uniqueId'), | ||
extend: require('./extend'), | ||
augment: require('./augment'), | ||
deepMix: require('./deepMix'), | ||
mix: require('./mix'), | ||
clamp: require('./math/clamp'), | ||
fixedBase: require('./math/fixedBase'), | ||
isDecimal: require('./math/isDecimal'), | ||
isEven: require('./math/isEven'), | ||
isInteger: require('./math/isInteger'), | ||
isNegative: require('./math/isNegative'), | ||
isNumberEqual: require('./math/isNumberEqual'), | ||
isOdd: require('./math/isOdd'), | ||
isPositive: require('./math/isPositive'), | ||
mod: require('./math/mod'), | ||
toDegree: require('./math/toDegree'), | ||
toInt: require('./math/toInteger'), | ||
toInteger: require('./math/toInteger'), | ||
toRadian: require('./math/toRadian'), | ||
maxBy: require('./math/maxBy'), | ||
minBy: require('./math/minBy'), | ||
getType: require('./type/getType'), | ||
isArray: require('./type/isArray'), | ||
isArrayLike: require('./type/isArrayLike'), | ||
isBoolean: require('./type/isBoolean'), | ||
isDate: require('./type/isDate'), | ||
isFunction: require('./type/isFunction'), | ||
isNil: require('./type/isNil'), | ||
isNull: require('./type/isNull'), | ||
isNumber: require('./type/isNumber'), | ||
isObject: require('./type/isObject'), | ||
isObjectLike: require('./type/isObjectLike'), | ||
isPlainObject: require('./type/isPlainObject'), | ||
isPrototype: require('./type/isPrototype'), | ||
isType: require('./type/isType'), | ||
isUndefined: require('./type/isUndefined'), | ||
isString: require('./type/isString'), | ||
isRegExp: require('./type/isRegExp'), | ||
lowerCase: require('./string/lowerCase'), | ||
lowerFirst: require('./string/lowerFirst'), | ||
substitute: require('./string/substitute'), | ||
upperCase: require('./string/upperCase'), | ||
upperFirst: require('./string/upperFirst'), | ||
contains: require('./array/contains'), | ||
firstValue: require('./array/firstValue'), | ||
flatten: require('./array/flatten'), | ||
getRange: require('./array/getRange'), | ||
pull: require('./array/pull'), | ||
pullAt: require('./array/pullAt'), | ||
reduce: require('./array/reduce'), | ||
remove: require('./array/remove'), | ||
union: require('./array/union'), | ||
uniq: require('./array/uniq'), | ||
values: require('./array/values'), | ||
groupBy: require('./groupBy'), | ||
groupToMap: require('./groupToMap'), | ||
group: require('./group'), | ||
pick: require('./pick') | ||
}; | ||
uniqueId: require('./uniqueId') | ||
}; | ||
each([arrayUtil, eventUtil, mathUtil, stringUtil, typeUtil], function (collection) { | ||
mix(util, collection); | ||
}); | ||
module.exports = util; |
@@ -11,2 +11,4 @@ module.exports = { | ||
isPositive: require('./isPositive'), | ||
maxBy: require('./maxBy'), | ||
minBy: require('./minBy'), | ||
mod: require('./mod'), | ||
@@ -16,5 +18,3 @@ toDegree: require('./toDegree'), | ||
toInteger: require('./toInteger'), | ||
toRadian: require('./toRadian'), | ||
maxBy: require('./maxBy'), | ||
minBy: require('./minBy') | ||
toRadian: require('./toRadian') | ||
}; |
{ | ||
"name": "@antv/util", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "A common util collection for antv projects", | ||
@@ -15,3 +15,3 @@ "browser": "build/util.js", | ||
"coverage-viewer": "torch-coverage", | ||
"coverage-generator": "torch --coverage --compile --renderer --recursive test/unit", | ||
"coverage-generator": "torch --coverage --compile --renderer --source-pattern src/*.js,src/**/*.js --recursive test/unit", | ||
"dev": "webpack --config webpack-dev.config.js", | ||
@@ -55,3 +55,3 @@ "dist": "rm -rf dist && mkdir dist && npm run build && npm run compress", | ||
"string-replace-loader": "~1.3.0", | ||
"torchjs": "~1.2.1", | ||
"torchjs": "~2.0.4", | ||
"uglify-js": "~3.0.15", | ||
@@ -58,0 +58,0 @@ "webpack": "~3.4.1" |
module.exports = { | ||
contains: require('./contains'), | ||
firstValue: require('./firstValue'), | ||
flatten: require('./flatten'), | ||
getRange: require('./getRange'), | ||
merge: require('./merge'), | ||
pull: require('./pull'), | ||
pullAt: require('./pullAt'), | ||
reduce: require('./reduce'), | ||
remove: require('./remove'), | ||
union: require('./union'), | ||
uniq: require('./uniq'), | ||
values: require('./values'), | ||
flatten: require('./flatten'), | ||
union: require('./union'), | ||
reduce: require('./reduce') | ||
values: require('./values') | ||
}; |
101
src/index.js
@@ -1,7 +0,27 @@ | ||
module.exports = { | ||
arrayUtil: require('./array/index'), | ||
stringUtil: require('./string'), | ||
const arrayUtil = require('./array'); | ||
const eventUtil = require('./event'); | ||
const mathUtil = require('./math'); | ||
const stringUtil = require('./string'); | ||
const typeUtil = require('./type'); | ||
const each = require('./each'); | ||
const mix = require('./mix'); | ||
const util = { | ||
// collections | ||
arrayUtil, | ||
eventUtil, | ||
mathUtil, | ||
stringUtil, | ||
typeUtil, | ||
// others | ||
augment: require('./augment'), | ||
clone: require('./clone'), | ||
each: require('./each'), | ||
deepMix: require('./deepMix'), | ||
each, | ||
extend: require('./extend'), | ||
filter: require('./filter'), | ||
group: require('./group'), | ||
groupBy: require('./groupBy'), | ||
groupToMap: require('./groupToMap'), | ||
indexOf: require('./indexOf'), | ||
@@ -12,61 +32,18 @@ isEmpty: require('./isEmpty'), | ||
map: require('./map'), | ||
mix, | ||
pick: require('./pick'), | ||
toArray: require('./toArray'), | ||
uniqueId: require('./uniqueId'), | ||
extend: require('./extend'), | ||
augment: require('./augment'), | ||
deepMix: require('./deepMix'), | ||
mix: require('./mix'), | ||
clamp: require('./math/clamp'), | ||
fixedBase: require('./math/fixedBase'), | ||
isDecimal: require('./math/isDecimal'), | ||
isEven: require('./math/isEven'), | ||
isInteger: require('./math/isInteger'), | ||
isNegative: require('./math/isNegative'), | ||
isNumberEqual: require('./math/isNumberEqual'), | ||
isOdd: require('./math/isOdd'), | ||
isPositive: require('./math/isPositive'), | ||
mod: require('./math/mod'), | ||
toDegree: require('./math/toDegree'), | ||
toInt: require('./math/toInteger'), | ||
toInteger: require('./math/toInteger'), | ||
toRadian: require('./math/toRadian'), | ||
maxBy: require('./math/maxBy'), | ||
minBy: require('./math/minBy'), | ||
getType: require('./type/getType'), | ||
isArray: require('./type/isArray'), | ||
isArrayLike: require('./type/isArrayLike'), | ||
isBoolean: require('./type/isBoolean'), | ||
isDate: require('./type/isDate'), | ||
isFunction: require('./type/isFunction'), | ||
isNil: require('./type/isNil'), | ||
isNull: require('./type/isNull'), | ||
isNumber: require('./type/isNumber'), | ||
isObject: require('./type/isObject'), | ||
isObjectLike: require('./type/isObjectLike'), | ||
isPlainObject: require('./type/isPlainObject'), | ||
isPrototype: require('./type/isPrototype'), | ||
isType: require('./type/isType'), | ||
isUndefined: require('./type/isUndefined'), | ||
isString: require('./type/isString'), | ||
isRegExp: require('./type/isRegExp'), | ||
lowerCase: require('./string/lowerCase'), | ||
lowerFirst: require('./string/lowerFirst'), | ||
substitute: require('./string/substitute'), | ||
upperCase: require('./string/upperCase'), | ||
upperFirst: require('./string/upperFirst'), | ||
contains: require('./array/contains'), | ||
firstValue: require('./array/firstValue'), | ||
flatten: require('./array/flatten'), | ||
getRange: require('./array/getRange'), | ||
pull: require('./array/pull'), | ||
pullAt: require('./array/pullAt'), | ||
reduce: require('./array/reduce'), | ||
remove: require('./array/remove'), | ||
union: require('./array/union'), | ||
uniq: require('./array/uniq'), | ||
values: require('./array/values'), | ||
groupBy: require('./groupBy'), | ||
groupToMap: require('./groupToMap'), | ||
group: require('./group'), | ||
pick: require('./pick') | ||
uniqueId: require('./uniqueId') | ||
}; | ||
each([ | ||
arrayUtil, | ||
eventUtil, | ||
mathUtil, | ||
stringUtil, | ||
typeUtil | ||
], collection => { | ||
mix(util, collection); | ||
}); | ||
module.exports = util; |
@@ -11,2 +11,4 @@ module.exports = { | ||
isPositive: require('./isPositive'), | ||
maxBy: require('./maxBy'), | ||
minBy: require('./minBy'), | ||
mod: require('./mod'), | ||
@@ -16,5 +18,3 @@ toDegree: require('./toDegree'), | ||
toInteger: require('./toInteger'), | ||
toRadian: require('./toRadian'), | ||
maxBy: require('./maxBy'), | ||
minBy: require('./minBy') | ||
toRadian: require('./toRadian') | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
171
122368
3914