-
Notifications
You must be signed in to change notification settings - Fork 0
/
like-underscore-util-min.js
58 lines (58 loc) · 30 KB
/
like-underscore-util-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
!function(){var u="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||this||{},n=u._,p=function(n){return n instanceof p?n:this instanceof p?void(this._wrapped=n):new p(n)};"undefined"==typeof exports||exports.nodeType?u._=p:("undefined"!=typeof module&&!module.nodeType&&module.exports&&(exports=module.exports=p),exports._=p),p.VERSION="1.0.0";function o(){}var e=Array.prototype,a=e.push,c=e.slice,t=Object.prototype,f=t.toString,i=t.hasOwnProperty,r=Array.isArray,l=Math.pow(2,53)-1,s=p.iteratee=function(n,t){return d(n,t,1/0)};p.noop=o;function h(t){return function(n){if(null!=t&&null!=n)return n&&n[t]}}function y(r,e){var i=r&&r.length||0;return function(){var n;if(p.isNumber(e))return(n=[])[e]=[].slice.call(arguments),r.apply(this,n);if(arguments.length<i&&1!=i)
// args[pos] = [args[pos]];
return(n=[].slice.call(arguments)).length<i&&(n[i-1]=[]),r.apply(this,n);n=Array(i);for(var t=0;t<Math.max(0,i-1);t++)n[t]=arguments[t];return n[t]=[].slice.call(arguments,i-1),r.apply(this,n)}}var g=console.log.bind(),v=!1,d=function(n,t,r){return p.iteratee!=s?p.iteratee(n,t):null==n?p.identity:p.isFunction(n)?m(n,t,r):p.isObject(n)&&!p.isArray(n)?p.matcher(n):p.property(n)},m=function(i,u,n){if(null==u)return i;switch(null==n?3:n){case 1:return function(n){return i.call(u,n)};case 3:return function(n,t,r){return i.call(u,n,t,r)};case 4:return function(n,t,r,e){return i.call(u,n,t,r,e)}}return function(){return i.apply(u,arguments)}},_=h("length"),b=p.wrapperByArgsNumber=function(r,t){return function(n){return arguments.length<=1?r.call(null,n):!0===t?p.every(arguments,function(n,t){return r.call(null,n)}):p.some(arguments,function(n,t){return r.call(null,n)})}};p.isArrayLike=function(n){if("object"==typeof n&&null!==n){var t=h("length")(n);if("number"==typeof t&&0<=t&&t<=l)return!0}return!1},p.identity=function(n){return n},p.property=function(n){return p.isArrayLike(n)?p.deepGet(n):h(n)},p.deepGet=function(e){return function(n){var t=e.length;if(0!==t){for(var r=0;r<t&&(n=n&&n[e[r]]);r++);return r>=Math.max(t-1,0)?n:null==n?void 0:n}}},p.propertyOf=function(e){return p.isObject(e)?function(n){return p.isArrayLike(n)?(p.each(n,function(n,t,r){e=e&&e[n]}),null==e?null:e):e[n]}:o},p.matcher=p.matches=function(t){return t=p.extendOwn({},t),function(n){return p.isMatch(n,t)}},p.isMatch=function(n,t){if(null==n&&(p.isRealObject(t)&&p.isEmpty(t)||null==t))return!0;if(!p.isObject(n)&&!p.isArrayLike(n))return!1;for(var r in t)if(F(t,r)&&(!(r in n)||F(n,r)&&n[r]!==t[r]))return!1;
// if(!has(obj, prop) && obj[prop] !== attrs[prop])
// return false;
return!0};function A(n,t){return n._chain?p(t).chain():t}p.mixin=function(i){return p.each(p.functions(i),function(n,t,r){var e=p[n]=i[n];p.prototype[n]=function(){var n=[this._wrapped];return a.apply(n,arguments),A(this,e.apply(p,n))}}),p},p.chain=function(n){var t=p(n);return t._chain=!0,t}
// return this._wrapped;
,p.prototype.valueOf=p.prototype.toJSON=p.prototype.value=function(){return this._wrapped},p.prototype.toString=function(){return String(this._wrapped)},p.each=p.forEach=function(n,t,r){var e=m(t,r);if(null==n)return null;var i,u=0;if(p.isArrayLike(n))for(i=n.length,u=0;u<i;u++)e(n[u],u,n);else{var o=p.keys(n);for(i=o.length,u=0;u<i;u++)e(n[o[u]],o[u],n)}return n},p.map=p.collect=function(n,t,r){t=d(t,r);var e,i,u=[];if(p.isArrayLike(n))for(i=n.length,e=0;e<i;e++)u.push(t(n[e],e,n));else{var o=p.keys(n);for(i=o.length,e=0;e<i;e++)u.push(t(n[o[e]],o[e],n))}return u},p.every=p.all=function(n,t,r){var e,i,u;if(t=d(t,r),p.isArrayLike(n)){for(u=n.length,e=0;e<u;e++)if(!t(n[e],e,n))return!1}else for(u=(i=p.keys(n)).length,e=0;e<u;e++)if(!t(n[i[e]],i[e],n))return!1;return!0},p.some=p.any=function(n,t,r){var e,i,u;if(t=d(t,r),p.isArrayLike(n)){for(u=n.length,e=0;e<u;e++)if(t(n[e],e,n))return!0}else for(u=(i=p.keys(n)).length,e=0;e<u;e++)if(t(n[i[e]],i[e],n))return!0;return!1};function k(a){return function(n,t,r,e){var i,u=p.isArrayLike(n)?n.length:p.keys(n);if((null==n||0===n.length||u&&0===u.length)&&null!=r)return r;if(n&&(1===n.length||1===(u&&u.length)))return p.isArrayLike(n)?n[0]:n[u[0]];t=d(t,e,4),p.isArrayLike(n)?(i=0<a?0:n.length-1,null==r&&(r=n[i],i+=a)):(i=0<a?0:u.length-1,null==r&&(r=n[u[i]],i+=a));for(var o=p.isArrayLike(n)?u:u.length;0<=i&&i<o;i+=a)r=p.isArrayLike(n)?t(r,n[i],i,n):t(r,n[u[i]],u[i],n);return r}}p.reduce=p.inject=p.foldl=k(1),p.reduceRight=p.foldr=k(-1);
// var ret;
// if(!_.isArrayLike(arr)) return [];
// if(getLength(arr) === 0) return [];
// if(getLength(arr) === 1) return _.isArray(arr[0]) ? _.flatten(arr[0]) : arr;
// ret = _.reduce(arr, function(now, next) {
// // log(now, next)
// if(isShallow) {
// return _.isArray(now) ? now.concat(next) : [now].concat(next);;
// } else {
// return _.isArray(now) ? _.flatten(now).concat(_.isArray(next) ? _.flatten(next) : next)
// : [now].concat(_.isArray(next) ? _.flatten(next) : next);
// }
// });
// return ret;
var j=function(n,t,r,e){if(e=e||[],!p.isArrayLike(n)||0===n.length)return[];for(var i,u=e.length,o=0,a=n.length;o<a;o++)if(i=n[o],p.isArrayLike(i))if(t)for(var c=0,l=i.length;c<l;)e[u++]=i[c++];else j(i,t,r,e),u=e.length;else r||(e[u++]=i);return e};p.flatten=function(n,t){return j(n,t)},p.union=y(function(n){var t=[];if(p.isArrayLike(n))return n=p.filter(n,function(n){return p.isArrayLike(n)}),n=p.flatten(n,!0),p.each(n,function(n){-1===t.indexOf(n)&&t.push(n)}),t}),p.intersection=y(function(n){if(p.isArrayLike(n))return p.contains(n,null)?[]:p.reduce(n,function(t,r){return p.isArrayLike(t)?p.isArrayLike(r)?0===t.length?(p.each(r,function(n){p.contains(t,n)||t.push(n)}),t):p.filter(t,function(n){return p.contains(r,n)}):p.isArrayLike(t)?t:[]:p.isArrayLike(r)?r:[]},[])}),p.difference=y(function(n){if(p.isArrayLike(n))return p.contains(n,null)?[]:p.reduce(n,function(t,r){return p.isArrayLike(t)?p.isArrayLike(r)?0===t.length?(p.each(r,function(n){p.contains(t,n)||t.push(n)}),t):p.filter(t,function(n){return!p.contains(r,n)}):p.isArrayLike(t)?t:[]:p.isArrayLike(r)?r:[]},[])});function x(n){if(!p.isArrayLike(n))return[];for(var t=[],r=p.max(n,function(n){var t=n&&n.length;return p.isNumber(t)?t:0}).length,e=0;e<n.length;e++){var i=n[e];if(p.isArrayLike(i))for(var u=0;u<r;u++)F(t,u)?t[u].push(i[u]):t[u]=[i[u]]}return t}function O(n){return n?y(x):x}p.zip=O(!0),p.unzip=O(!1),p.object=function(n,t){var r,e={};return t||(r=n),p.isArrayLike(n)?(t?(r=p.zip(n,t),p.each(r,function(n){e[n[0]]=n[1]})):p.each(r,function(n){e[n[0]]=n[1]}),e):{}},p.chunk=function(n,t){if(t<=0||null==t)return[];if(p.isArrayLike(n)){var r=[];t="number"==typeof t?Math.ceil(t):1,t=Math.min(t,n.length);for(var e=0;e<n.length&&0<=e;e+=t)r.push(n.slice(e,e+t));return r}};function w(u){return function(n,t,r){if(!p.isArrayLike(n))return-1;t=d(t,r);for(var e=n.length,i=-1===u?Math.max(e-1,0):0;i<e&&0<=i&&!t(n[i],i,n);i+=u);return i===e?-1:i}}p.findIndex=w(1),p.findLastIndex=w(-1);function L(u,o,a){return function(n,t,r){if(!p.isArrayLike(n))return-1;var e=_(n),i=0;if(p.isNumber(r))0<=u?i=0<=r?r:Math.max(e+r,i):e=0<=r?Math.min(r+1,e):r+e+1;else if(a&&r&&e)return n[i=a(n,t)]===t?i:-1;if(t!=t)return 0<=(r=o(c.call(n,i,e),p.isNaN))?r+i:-1;for(i=0<=u?i:e-1;0<=i&&i<e;i+=u)if(t===n[i])return i;return-1}}p.sortedIndex=function(n,t,r,e){for(var i=(r=d(r,e))(t),u=0,o=n.length;u<o;){var a=Math.floor((u+o)/2);r(n[a])<i?u=a+1:o=a}return u},p.indexOf=L(1,p.findIndex,p.sortedIndex),p.lastIndexOf=L(-1,p.findLastIndex),p.range=function(n,t,r){p.isNumber(t)||(t=n||0,n=0),r=r||(t<n?-1:1);for(var e=[],i=n;t<n?t<i&&i<=n:i<t&&n<=i;i+=r)e.push(i);return e},p.bind=y(function(t,r,e){if(!p.isFunction(t))throw new TypeError("must bind to a function");p.isArray(e)||(e=[],r=r&&r[0]);var i=y(function(n){return this instanceof i?t.apply(this,e.concat(n)):t.apply(r,e.concat(n))});return i.prototype=t.prototype,i}),p.bindAll=y(function(t,n){if(!p.isArray(n)||0===n.length)throw new Error("bingAll must need a function");p.each(n,function(n){if(p.isUndefined(t[n]))throw new TypeError("the given key is undefined");if(!p.isFunction(t[n]))throw new TypeError("the given key is not a function");"function"==typeof t[n]&&(t[n]=p.bind(t[n],t))})}),p.partial=y(function(n,t){p.isArray(t)||(t=[],n=n&&n[0]);var r=y(function(r){var e=p.clone(t);return p.each(e,function(n,t){n===p.partial.placeholder&&(0!==r.length?e.splice(t,1,r.shift()):e.splice(t,1,void 0))}),n.apply(this,e.concat(r))});return r.prototype=n.prototype,r}),(p.partial.placeholder=p).memoize=function(r,e){e=d(e);var i=y(function(n){var t=e(n.join(""));return F(i.cache,t)?i.cache[t]:i.cache[t]=r.apply(null,n)});return i.cache={},i},p.delay=y(function(n,t,r){return p.isUndefined(r)&&(r=[],t=(t=t&&t[0])||0),setTimeout(function(){return n.apply(null,r)},t)}),p.defer=y(function(n,t){p.isUndefined(t)&&(t=[],n=n&&n[0]),setTimeout(function(){n.apply(null,t)},1)});function N(o,a){return y(function(u,n){return a||(u=Object(u)),null==u||void 0===u||(p.isArray(n)||null==n||(n=[n]),p.each(n,function(n,t,r){var e,i=o(n);for(t=0;i.length,e=i[t];t++)!a&&F(u,e)||(u[e]=n[e])})),u})}
// var length = arguments.length;
// if(length < 2 || target == null) return target;
// var deep = 'boolean' === typeof arguments[1] ? arguments[1] : 'nope';
// var i = 'nope' === deep ? 1 : 2;
// deep = 'nope' === deep ? false : deep;
// for(; i < length; i++) {
// for(var prop in arguments[i]) {
// if (has(arguments[i], prop) && (!target[prop] || deep)) {
// target[prop] = arguments[i][prop];
// }
// }
// }
// return target;
p.functions=p.methods=function(n){var t=[];for(var r in n)p.isFunction(n[r])&&t.push(r);return t.sort()},p.isObjectTypeFn=function(t){return function(n){return f.call(n)==="[object "+t+"]"}}
// 'Number', 'Date', 'Symbol',
// 'RegExp', 'Error', 'Map',
// 'WeakMap', 'Set', 'WeakSet'], function (params) {
// _['isArgs' + params] = _.wrapperByArgsNumber(_.isObjectTypeFn(params), true);
,p.each(["Arguments","Function","String","Number","Date","Symbol","RegExp","Error","Map","WeakMap","Set","WeakSet"],function(n){p["is"+n]=p.isObjectTypeFn(n)}),p.isRealObject=function(n){return"object"==typeof n&&"[object Object]"==f.call(n)},p.isObject=function(n){return("object"==typeof n||"function"==typeof n)&&null!=n},p.isArray=function(n){return r&&r(n)||"[object Array]"==f.call(n)},p.isObjectLike=function(n){return"object"==typeof n&&null!==n};function E(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return!1;if(n!=n)return t!=t;var i=typeof n;return("function"==i||"object"==i||"object"==typeof t)&&M(n,t,r,e)}var S=void 0!==Symbol.prototype?Symbol.prototype:null,M=function(n,t,r,e){n instanceof p&&(n=n._wrapped),t instanceof p&&(t=t._wrapped);var i=f.call(n);if(i!==f.call(t))return!1;switch(i){case"[object RegExp]":case"[object String]":return""+n==""+t;case"[object Number]":return+n!=+n?+t!=+t:0==+n?1/+n==1/+t:+n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object Symbol]":return S.valueOf.call(n)===S.valueOf.call(t)}var u="[object Array]"===i;if(!u){if("object"!=typeof n||"object"!=typeof t)return!1;var o=n.constructor,a=t.constructor;if(o!==a&&!(p.isFunction(o)&&o instanceof o&&p.isFunction(a)&&a instanceof a)&&"constructor"in n&&"constructor"in t)return!1}e=e||[];for(var c=(r=r||[]).length;c--;)if(r[c]===n)return e[c]===t;if(r.push(n),e.push(t),u){if((c=n.length)!==t.length)return!1;for(;c--;)if(!E(n[c],t[c],r,e))return!1}else{var l,s=p.keys(n);if((c=s.length)!==p.keys(t).length)return!1;for(;c--;)if(l=s[c],!F(t,l)||!E(n[l],t[l],r,e))return!1}return r.pop(),e.pop(),!0};p.isDeepEqual=p.isEqual=function(n,t){return n===t&&0!==n||E(n,t)};var F=function(n,t){if(null==n)return!1;if(p.isArrayLike(t)){for(var r=t.length,e=0;e<r;e++)if(!i.call(n,t[e])||null==(n=n[t[e]]))return!1;return!0}return i.call(n,t)};p.has=F,p.isEmpty=function(n){if(null==n)return!0;if(p.isArrayLike(n)){for(var t in n)if(F(n,t)&&"length"!==t)return!1;return 0===n.length}if(p.isObject(n)){for(var t in n)if(F(n,t))return!1;return!0}return p.isString(n)?0===n.length:p.isRegExp(n)?"(?:)"===n.source:void 0},p.isElement=function(n){return"object"==typeof HTMLElement?n instanceof HTMLElement:p.isObjectLike(n)&&1===n.nodeType&&"string"==typeof n.nodeName},p.isNaN=function(n){return isNaN?p.isNumber(n)&&isNaN(n):n!=n},p.isFinite=function(n){return!p.isSymbol(n)&&isFinite(n)&&!isNaN(parseFloat(n))},p.isBoolean=function(n){return"boolean"==typeof n||p.isObjectTypeFn("Boolean")(n)},p.isNull=function(n){return null===n},p.isUndefined=function(n){return void 0===n},p.keys=p.objects=function(n){if(null==n||p.isString(n))return[];var t=Object.keys;if(t)return t(n);var r=[];for(var e in n)F(n,e)&&r.push(e);return r},p.allKeys=p.allObjects=function(n){if(null==n||p.isString(n))return[];var t=[];for(var r in n)t.push(r);return t},p.extend=N(p.allKeys,!0),p.extendOwn=p.assign=N(p.keys,!0),p.pick=y(function(e,n){var i,t=p.keys(e),u=Object.create(null);return null==e||("function"==typeof(n&&n[0])?(i=d(n[0],n[1]),p.each(t,function(n,t,r){i(e[n],n,e)&&(u[n]=e[n])})):(n=p.flatten(n),p.each(n,function(n,t,r){!F(e,n)&&null==e[n]||(u[n]=e[n])}))),u}),p.omit=y(function(e,n){var i,t=p.keys(e),u=Object.create(null);if(null==e)return u;var r=p.isArrayLike(e);if("function"==typeof(n&&n[0]))i=d(n[0],n[1]),p.each(t,function(n,t,r){i(e[n],n,e)||(u[n]=e[n])});else if(n=p.flatten(n),r)for(var o in e)p.contains(n,Number(o))||(u[o]=e[o]);else for(var o in e)p.contains(n,o)||(u[o]=e[o]);
// if(!_.contains(keys, key)) {
// result[key] = obj[key];
// }
return u}),p.defaults=N(p.keys,!1),p.clone=function(n){return p.isRealObject(n)?p.extend({},n):p.isArray(n)?n.slice():n},p.tap=function(n,t){return t=d(t),(p.isObject(n)||p.isArrayLike(n)||null!=n)&&t(n),n},p.values=function(t){var n=p.keys(t);return 0===n.length?[]:p.map(n,function(n){return t[n]})},p.mapObject=function(e,i,n){i=d(i,n);var u=Object.create(null),t=p.keys(e);return p.each(t,function(n,t,r){u[n]=i(e[n],n,e)}),u},p.pairs=function(r){var e=[],n=p.keys(r);return 0===n.length||p.each(n,function(n,t){e.push([n,r[n]])}),e},p.invert=function(r){var e=Object.create(null),n=p.keys(r);return 0===n.length||p.each(n,function(n,t){e[r[n]]=n}),e},p.create=function(n,r){if(!p.isObject(n)&&!p.isArrayLike(n))return Object.create(null);var e=Object.create(n||null),t=p.keys(r);return 0===t.length||p.each(t,function(n,t){e[n]=r[n]}),e},p.find=p.detect=function(n,t,r){var e,i;if(t=d(t,r),p.isArray(n)){for(i=n.length,e=0;e<i;e++)if(t(n[e],e,n))return n[e]}else{var u=p.keys(n);for(i=u.length,e=0;e<i;e++)if(t(n[u[e]],u[e],n))return n[u[e]]}},p.filter=p.select=function(n,t,r){var e,i,u;if(t=d(t,r),p.isArrayLike(n))for(e=[],u=n.length,i=0;i<u;i++)t(n[i],i,n)&&e.push(n[i]);else{e=[];var o=p.keys(n);for(u=o.length,i=0;i<u;i++)t(n[o[i]],o[i],n)&&e.push(n[o[i]])}return null==e?[]:e};function T(n,t,r){for(var e,i=0;i<r.length;i++)if(e=r[i],!F(n,e)||n[e]!==t[e])return!1;return!0}p.findWhere=function(n,t){var r,e=p.keys(t);if(p.isArray(n)){for(r=0;r<n.length;r++)if(T(n[r],t,e))return n[r]}else if(T(n,t,e))return n},p.where=function(n,t){var r,e=p.keys(t),i=[];if(p.isArray(n))for(r=0;r<n.length;r++)T(n[r],t,e)&&i.push(n[r]);else if(T(n,t,e))return[n];return i},p.reject=function(n,t,r){var e,i,u;if(t=d(t,r),p.isArray(n))for(e=[],u=n.length,i=0;i<u;i++)t(n[i],i,n)||e.push(n[i]);else{e={};var o=p.keys(n);for(u=o.length,i=0;i<u;i++)t(n[o[i]],o[i],n)||(e[o[i]]=n[o[i]])}return null==e?[]:e},p.contains=p.includes=p.include=function(n,t,r,e){var i;return null!=n&&("number"==typeof r&&!e||(r=0),!!(p.isArrayLike(n)&&(r=0<=r?Math.min(r,Math.max(n.length-1,0)):Math.max(n.length+r,0))<=p.indexOf(n,t,r))||!!(p.isRealObject(n)&&(i=p.values(n),(r=0<=r?Math.min(r,Math.max(i.length-1,0)):Math.max(n.length+r,0))<=p.indexOf(i,t,r))))},p.without=y(function(n,t){return null==t&&(t=[t]),p.filter(n,function(n){return!p.contains(t,n)})}),p.uniq=p.unique=function(n,t,r,e){if(!p.isArrayLike(n))return[];p.isBoolean(t)||(e=r,r=t,t=!1),null!=r&&(r=d(r,e));for(var i=[],u=[],o=0;o<n.length;o++){var a=n[o],c=r?r(a,o,n):a;t&&!r?(o&&i===c||u.push(a),i=c):r?p.contains(i,c)||(u.push(a),i.push(c)):p.contains(u,a)||u.push(a)}return u},p.invoke=y(function(n,e,i){var u,o,a=p.isArray(n)?[]:{};return p.isArray(i)||(e=e[0]),p.each(n,function(n,t,r){if("function"==typeof e)a[t]=e.apply(n,i);else if(p.isArray(e)){if("function"==typeof(u=p.deepGet(e)(n)))o=p.deepGet(e.slice(0,-1))(n)||n,a[t]=u.apply(o,i);else if(null==u)return a.push(u)}else if("function"==typeof n[e]?a[t]=n[e].apply(n,i):null==n[e]&&(a[t]=n[e]),"function"!=typeof n[e]&&null!=n[e])throw new TypeError("non-functions")}),a}),p.pluck=function(n,e){var i=[];return p.isArray(n)&&p.each(n,function(n,t,r){p.isObject(n)&&(e in n?i.push(n[e]):i.push(void 0))}),i},p.max=function(n,e,t){var i,u,o=-1/0;return p.isEmpty(n)?o:(e=p.isUndefined(e)?d():t&&t[e]==n?d():d(e,t),p.each(n,function(n,t,r){u=e(n,t,r),u=p.isString(u)?Number(e(n,t,r)):u,null==i&&(!p.isNaN(u)&&p.isNumber(u)||p.isDate(u))&&(i=n),o<u&&(!p.isNaN(u)&&p.isNumber(u)||p.isDate(u))&&(o=u,i=n)}),i||o)},p.min=function(n,e,t){var i,u,o=1/0;return p.isEmpty(n)?o:(e=p.isUndefined(e)?d():t&&t[e]==n?d():d(e,t),p.each(n,function(n,t,r){u=e(n,t,r),u=p.isString(u)?Number(e(n,t,r)):u,null==i&&(!p.isNaN(u)&&p.isNumber(u)||p.isDate(u))&&(i=n),u<o&&(!p.isNaN(u)&&p.isNumber(u)||p.isDate(u))&&(o=u,i=n)}),i||o)},p.sortBy=function(n,e,t){var i=0;return e=d(e,t),p.pluck(p.map(n,function(n,t,r){return{value:n,index:i++,criteria:e(n,t,r)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(e<r||null==r)return 1;if(r<e||null==e)return-1}return n.index-t.index}),"value")};function R(o){return function(n,e,t){var i,u={};return e=d(e,t),p.each(n,function(n,t,r){i=e(n,t,r),o(i,u,n)}),u}}p.groupBy=R(function(n,t,r){F(t,String(n))?t[n].push(r):t[n]=[r]}),p.indexBy=R(function(n,t,r){t[n]=r}),p.countBy=R(function(n,t,r){F(t,String(n))?t[n]++:t[n]=1}),p.sample=function(n,t,r){if(null==t||r)return p.isArrayLike(n)&&!p.isObject(n)||(n=p.values(n)),n[p.random(n.length)];n=!p.isArrayLike(n)||p.isObject(n)?p.values(n):p.clone(n);var e,i,u=p.isArray(n)?n.length:p.values(n).length;if(u<=1)return n;t=Math.max(Math.min(t,u),0);for(var o=0;o<u;o++)e=p.random(o,u-1),i=n[o],n[o]=n[e],n[e]=i;return c.call(n,0,t)},p.shuffle=function(n){return p.sample(n,1/0)},p.findKey=function(n,t,r){t=d(t,r);var e=p.keys(n);if(0!==e.length)for(var i=0;i<e.length;i++)if(t(n[e[i]],e[i],n))return e[i]};var q=/[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;p.toArray=function(n){return p.isObject(n)?p.values(n):p.isArray(n)?p.clone(n):p.isString(n)?n.match(q)||[]:p.isArrayLike(n)?c.call(n,0):[n]},p.size=function(n){return p.isString(n)?_(n)||0:p.isObject(n)&&!p.isArrayLike(n)?p.values(n).length:p.isArrayLike(n)?n.length:0},p.partition=function(e,i,n){var u,t;return i=d(i,n),p.isRealObject(e)?(u=[[],[]],t=p.keys(e),p.each(t,function(n,t,r){i(e[n],n,e)?u[0].push(e[n]):u[1].push(e[n])}),u):p.isArrayLike(e)?(u=[[],[]],e=p.clone(e),p.each(e,function(n,t,r){i(n,t,r)?u[0].push(n):u[1].push(n)}),u):[[],[]]},p.compact=function(n){return p.partition(n,p.negate(Boolean))[1]},p.first=p.head=p.take=function(n,t,r){return!p.isArrayLike(n)||n.length<1?p.isNumber(t)?[]:void 0:!p.isNumber(t)||r?n[0]:p.initial(n,n.length-t)},p.initial=function(n,t,r){return!p.isArrayLike(n)||n.length<1?[]:c.call(n,0,Math.max(0,Math.min(n.length-(!p.isNumber(t)||r?1:t),n.length)))},p.last=function(n,t,r){return!p.isArrayLike(n)||n.length<1?p.isNumber(t)?[]:void 0:!p.isNumber(t)||r?n[n.length-1]:p.rest(n,n.length-t)},p.rest=p.drop=p.tail=function(n,t,r){return!p.isArrayLike(n)||n.length<1?[]:c.call(n,Math.max(!p.isNumber(t)||r?1:t,0),n.length)},p.debounce=function(r,e,i){var u,o,a=null;i=i||!1;function n(){a&&clearTimeout(a);var n=this,t=arguments;return!1!==i?(u=!a,a=setTimeout(function(){a=null},e),u&&(o=r.apply(n,t))):a=setTimeout(function(){a=null,o=r.apply(n,t)},e),o}return n.reset=function(n){!1},n.cancel=function(){clearTimeout(a),a=null},n},p.throttle=function(r,e,i){function n(){var n=p.now();l||!1!==i.leading||(l=n);var t=e-(n-l);return o=this,a=arguments,t<=0||e<t?(u&&(clearTimeout(u),u=null),l=n,c=r.apply(o,a),u||(o=a=null)):u||!1===i.trailing||(u=setTimeout(function(){l=!(u=null)===i.leading?0:p.now(),c=r.apply(o,a),u||(o=a=null)},t)),c}var u,o,a,c,l=0;i=i||{leading:!0,trailing:!0};return n.cancel=function(){clearTimeout(u),l=0,u=o=a=null},n.reset=function(n){l=0},n},p.timeChunk=function(n,t,r,e,i){if(p.isArray(n)||p.isObject(n)){r=Math.max(1,r||8),i=i||200,t=d(t,e);var u=0,o=p.isArray(n)?n.length:p.keys(n).length;n=p.clone(n),list=p.isArray(n)?n:p.keys(n);var a,c,l,s=Math.max(1,r);return c=p.isArray(n)?function(){for(;u<s&&u<o;u++)t(list[u],u,list);u=s,s=Math.min(o,s+r)}:function(){for(;u<s&&u<o;u++)t(n[list[u]],list[u],n);u=s,s=Math.min(o,s+r)},(l=function(){g(u,s,o),c(),a=setTimeout(function(){l(),o===u&&(clearTimeout(a),a=null)},i)}).reset=function(n){p.isNaN(Number(n))||(r=Number(n)||r),s=Math.max(1,r)},l}},p.once=function(t){var r,e=0;return function(){var n=arguments;return e++,t&&e<=1&&(r=t.apply(this,n),t=null),r}},p.after=function(t,r){var e,i=0;return p.isNumber(t)?(t=t||1,function(){var n=arguments;return++i===t&&r&&(e=r.apply(this,n),r=null),e}):o},p.before=function(t,r){var e,i=0;return p.isNumber(t)?(t=t||1,function(){var n=arguments;return++i<t&&r?e=r.apply(this,n):r=null,e}):o},p.wrap=function(t,r){return p.isArgsFunction(t,r)?y(function(n){return n.unshift(t),r.apply(this,n)}):o},p.negateArgsType=function(r){return p.wrapperByArgsNumber(function(t){if(p.isFunction(r))try{return void 0!==t&&t.constructor===r}catch(n){return null==t}try{r=r.prototype.constructor}catch(n){r=void 0}return void 0!==r?t.prototype.constructor===r:t==r},!0)},p.negateType=function(r){return function(t){if(p.isFunction(r))try{return void 0!==t&&t.constructor===r}catch(n){return null==t}try{r=r.prototype.constructor}catch(n){r=void 0}return void 0!==r?t.prototype.constructor===r:t==r}},p.negate=function(n){return function(){return!n.apply(this,arguments)}},p.restArguments=y,p.compose=p.restArguments(function(e){return p.restArguments(function(n){var t;0<=(r=e.length-1)&&(t=e[r].apply(this,n));for(var r=e.length-2;0<=r;r--)t=e[r].call(this,t);return t})}),p.noConflict=function(){return u._=n,this},p.constant=function(n){var t=n;return function(){return t}},p.times=function(n,t,r){var e=[];t=d(t,r);for(var i=0;i<n;i++)e.push(t(i));return e},p.random=function(n,t){return void 0===t&&(t=n||0,n=0),Math.floor(Math.random()*Math.floor(t-n))};var B=0;p.uniqueId=function(n){return(n||"")+B++};function D(t){function r(n){return t[n]}var n="(?:"+p.keys(t).join("|")+")",e=new RegExp(n),i=new RegExp(n,"g");return function(n){return n=n?""+n:"",e.test(n)?n.replace(i,r):n}}var C={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},I=p.invert(C);p.escape=D(C),p.unescape=D(I),p.result=function(n,t,r){if(null==n)return"function"==typeof r?r():r;var e,i,u,o;if(p.isArrayLike(t)){for(u=t.length,e=n&&n[t[0]],o=n&&n[t[0]],i=1;i<u;i++)e="function"==typeof e?e()&&e()[t[i]]:e&&e[t[i]],i!==u-1&&(o="function"==typeof o?o.apply(n)&&o.apply(n)[t[i]]:o&&o[t[i]]);o="function"==typeof o?o.apply(n):o}else e=n&&n[t],o=n;return void 0!==e?"function"==typeof e?e.call(o):e:"function"==typeof r?r.call(o||n):r},p.now=Date.now||function(){return(new Date).getTime()},p.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};function U(n){return"\\"+z[n]}var P=/(.)^/,z={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},G=new RegExp(/\\|'|\r|\n|\u2028|\u2029/,"g");p.template=function(u,n,t){!n&&t&&(n=t),n=p.defaults({},n,p.templateSettings);var r,o="__source+='",a=0,e=new RegExp([(n.escape||P).source,(n.interpolate||P).source,(n.evaluate||P).source,"$"].join("|"),"g");u.replace(e,function(n,t,r,e,i){return o+=u.slice(a,i).replace(G,U),a=i+n.length,
// source += "';\n" + evaluate + "\n__source+='";
// log('evaluate', source)
// source += "'+\n((__text=(" + interpolate + "))==null?'':__text)+\n'";
// log('interpolate', source)
// // why not directly use _.escape in the function ?
// // because it will be a calculator text to escape
// // source += "'" + escape ? _.escape(escape) : '' + "'"
// source += "'+\n((__text=(" + escape + "))==null?'':_.escape(__text))+\n";
// log('escape', source)
t?o+="'+\n((__text=("+t+"))==null?'':_.escape(__text))+\n'":r?o+="'+\n((__text=("+r+"))==null?'':__text)+\n'":e&&(o+="';\n"+e+"\n__source+='"),n}),o+="';\n",n.variable||(o="with(obj||{}){\n"+o+"}\n"),o="var __text, __source='',__j=Array.prototype.join,"+"print=function(){__source+=__j.call(arguments, '');};\n"+o+"return __source;\n";try{r=new Function(n.variable||"obj","_",o)}catch(n){throw n.source=o,n}function i(n){return r.call(this,n,p)}var c=n.variable||"obj";return i.source="function("+c+") {\n"+o+"}",i},p.each(["pop","push","reverse","shift","sort","splice","unshift"],function(n,t,r){p.prototype[n]=function(){return e[n].apply(this._wrapped,arguments),"shift"!==n&&"shift"!==n||0!==this._wrapped.length||delete this._wrapped[0],A(this,this._wrapped)}}),p.each(["concat","join","slice"],function(n,t,r){p.prototype[n]=function(){return A(this,e[n].apply(this._wrapped,arguments))}}),p.onceLog=y(function(n){v||(p.each(n,function(n,t,r){console.log("onceLog: 第"+(t+1)+"个参数: ",n)}),v=!0,setTimeout(function(){v=!1},0))}),p.eqLog=function(n,t,r){if(n&&Array.isArray(n)&&(0===n.length||n.length%2==1))throw new Error("eqLog function arguments must be an array and first one length must be double");for(var e=0;e<n.length;e+=2)if(n[e]!==n[e+1])return null;p.each(t,function(n,t,r){console.log("eqLog: 第"+(t+1)+"个参数: ",n)}),r&&p.each(r,function(n){"function"==typeof n&&n()})},p.countLog=function(){return y(function(n){})};var W=Symbol();p.proxy=function(n,i,u,o,a){var t,r,e=new WeakSet;for(var c in u=d(u,o),p.isArray(a)||(a=p.isUndefined(a)?[]:[a]),p.isArray(i)||(i=p.isString(i)?p.map(i.split(" "),function(n){return new RegExp(n)}):[""]),Object.prototype.hasOwnProperty.call(n,W)||(n[W]=!0),n)if(t=n,r=c,Object.prototype.hasOwnProperty.call(t,r)&&"object"==typeof t[r]&&"[object Object]"===Object.prototype.toString.call(t[r])||!1){if(Object.prototype.hasOwnProperty.call(n[c],W)&&n[c][W])continue;n[c]=p.proxy(n[c]).proxy}var l=Proxy.revocable(n,{get:function(n,t,r){
// elseLog({ target: target, property: property, receiver: receiver, mode: 'get' })
return p.some(i,function(n){if(!p.isRegExp(n)&&p.isString(n)&&(n=new RegExp(n)),p.isRegExp(n))return n.test(t.toString())})&&(a.unshift(n,t,value,r),u.apply(o,a)),Reflect.get(n,t)},set:function(n,t,r,e){p.some(i,function(n){if(!p.isRegExp(n)&&p.isString(n)&&(n=new RegExp(n)),p.isRegExp(n))return n.test(t.toString())})&&(a.unshift(n,t,r,e),u.apply(o,a)),Reflect.set(n,t,r,e)}});return e.add(l.revoke.bind(l)),{proxy:l.proxy,revoke:function(){var t=this;p.each(e,function(n){n.apply(t)})}}};var K=p.buildTree=function(n,t,r,e){var i=(e=e||{}).children,u=e.parent,o=e.model,a={},c={};if(i=i||"children",u=u||"parent",p.isObject(n)||p.isArray(n)){for(var l in t=d(t,r),n)F(n,l)&&(a[n[l].name]=n[l]);for(var s in a)F(a,s)&&(a[s][u]&&0<a[s][u].length?p.each(a[s][u],function(n){a[n]&&!a[n][i]&&(a[n][i]={}),a[n]&&!a[n][u]?a[n]&&n!==a[s].name&&(a[n][i][a[s].name]=t(a[s])):a[n]&&n!==a[s].name&&a[n][u]&&-1==a[n][u].indexOf(a[s].name)&&(a[n][i][a[s].name]=t(a[s]))}):c[a[s].name]=a[s]);if(p.isObject(o))for(var f in F(o,utilFunctions)&&p.isArray(o.utilFunctions)||(o.utilFunctions=[]),F(o,relationClasses)&&p.isArray(o.relationClasses)||(o.relationClasses=[]),c)F(c,f)&&(null==c[f][i]||c[f][i]&&0==c[f][i].length?o.utilFunctions.push(c[f]):o.relationClasses.push(c[f]));return c}},H=[],J=Function.prototype.call.bind(),V=Function.prototype.apply.bind();p.beforeDetectEnv=function(n,t){for(var r in n=n||u,t&&(Function.prototype.call=function(n){(n=n||window).__fn=this,n!=window&&(this.__children=this.__children||[],""!==f.call(n.__proto__.constructor.name)&&-1==this.__children.indexOf(f.call(n.__proto__.constructor.name))&&f.call(n.__proto__.constructor.name)!=this.name&&this.__children.push(f.call(n.__proto__.constructor.name)),n.__proto__.constructor.__parents=n.__proto__.constructor.__parents||[],""!==f.call(this.name)&&-1==n.__proto__.constructor.__parents.indexOf(f.call(this.name))&&n.__proto__.constructor.name!=f.call(this.name)&&n.__proto__.constructor.__parents.push(f.call(this.name)));for(var t=[],r=1,e=arguments.length;r<e;r++)t.push("arguments["+r+"]");var i=new Function("args","return context.__fn(args);")(t);return delete n.__fn,i},Function.prototype.apply=function(n,t){var r;if((n=n||window).__fn=this,n!=window&&(this.__children=this.__children||[],""!==f.call(n.__proto__.constructor.name)&&-1==this.__children.indexOf(f.call(n.__proto__.constructor.name))&&f.call(n.__proto__.constructor.name)!=this.name&&this.__children.push(f.call(n.__proto__.constructor.name)),n.__proto__.constructor.__parents=n.__proto__.constructor.__parents||[],""!==f.call(this.name)&&-1!=n.__proto__.constructor.__parents.indexOf(f.call(this.name))&&n.__proto__.constructor.name!=f.call(this.name)&&n.__proto__.constructor.__parents.push(f.call(this.name))),t){for(var e=[],i=0,u=t.length;i<u;i++)e.push("arr["+i+"]");r=new Function("args","return context.__fn(args);")(e)}else r=n.__fn();return r}),n)F(n,r)&&-1===H.indexOf(r)&&H.push(f.call(r))},p.detectEnv=function(t,n){t=t||u;var r,e={classes:[],utilFunctions:[],relationClasses:[],props:{vals:[],objs:[],strs:[],nums:[],arrs:[],bools:[],nullAndUndefineds:[]}};for(var i in H.push("_typesForModel","model"),t)if(r=f.call(i),Object.prototype.hasOwnProperty.call(t,i)&&-1===H.indexOf(r)){if(null===t[i]||void 0===t[i]){e["props"]["nullAndUndefineds"].push(r);continue}switch(typeof t[i]){case"function":e["classes"].push(r);break;case"boolean":e["props"]["bools"].push(r);break;case"string":e["props"]["strs"].push(r);break;case"number":e["props"]["nums"].push(r);break;case"object":Array.isArray(t[i])?e["props"]["arrs"].push(r):e["props"]["objs"].push(r);break;default:e["props"]["vals"].push(r)}}return e.retClasses=p.map(e.classes,function(n){return{name:n,parent:t[n].__parents}}),e.rets=K(e.retClasses),n&&(Function.prototype.call=J,Function.prototype.apply=V),e},p.each(p.functions(p),function(n,t,r){!/^is/.test(n)||"isEqual"===n&&"isDeepEqual"===n||(p["isArgs"+n.slice(2)]=b(p[n],!0))}),p.mixin(p),"function"==typeof define&&define.amd&&define("underscore",[],function(){return p})}();