underscore
Advanced tools
Comparing version 1.8.3 to 1.9.0
@@ -18,18 +18,27 @@ { | ||
"main": "underscore.js", | ||
"version": "1.8.3", | ||
"version": "1.9.0", | ||
"devDependencies": { | ||
"coveralls": "^2.11.2", | ||
"docco": "*", | ||
"eslint": "0.6.x", | ||
"karma": "~0.12.31", | ||
"karma-qunit": "~0.1.4", | ||
"eslint": "1.10.x", | ||
"gzip-size-cli": "^1.0.0", | ||
"karma": "^0.13.13", | ||
"karma-qunit": "~2.0.1", | ||
"nyc": "^2.1.3", | ||
"pretty-bytes-cli": "^1.0.0", | ||
"qunit-cli": "~0.2.0", | ||
"uglify-js": "2.4.x" | ||
"qunit": "^2.6.0", | ||
"uglify-js": "3.3.21" | ||
}, | ||
"scripts": { | ||
"test": "npm run test-node && npm run lint", | ||
"coverage": "nyc npm run test-node && nyc report", | ||
"coveralls": "nyc npm run test-node && nyc report --reporter=text-lcov | coveralls", | ||
"lint": "eslint underscore.js test/*.js", | ||
"test-node": "qunit-cli test/*.js", | ||
"test-browser": "npm i karma-phantomjs-launcher && ./node_modules/karma/bin/karma start", | ||
"build": "uglifyjs underscore.js -c \"evaluate=false\" --comments \"/ .*/\" -m --source-map underscore-min.map -o underscore-min.js", | ||
"doc": "docco underscore.js" | ||
"test-browser": "npm i karma-phantomjs-launcher && karma start", | ||
"minify": "uglifyjs underscore.js -c \"evaluate=false\" --comments \"/ .*/\" -m", | ||
"build": "npm run minify -- --source-map --source-map-url \" \" -o underscore-min.js", | ||
"doc": "docco underscore.js", | ||
"weight": "npm run minify | gzip-size | pretty-bytes" | ||
}, | ||
@@ -40,5 +49,4 @@ "license": "MIT", | ||
"underscore-min.js", | ||
"underscore-min.map", | ||
"LICENSE" | ||
"underscore-min.js.map" | ||
] | ||
} |
@@ -18,2 +18,6 @@ __ | ||
For support and questions, please use | ||
[the gitter channel](https://gitter.im/jashkenas/underscore) | ||
or [stackoverflow](http://stackoverflow.com/search?q=underscore.js) | ||
Underscore is an open-sourced component of DocumentCloud: | ||
@@ -24,1 +28,3 @@ https://github.com/documentcloud | ||
https://github.com/jashkenas/underscore/contributors | ||
This project adheres to a [code of conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. |
@@ -1,6 +0,5 @@ | ||
// Underscore.js 1.8.3 | ||
// Underscore.js 1.9.0 | ||
// http://underscorejs.org | ||
// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
// (c) 2009-2018 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
// Underscore may be freely distributed under the MIT license. | ||
(function(){function n(n){function t(t,r,e,u,i,o){for(;i>=0&&o>i;i+=n){var a=u?u[i]:i;e=r(e,t[a],a,t)}return e}return function(r,e,u,i){e=b(e,i,4);var o=!k(r)&&m.keys(r),a=(o||r).length,c=n>0?0:a-1;return arguments.length<3&&(u=r[o?o[c]:c],c+=n),t(r,e,u,o,c,a)}}function t(n){return function(t,r,e){r=x(r,e);for(var u=O(t),i=n>0?0:u-1;i>=0&&u>i;i+=n)if(r(t[i],i,t))return i;return-1}}function r(n,t,r){return function(e,u,i){var o=0,a=O(e);if("number"==typeof i)n>0?o=i>=0?i:Math.max(i+a,o):a=i>=0?Math.min(i+1,a):i+a+1;else if(r&&i&&a)return i=r(e,u),e[i]===u?i:-1;if(u!==u)return i=t(l.call(e,o,a),m.isNaN),i>=0?i+o:-1;for(i=n>0?o:a-1;i>=0&&a>i;i+=n)if(e[i]===u)return i;return-1}}function e(n,t){var r=I.length,e=n.constructor,u=m.isFunction(e)&&e.prototype||a,i="constructor";for(m.has(n,i)&&!m.contains(t,i)&&t.push(i);r--;)i=I[r],i in n&&n[i]!==u[i]&&!m.contains(t,i)&&t.push(i)}var u=this,i=u._,o=Array.prototype,a=Object.prototype,c=Function.prototype,f=o.push,l=o.slice,s=a.toString,p=a.hasOwnProperty,h=Array.isArray,v=Object.keys,g=c.bind,y=Object.create,d=function(){},m=function(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=m),exports._=m):u._=m,m.VERSION="1.8.3";var b=function(n,t,r){if(t===void 0)return n;switch(null==r?3:r){case 1:return function(r){return n.call(t,r)};case 2:return function(r,e){return n.call(t,r,e)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,i){return n.call(t,r,e,u,i)}}return function(){return n.apply(t,arguments)}},x=function(n,t,r){return null==n?m.identity:m.isFunction(n)?b(n,t,r):m.isObject(n)?m.matcher(n):m.property(n)};m.iteratee=function(n,t){return x(n,t,1/0)};var _=function(n,t){return function(r){var e=arguments.length;if(2>e||null==r)return r;for(var u=1;e>u;u++)for(var i=arguments[u],o=n(i),a=o.length,c=0;a>c;c++){var f=o[c];t&&r[f]!==void 0||(r[f]=i[f])}return r}},j=function(n){if(!m.isObject(n))return{};if(y)return y(n);d.prototype=n;var t=new d;return d.prototype=null,t},w=function(n){return function(t){return null==t?void 0:t[n]}},A=Math.pow(2,53)-1,O=w("length"),k=function(n){var t=O(n);return"number"==typeof t&&t>=0&&A>=t};m.each=m.forEach=function(n,t,r){t=b(t,r);var e,u;if(k(n))for(e=0,u=n.length;u>e;e++)t(n[e],e,n);else{var i=m.keys(n);for(e=0,u=i.length;u>e;e++)t(n[i[e]],i[e],n)}return n},m.map=m.collect=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=Array(u),o=0;u>o;o++){var a=e?e[o]:o;i[o]=t(n[a],a,n)}return i},m.reduce=m.foldl=m.inject=n(1),m.reduceRight=m.foldr=n(-1),m.find=m.detect=function(n,t,r){var e;return e=k(n)?m.findIndex(n,t,r):m.findKey(n,t,r),e!==void 0&&e!==-1?n[e]:void 0},m.filter=m.select=function(n,t,r){var e=[];return t=x(t,r),m.each(n,function(n,r,u){t(n,r,u)&&e.push(n)}),e},m.reject=function(n,t,r){return m.filter(n,m.negate(x(t)),r)},m.every=m.all=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(!t(n[o],o,n))return!1}return!0},m.some=m.any=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(t(n[o],o,n))return!0}return!1},m.contains=m.includes=m.include=function(n,t,r,e){return k(n)||(n=m.values(n)),("number"!=typeof r||e)&&(r=0),m.indexOf(n,t,r)>=0},m.invoke=function(n,t){var r=l.call(arguments,2),e=m.isFunction(t);return m.map(n,function(n){var u=e?t:n[t];return null==u?u:u.apply(n,r)})},m.pluck=function(n,t){return m.map(n,m.property(t))},m.where=function(n,t){return m.filter(n,m.matcher(t))},m.findWhere=function(n,t){return m.find(n,m.matcher(t))},m.max=function(n,t,r){var e,u,i=-1/0,o=-1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],e>i&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(u>o||u===-1/0&&i===-1/0)&&(i=n,o=u)});return i},m.min=function(n,t,r){var e,u,i=1/0,o=1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],i>e&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(o>u||1/0===u&&1/0===i)&&(i=n,o=u)});return i},m.shuffle=function(n){for(var t,r=k(n)?n:m.values(n),e=r.length,u=Array(e),i=0;e>i;i++)t=m.random(0,i),t!==i&&(u[i]=u[t]),u[t]=r[i];return u},m.sample=function(n,t,r){return null==t||r?(k(n)||(n=m.values(n)),n[m.random(n.length-1)]):m.shuffle(n).slice(0,Math.max(0,t))},m.sortBy=function(n,t,r){return t=x(t,r),m.pluck(m.map(n,function(n,r,e){return{value:n,index:r,criteria:t(n,r,e)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={};return r=x(r,e),m.each(t,function(e,i){var o=r(e,i,t);n(u,e,o)}),u}};m.groupBy=F(function(n,t,r){m.has(n,r)?n[r].push(t):n[r]=[t]}),m.indexBy=F(function(n,t,r){n[r]=t}),m.countBy=F(function(n,t,r){m.has(n,r)?n[r]++:n[r]=1}),m.toArray=function(n){return n?m.isArray(n)?l.call(n):k(n)?m.map(n,m.identity):m.values(n):[]},m.size=function(n){return null==n?0:k(n)?n.length:m.keys(n).length},m.partition=function(n,t,r){t=x(t,r);var e=[],u=[];return m.each(n,function(n,r,i){(t(n,r,i)?e:u).push(n)}),[e,u]},m.first=m.head=m.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:m.initial(n,n.length-t)},m.initial=function(n,t,r){return l.call(n,0,Math.max(0,n.length-(null==t||r?1:t)))},m.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:m.rest(n,Math.max(0,n.length-t))},m.rest=m.tail=m.drop=function(n,t,r){return l.call(n,null==t||r?1:t)},m.compact=function(n){return m.filter(n,m.identity)};var S=function(n,t,r,e){for(var u=[],i=0,o=e||0,a=O(n);a>o;o++){var c=n[o];if(k(c)&&(m.isArray(c)||m.isArguments(c))){t||(c=S(c,t,r));var f=0,l=c.length;for(u.length+=l;l>f;)u[i++]=c[f++]}else r||(u[i++]=c)}return u};m.flatten=function(n,t){return S(n,t,!1)},m.without=function(n){return m.difference(n,l.call(arguments,1))},m.uniq=m.unique=function(n,t,r,e){m.isBoolean(t)||(e=r,r=t,t=!1),null!=r&&(r=x(r,e));for(var u=[],i=[],o=0,a=O(n);a>o;o++){var c=n[o],f=r?r(c,o,n):c;t?(o&&i===f||u.push(c),i=f):r?m.contains(i,f)||(i.push(f),u.push(c)):m.contains(u,c)||u.push(c)}return u},m.union=function(){return m.uniq(S(arguments,!0,!0))},m.intersection=function(n){for(var t=[],r=arguments.length,e=0,u=O(n);u>e;e++){var i=n[e];if(!m.contains(t,i)){for(var o=1;r>o&&m.contains(arguments[o],i);o++);o===r&&t.push(i)}}return t},m.difference=function(n){var t=S(arguments,!0,!0,1);return m.filter(n,function(n){return!m.contains(t,n)})},m.zip=function(){return m.unzip(arguments)},m.unzip=function(n){for(var t=n&&m.max(n,O).length||0,r=Array(t),e=0;t>e;e++)r[e]=m.pluck(n,e);return r},m.object=function(n,t){for(var r={},e=0,u=O(n);u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},m.findIndex=t(1),m.findLastIndex=t(-1),m.sortedIndex=function(n,t,r,e){r=x(r,e,1);for(var u=r(t),i=0,o=O(n);o>i;){var a=Math.floor((i+o)/2);r(n[a])<u?i=a+1:o=a}return i},m.indexOf=r(1,m.findIndex,m.sortedIndex),m.lastIndexOf=r(-1,m.findLastIndex),m.range=function(n,t,r){null==t&&(t=n||0,n=0),r=r||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=Array(e),i=0;e>i;i++,n+=r)u[i]=n;return u};var E=function(n,t,r,e,u){if(!(e instanceof t))return n.apply(r,u);var i=j(n.prototype),o=n.apply(i,u);return m.isObject(o)?o:i};m.bind=function(n,t){if(g&&n.bind===g)return g.apply(n,l.call(arguments,1));if(!m.isFunction(n))throw new TypeError("Bind must be called on a function");var r=l.call(arguments,2),e=function(){return E(n,e,t,this,r.concat(l.call(arguments)))};return e},m.partial=function(n){var t=l.call(arguments,1),r=function(){for(var e=0,u=t.length,i=Array(u),o=0;u>o;o++)i[o]=t[o]===m?arguments[e++]:t[o];for(;e<arguments.length;)i.push(arguments[e++]);return E(n,r,this,this,i)};return r},m.bindAll=function(n){var t,r,e=arguments.length;if(1>=e)throw new Error("bindAll must be passed function names");for(t=1;e>t;t++)r=arguments[t],n[r]=m.bind(n[r],n);return n},m.memoize=function(n,t){var r=function(e){var u=r.cache,i=""+(t?t.apply(this,arguments):e);return m.has(u,i)||(u[i]=n.apply(this,arguments)),u[i]};return r.cache={},r},m.delay=function(n,t){var r=l.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},m.defer=m.partial(m.delay,m,1),m.throttle=function(n,t,r){var e,u,i,o=null,a=0;r||(r={});var c=function(){a=r.leading===!1?0:m.now(),o=null,i=n.apply(e,u),o||(e=u=null)};return function(){var f=m.now();a||r.leading!==!1||(a=f);var l=t-(f-a);return e=this,u=arguments,0>=l||l>t?(o&&(clearTimeout(o),o=null),a=f,i=n.apply(e,u),o||(e=u=null)):o||r.trailing===!1||(o=setTimeout(c,l)),i}},m.debounce=function(n,t,r){var e,u,i,o,a,c=function(){var f=m.now()-o;t>f&&f>=0?e=setTimeout(c,t-f):(e=null,r||(a=n.apply(i,u),e||(i=u=null)))};return function(){i=this,u=arguments,o=m.now();var f=r&&!e;return e||(e=setTimeout(c,t)),f&&(a=n.apply(i,u),i=u=null),a}},m.wrap=function(n,t){return m.partial(t,n)},m.negate=function(n){return function(){return!n.apply(this,arguments)}},m.compose=function(){var n=arguments,t=n.length-1;return function(){for(var r=t,e=n[t].apply(this,arguments);r--;)e=n[r].call(this,e);return e}},m.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},m.before=function(n,t){var r;return function(){return--n>0&&(r=t.apply(this,arguments)),1>=n&&(t=null),r}},m.once=m.partial(m.before,2);var M=!{toString:null}.propertyIsEnumerable("toString"),I=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];m.keys=function(n){if(!m.isObject(n))return[];if(v)return v(n);var t=[];for(var r in n)m.has(n,r)&&t.push(r);return M&&e(n,t),t},m.allKeys=function(n){if(!m.isObject(n))return[];var t=[];for(var r in n)t.push(r);return M&&e(n,t),t},m.values=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},m.mapObject=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=u.length,o={},a=0;i>a;a++)e=u[a],o[e]=t(n[e],e,n);return o},m.pairs=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},m.invert=function(n){for(var t={},r=m.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},m.functions=m.methods=function(n){var t=[];for(var r in n)m.isFunction(n[r])&&t.push(r);return t.sort()},m.extend=_(m.allKeys),m.extendOwn=m.assign=_(m.keys),m.findKey=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=0,o=u.length;o>i;i++)if(e=u[i],t(n[e],e,n))return e},m.pick=function(n,t,r){var e,u,i={},o=n;if(null==o)return i;m.isFunction(t)?(u=m.allKeys(o),e=b(t,r)):(u=S(arguments,!1,!1,1),e=function(n,t,r){return t in r},o=Object(o));for(var a=0,c=u.length;c>a;a++){var f=u[a],l=o[f];e(l,f,o)&&(i[f]=l)}return i},m.omit=function(n,t,r){if(m.isFunction(t))t=m.negate(t);else{var e=m.map(S(arguments,!1,!1,1),String);t=function(n,t){return!m.contains(e,t)}}return m.pick(n,t,r)},m.defaults=_(m.allKeys,!0),m.create=function(n,t){var r=j(n);return t&&m.extendOwn(r,t),r},m.clone=function(n){return m.isObject(n)?m.isArray(n)?n.slice():m.extend({},n):n},m.tap=function(n,t){return t(n),n},m.isMatch=function(n,t){var r=m.keys(t),e=r.length;if(null==n)return!e;for(var u=Object(n),i=0;e>i;i++){var o=r[i];if(t[o]!==u[o]||!(o in u))return!1}return!0};var N=function(n,t,r,e){if(n===t)return 0!==n||1/n===1/t;if(null==n||null==t)return n===t;n instanceof m&&(n=n._wrapped),t instanceof m&&(t=t._wrapped);var u=s.call(n);if(u!==s.call(t))return!1;switch(u){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}var i="[object Array]"===u;if(!i){if("object"!=typeof n||"object"!=typeof t)return!1;var o=n.constructor,a=t.constructor;if(o!==a&&!(m.isFunction(o)&&o instanceof o&&m.isFunction(a)&&a instanceof a)&&"constructor"in n&&"constructor"in t)return!1}r=r||[],e=e||[];for(var c=r.length;c--;)if(r[c]===n)return e[c]===t;if(r.push(n),e.push(t),i){if(c=n.length,c!==t.length)return!1;for(;c--;)if(!N(n[c],t[c],r,e))return!1}else{var f,l=m.keys(n);if(c=l.length,m.keys(t).length!==c)return!1;for(;c--;)if(f=l[c],!m.has(t,f)||!N(n[f],t[f],r,e))return!1}return r.pop(),e.pop(),!0};m.isEqual=function(n,t){return N(n,t)},m.isEmpty=function(n){return null==n?!0:k(n)&&(m.isArray(n)||m.isString(n)||m.isArguments(n))?0===n.length:0===m.keys(n).length},m.isElement=function(n){return!(!n||1!==n.nodeType)},m.isArray=h||function(n){return"[object Array]"===s.call(n)},m.isObject=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},m.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(n){m["is"+n]=function(t){return s.call(t)==="[object "+n+"]"}}),m.isArguments(arguments)||(m.isArguments=function(n){return m.has(n,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(m.isFunction=function(n){return"function"==typeof n||!1}),m.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},m.isNaN=function(n){return m.isNumber(n)&&n!==+n},m.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"===s.call(n)},m.isNull=function(n){return null===n},m.isUndefined=function(n){return n===void 0},m.has=function(n,t){return null!=n&&p.call(n,t)},m.noConflict=function(){return u._=i,this},m.identity=function(n){return n},m.constant=function(n){return function(){return n}},m.noop=function(){},m.property=w,m.propertyOf=function(n){return null==n?function(){}:function(t){return n[t]}},m.matcher=m.matches=function(n){return n=m.extendOwn({},n),function(t){return m.isMatch(t,n)}},m.times=function(n,t,r){var e=Array(Math.max(0,n));t=b(t,r,1);for(var u=0;n>u;u++)e[u]=t(u);return e},m.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},m.now=Date.now||function(){return(new Date).getTime()};var B={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},T=m.invert(B),R=function(n){var t=function(t){return n[t]},r="(?:"+m.keys(n).join("|")+")",e=RegExp(r),u=RegExp(r,"g");return function(n){return n=null==n?"":""+n,e.test(n)?n.replace(u,t):n}};m.escape=R(B),m.unescape=R(T),m.result=function(n,t,r){var e=null==n?void 0:n[t];return e===void 0&&(e=r),m.isFunction(e)?e.call(n):e};var q=0;m.uniqueId=function(n){var t=++q+"";return n?n+t:t},m.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var K=/(.)^/,z={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\u2028|\u2029/g,L=function(n){return"\\"+z[n]};m.template=function(n,t,r){!t&&r&&(t=r),t=m.defaults({},t,m.templateSettings);var e=RegExp([(t.escape||K).source,(t.interpolate||K).source,(t.evaluate||K).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,o,a){return i+=n.slice(u,a).replace(D,L),u=a+t.length,r?i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":e?i+="'+\n((__t=("+e+"))==null?'':__t)+\n'":o&&(i+="';\n"+o+"\n__p+='"),t}),i+="';\n",t.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var o=new Function(t.variable||"obj","_",i)}catch(a){throw a.source=i,a}var c=function(n){return o.call(this,n,m)},f=t.variable||"obj";return c.source="function("+f+"){\n"+i+"}",c},m.chain=function(n){var t=m(n);return t._chain=!0,t};var P=function(n,t){return n._chain?m(t).chain():t};m.mixin=function(n){m.each(m.functions(n),function(t){var r=m[t]=n[t];m.prototype[t]=function(){var n=[this._wrapped];return f.apply(n,arguments),P(this,r.apply(m,n))}})},m.mixin(m),m.each(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=o[n];m.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==n&&"splice"!==n||0!==r.length||delete r[0],P(this,r)}}),m.each(["concat","join","slice"],function(n){var t=o[n];m.prototype[n]=function(){return P(this,t.apply(this._wrapped,arguments))}}),m.prototype.value=function(){return this._wrapped},m.prototype.valueOf=m.prototype.toJSON=m.prototype.value,m.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return m})}).call(this); | ||
//# sourceMappingURL=underscore-min.map | ||
!function(){var n="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||this||{},r=n._,e=Array.prototype,o=Object.prototype,s="undefined"!=typeof Symbol?Symbol.prototype:null,u=e.push,c=e.slice,p=o.toString,i=o.hasOwnProperty,t=Array.isArray,a=Object.keys,l=Object.create,f=function(){},h=function(n){return n instanceof h?n:this instanceof h?void(this._wrapped=n):new h(n)};"undefined"==typeof exports||exports.nodeType?n._=h:("undefined"!=typeof module&&!module.nodeType&&module.exports&&(exports=module.exports=h),exports._=h),h.VERSION="1.9.0";var v,y=function(u,i,n){if(void 0===i)return u;switch(null==n?3:n){case 1:return function(n){return u.call(i,n)};case 3:return function(n,r,t){return u.call(i,n,r,t)};case 4:return function(n,r,t,e){return u.call(i,n,r,t,e)}}return function(){return u.apply(i,arguments)}},d=function(n,r,t){return h.iteratee!==v?h.iteratee(n,r):null==n?h.identity:h.isFunction(n)?y(n,r,t):h.isObject(n)&&!h.isArray(n)?h.matcher(n):h.property(n)};h.iteratee=v=function(n,r){return d(n,r,1/0)};var g=function(u,i){return i=null==i?u.length-1:+i,function(){for(var n=Math.max(arguments.length-i,0),r=Array(n),t=0;t<n;t++)r[t]=arguments[t+i];switch(i){case 0:return u.call(this,r);case 1:return u.call(this,arguments[0],r);case 2:return u.call(this,arguments[0],arguments[1],r)}var e=Array(i+1);for(t=0;t<i;t++)e[t]=arguments[t];return e[i]=r,u.apply(this,e)}},m=function(n){if(!h.isObject(n))return{};if(l)return l(n);f.prototype=n;var r=new f;return f.prototype=null,r},b=function(r){return function(n){return null==n?void 0:n[r]}},j=function(n,r){for(var t=r.length,e=0;e<t;e++){if(null==n)return;n=n[r[e]]}return t?n:void 0},x=Math.pow(2,53)-1,_=b("length"),A=function(n){var r=_(n);return"number"==typeof r&&0<=r&&r<=x};h.each=h.forEach=function(n,r,t){var e,u;if(r=y(r,t),A(n))for(e=0,u=n.length;e<u;e++)r(n[e],e,n);else{var i=h.keys(n);for(e=0,u=i.length;e<u;e++)r(n[i[e]],i[e],n)}return n},h.map=h.collect=function(n,r,t){r=d(r,t);for(var e=!A(n)&&h.keys(n),u=(e||n).length,i=Array(u),o=0;o<u;o++){var a=e?e[o]:o;i[o]=r(n[a],a,n)}return i};var w=function(c){return function(n,r,t,e){var u=3<=arguments.length;return function(n,r,t,e){var u=!A(n)&&h.keys(n),i=(u||n).length,o=0<c?0:i-1;for(e||(t=n[u?u[o]:o],o+=c);0<=o&&o<i;o+=c){var a=u?u[o]:o;t=r(t,n[a],a,n)}return t}(n,y(r,e,4),t,u)}};h.reduce=h.foldl=h.inject=w(1),h.reduceRight=h.foldr=w(-1),h.find=h.detect=function(n,r,t){var e=(A(n)?h.findIndex:h.findKey)(n,r,t);if(void 0!==e&&-1!==e)return n[e]},h.filter=h.select=function(n,e,r){var u=[];return e=d(e,r),h.each(n,function(n,r,t){e(n,r,t)&&u.push(n)}),u},h.reject=function(n,r,t){return h.filter(n,h.negate(d(r)),t)},h.every=h.all=function(n,r,t){r=d(r,t);for(var e=!A(n)&&h.keys(n),u=(e||n).length,i=0;i<u;i++){var o=e?e[i]:i;if(!r(n[o],o,n))return!1}return!0},h.some=h.any=function(n,r,t){r=d(r,t);for(var e=!A(n)&&h.keys(n),u=(e||n).length,i=0;i<u;i++){var o=e?e[i]:i;if(r(n[o],o,n))return!0}return!1},h.contains=h.includes=h.include=function(n,r,t,e){return A(n)||(n=h.values(n)),("number"!=typeof t||e)&&(t=0),0<=h.indexOf(n,r,t)},h.invoke=g(function(n,t,e){var u,i;return h.isFunction(t)?i=t:h.isArray(t)&&(u=t.slice(0,-1),t=t[t.length-1]),h.map(n,function(n){var r=i;if(!r){if(u&&u.length&&(n=j(n,u)),null==n)return;r=n[t]}return null==r?r:r.apply(n,e)})}),h.pluck=function(n,r){return h.map(n,h.property(r))},h.where=function(n,r){return h.filter(n,h.matcher(r))},h.findWhere=function(n,r){return h.find(n,h.matcher(r))},h.max=function(n,e,r){var t,u,i=-1/0,o=-1/0;if(null==e||"number"==typeof e&&"object"!=typeof n[0]&&null!=n)for(var a=0,c=(n=A(n)?n:h.values(n)).length;a<c;a++)null!=(t=n[a])&&i<t&&(i=t);else e=d(e,r),h.each(n,function(n,r,t){u=e(n,r,t),(o<u||u===-1/0&&i===-1/0)&&(i=n,o=u)});return i},h.min=function(n,e,r){var t,u,i=1/0,o=1/0;if(null==e||"number"==typeof e&&"object"!=typeof n[0]&&null!=n)for(var a=0,c=(n=A(n)?n:h.values(n)).length;a<c;a++)null!=(t=n[a])&&t<i&&(i=t);else e=d(e,r),h.each(n,function(n,r,t){((u=e(n,r,t))<o||u===1/0&&i===1/0)&&(i=n,o=u)});return i},h.shuffle=function(n){return h.sample(n,1/0)},h.sample=function(n,r,t){if(null==r||t)return A(n)||(n=h.values(n)),n[h.random(n.length-1)];var e=A(n)?h.clone(n):h.values(n),u=_(e);r=Math.max(Math.min(r,u),0);for(var i=u-1,o=0;o<r;o++){var a=h.random(o,i),c=e[o];e[o]=e[a],e[a]=c}return e.slice(0,r)},h.sortBy=function(n,e,r){var u=0;return e=d(e,r),h.pluck(h.map(n,function(n,r,t){return{value:n,index:u++,criteria:e(n,r,t)}}).sort(function(n,r){var t=n.criteria,e=r.criteria;if(t!==e){if(e<t||void 0===t)return 1;if(t<e||void 0===e)return-1}return n.index-r.index}),"value")};var O=function(o,r){return function(e,u,n){var i=r?[[],[]]:{};return u=d(u,n),h.each(e,function(n,r){var t=u(n,r,e);o(i,n,t)}),i}};h.groupBy=O(function(n,r,t){h.has(n,t)?n[t].push(r):n[t]=[r]}),h.indexBy=O(function(n,r,t){n[t]=r}),h.countBy=O(function(n,r,t){h.has(n,t)?n[t]++:n[t]=1});var k=/[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;h.toArray=function(n){return n?h.isArray(n)?c.call(n):h.isString(n)?n.match(k):A(n)?h.map(n,h.identity):h.values(n):[]},h.size=function(n){return null==n?0:A(n)?n.length:h.keys(n).length},h.partition=O(function(n,r,t){n[t?0:1].push(r)},!0),h.first=h.head=h.take=function(n,r,t){if(!(null==n||n.length<1))return null==r||t?n[0]:h.initial(n,n.length-r)},h.initial=function(n,r,t){return c.call(n,0,Math.max(0,n.length-(null==r||t?1:r)))},h.last=function(n,r,t){if(!(null==n||n.length<1))return null==r||t?n[n.length-1]:h.rest(n,Math.max(0,n.length-r))},h.rest=h.tail=h.drop=function(n,r,t){return c.call(n,null==r||t?1:r)},h.compact=function(n){return h.filter(n,Boolean)};var S=function(n,r,t,e){for(var u=(e=e||[]).length,i=0,o=_(n);i<o;i++){var a=n[i];if(A(a)&&(h.isArray(a)||h.isArguments(a)))if(r)for(var c=0,l=a.length;c<l;)e[u++]=a[c++];else S(a,r,t,e),u=e.length;else t||(e[u++]=a)}return e};h.flatten=function(n,r){return S(n,r,!1)},h.without=g(function(n,r){return h.difference(n,r)}),h.uniq=h.unique=function(n,r,t,e){h.isBoolean(r)||(e=t,t=r,r=!1),null!=t&&(t=d(t,e));for(var u=[],i=[],o=0,a=_(n);o<a;o++){var c=n[o],l=t?t(c,o,n):c;r&&!t?(o&&i===l||u.push(c),i=l):t?h.contains(i,l)||(i.push(l),u.push(c)):h.contains(u,c)||u.push(c)}return u},h.union=g(function(n){return h.uniq(S(n,!0,!0))}),h.intersection=function(n){for(var r=[],t=arguments.length,e=0,u=_(n);e<u;e++){var i=n[e];if(!h.contains(r,i)){var o;for(o=1;o<t&&h.contains(arguments[o],i);o++);o===t&&r.push(i)}}return r},h.difference=g(function(n,r){return r=S(r,!0,!0),h.filter(n,function(n){return!h.contains(r,n)})}),h.unzip=function(n){for(var r=n&&h.max(n,_).length||0,t=Array(r),e=0;e<r;e++)t[e]=h.pluck(n,e);return t},h.zip=g(h.unzip),h.object=function(n,r){for(var t={},e=0,u=_(n);e<u;e++)r?t[n[e]]=r[e]:t[n[e][0]]=n[e][1];return t};var M=function(i){return function(n,r,t){r=d(r,t);for(var e=_(n),u=0<i?0:e-1;0<=u&&u<e;u+=i)if(r(n[u],u,n))return u;return-1}};h.findIndex=M(1),h.findLastIndex=M(-1),h.sortedIndex=function(n,r,t,e){for(var u=(t=d(t,e,1))(r),i=0,o=_(n);i<o;){var a=Math.floor((i+o)/2);t(n[a])<u?i=a+1:o=a}return i};var F=function(i,o,a){return function(n,r,t){var e=0,u=_(n);if("number"==typeof t)0<i?e=0<=t?t:Math.max(t+u,e):u=0<=t?Math.min(t+1,u):t+u+1;else if(a&&t&&u)return n[t=a(n,r)]===r?t:-1;if(r!=r)return 0<=(t=o(c.call(n,e,u),h.isNaN))?t+e:-1;for(t=0<i?e:u-1;0<=t&&t<u;t+=i)if(n[t]===r)return t;return-1}};h.indexOf=F(1,h.findIndex,h.sortedIndex),h.lastIndexOf=F(-1,h.findLastIndex),h.range=function(n,r,t){null==r&&(r=n||0,n=0),t||(t=r<n?-1:1);for(var e=Math.max(Math.ceil((r-n)/t),0),u=Array(e),i=0;i<e;i++,n+=t)u[i]=n;return u},h.chunk=function(n,r){if(null==r||r<1)return[];for(var t=[],e=0,u=n.length;e<u;)t.push(c.call(n,e,e+=r));return t};var E=function(n,r,t,e,u){if(!(e instanceof r))return n.apply(t,u);var i=m(n.prototype),o=n.apply(i,u);return h.isObject(o)?o:i};h.bind=g(function(r,t,e){if(!h.isFunction(r))throw new TypeError("Bind must be called on a function");var u=g(function(n){return E(r,u,t,this,e.concat(n))});return u}),h.partial=g(function(u,i){var o=h.partial.placeholder,a=function(){for(var n=0,r=i.length,t=Array(r),e=0;e<r;e++)t[e]=i[e]===o?arguments[n++]:i[e];for(;n<arguments.length;)t.push(arguments[n++]);return E(u,a,this,this,t)};return a}),(h.partial.placeholder=h).bindAll=g(function(n,r){var t=(r=S(r,!1,!1)).length;if(t<1)throw new Error("bindAll must be passed function names");for(;t--;){var e=r[t];n[e]=h.bind(n[e],n)}}),h.memoize=function(e,u){var i=function(n){var r=i.cache,t=""+(u?u.apply(this,arguments):n);return h.has(r,t)||(r[t]=e.apply(this,arguments)),r[t]};return i.cache={},i},h.delay=g(function(n,r,t){return setTimeout(function(){return n.apply(null,t)},r)}),h.defer=h.partial(h.delay,h,1),h.throttle=function(t,e,u){var i,o,a,c,l=0;u||(u={});var f=function(){l=!1===u.leading?0:h.now(),i=null,c=t.apply(o,a),i||(o=a=null)},n=function(){var n=h.now();l||!1!==u.leading||(l=n);var r=e-(n-l);return o=this,a=arguments,r<=0||e<r?(i&&(clearTimeout(i),i=null),l=n,c=t.apply(o,a),i||(o=a=null)):i||!1===u.trailing||(i=setTimeout(f,r)),c};return n.cancel=function(){clearTimeout(i),l=0,i=o=a=null},n},h.debounce=function(t,e,u){var i,o,a=function(n,r){i=null,r&&(o=t.apply(n,r))},n=g(function(n){if(i&&clearTimeout(i),u){var r=!i;i=setTimeout(a,e),r&&(o=t.apply(this,n))}else i=h.delay(a,e,this,n);return o});return n.cancel=function(){clearTimeout(i),i=null},n},h.wrap=function(n,r){return h.partial(r,n)},h.negate=function(n){return function(){return!n.apply(this,arguments)}},h.compose=function(){var t=arguments,e=t.length-1;return function(){for(var n=e,r=t[e].apply(this,arguments);n--;)r=t[n].call(this,r);return r}},h.after=function(n,r){return function(){if(--n<1)return r.apply(this,arguments)}},h.before=function(n,r){var t;return function(){return 0<--n&&(t=r.apply(this,arguments)),n<=1&&(r=null),t}},h.once=h.partial(h.before,2),h.restArguments=g;var N=!{toString:null}.propertyIsEnumerable("toString"),I=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],T=function(n,r){var t=I.length,e=n.constructor,u=h.isFunction(e)&&e.prototype||o,i="constructor";for(h.has(n,i)&&!h.contains(r,i)&&r.push(i);t--;)(i=I[t])in n&&n[i]!==u[i]&&!h.contains(r,i)&&r.push(i)};h.keys=function(n){if(!h.isObject(n))return[];if(a)return a(n);var r=[];for(var t in n)h.has(n,t)&&r.push(t);return N&&T(n,r),r},h.allKeys=function(n){if(!h.isObject(n))return[];var r=[];for(var t in n)r.push(t);return N&&T(n,r),r},h.values=function(n){for(var r=h.keys(n),t=r.length,e=Array(t),u=0;u<t;u++)e[u]=n[r[u]];return e},h.mapObject=function(n,r,t){r=d(r,t);for(var e=h.keys(n),u=e.length,i={},o=0;o<u;o++){var a=e[o];i[a]=r(n[a],a,n)}return i},h.pairs=function(n){for(var r=h.keys(n),t=r.length,e=Array(t),u=0;u<t;u++)e[u]=[r[u],n[r[u]]];return e},h.invert=function(n){for(var r={},t=h.keys(n),e=0,u=t.length;e<u;e++)r[n[t[e]]]=t[e];return r},h.functions=h.methods=function(n){var r=[];for(var t in n)h.isFunction(n[t])&&r.push(t);return r.sort()};var B=function(c,l){return function(n){var r=arguments.length;if(l&&(n=Object(n)),r<2||null==n)return n;for(var t=1;t<r;t++)for(var e=arguments[t],u=c(e),i=u.length,o=0;o<i;o++){var a=u[o];l&&void 0!==n[a]||(n[a]=e[a])}return n}};h.extend=B(h.allKeys),h.extendOwn=h.assign=B(h.keys),h.findKey=function(n,r,t){r=d(r,t);for(var e,u=h.keys(n),i=0,o=u.length;i<o;i++)if(r(n[e=u[i]],e,n))return e};var R,q,K=function(n,r,t){return r in t};h.pick=g(function(n,r){var t={},e=r[0];if(null==n)return t;h.isFunction(e)?(1<r.length&&(e=y(e,r[1])),r=h.allKeys(n)):(e=K,r=S(r,!1,!1),n=Object(n));for(var u=0,i=r.length;u<i;u++){var o=r[u],a=n[o];e(a,o,n)&&(t[o]=a)}return t}),h.omit=g(function(n,t){var r,e=t[0];return h.isFunction(e)?(e=h.negate(e),1<t.length&&(r=t[1])):(t=h.map(S(t,!1,!1),String),e=function(n,r){return!h.contains(t,r)}),h.pick(n,e,r)}),h.defaults=B(h.allKeys,!0),h.create=function(n,r){var t=m(n);return r&&h.extendOwn(t,r),t},h.clone=function(n){return h.isObject(n)?h.isArray(n)?n.slice():h.extend({},n):n},h.tap=function(n,r){return r(n),n},h.isMatch=function(n,r){var t=h.keys(r),e=t.length;if(null==n)return!e;for(var u=Object(n),i=0;i<e;i++){var o=t[i];if(r[o]!==u[o]||!(o in u))return!1}return!0},R=function(n,r,t,e){if(n===r)return 0!==n||1/n==1/r;if(null==n||null==r)return!1;if(n!=n)return r!=r;var u=typeof n;return("function"===u||"object"===u||"object"==typeof r)&&q(n,r,t,e)},q=function(n,r,t,e){n instanceof h&&(n=n._wrapped),r instanceof h&&(r=r._wrapped);var u=p.call(n);if(u!==p.call(r))return!1;switch(u){case"[object RegExp]":case"[object String]":return""+n==""+r;case"[object Number]":return+n!=+n?+r!=+r:0==+n?1/+n==1/r:+n==+r;case"[object Date]":case"[object Boolean]":return+n==+r;case"[object Symbol]":return s.valueOf.call(n)===s.valueOf.call(r)}var i="[object Array]"===u;if(!i){if("object"!=typeof n||"object"!=typeof r)return!1;var o=n.constructor,a=r.constructor;if(o!==a&&!(h.isFunction(o)&&o instanceof o&&h.isFunction(a)&&a instanceof a)&&"constructor"in n&&"constructor"in r)return!1}e=e||[];for(var c=(t=t||[]).length;c--;)if(t[c]===n)return e[c]===r;if(t.push(n),e.push(r),i){if((c=n.length)!==r.length)return!1;for(;c--;)if(!R(n[c],r[c],t,e))return!1}else{var l,f=h.keys(n);if(c=f.length,h.keys(r).length!==c)return!1;for(;c--;)if(l=f[c],!h.has(r,l)||!R(n[l],r[l],t,e))return!1}return t.pop(),e.pop(),!0},h.isEqual=function(n,r){return R(n,r)},h.isEmpty=function(n){return null==n||(A(n)&&(h.isArray(n)||h.isString(n)||h.isArguments(n))?0===n.length:0===h.keys(n).length)},h.isElement=function(n){return!(!n||1!==n.nodeType)},h.isArray=t||function(n){return"[object Array]"===p.call(n)},h.isObject=function(n){var r=typeof n;return"function"===r||"object"===r&&!!n},h.each(["Arguments","Function","String","Number","Date","RegExp","Error","Symbol","Map","WeakMap","Set","WeakSet"],function(r){h["is"+r]=function(n){return p.call(n)==="[object "+r+"]"}}),h.isArguments(arguments)||(h.isArguments=function(n){return h.has(n,"callee")});var z=n.document&&n.document.childNodes;"function"!=typeof/./&&"object"!=typeof Int8Array&&"function"!=typeof z&&(h.isFunction=function(n){return"function"==typeof n||!1}),h.isFinite=function(n){return!h.isSymbol(n)&&isFinite(n)&&!isNaN(parseFloat(n))},h.isNaN=function(n){return h.isNumber(n)&&isNaN(n)},h.isBoolean=function(n){return!0===n||!1===n||"[object Boolean]"===p.call(n)},h.isNull=function(n){return null===n},h.isUndefined=function(n){return void 0===n},h.has=function(n,r){if(!h.isArray(r))return null!=n&&i.call(n,r);for(var t=r.length,e=0;e<t;e++){var u=r[e];if(null==n||!i.call(n,u))return!1;n=n[u]}return!!t},h.noConflict=function(){return n._=r,this},h.identity=function(n){return n},h.constant=function(n){return function(){return n}},h.noop=function(){},h.property=function(r){return h.isArray(r)?function(n){return j(n,r)}:b(r)},h.propertyOf=function(r){return null==r?function(){}:function(n){return h.isArray(n)?j(r,n):r[n]}},h.matcher=h.matches=function(r){return r=h.extendOwn({},r),function(n){return h.isMatch(n,r)}},h.times=function(n,r,t){var e=Array(Math.max(0,n));r=y(r,t,1);for(var u=0;u<n;u++)e[u]=r(u);return e},h.random=function(n,r){return null==r&&(r=n,n=0),n+Math.floor(Math.random()*(r-n+1))},h.now=Date.now||function(){return(new Date).getTime()};var D={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},L=h.invert(D),P=function(r){var t=function(n){return r[n]},n="(?:"+h.keys(r).join("|")+")",e=RegExp(n),u=RegExp(n,"g");return function(n){return n=null==n?"":""+n,e.test(n)?n.replace(u,t):n}};h.escape=P(D),h.unescape=P(L),h.result=function(n,r,t){h.isArray(r)||(r=[r]);var e=r.length;if(!e)return h.isFunction(t)?t.call(n):t;for(var u=0;u<e;u++){var i=null==n?void 0:n[r[u]];void 0===i&&(i=t,u=e),n=h.isFunction(i)?i.call(n):i}return n};var W=0;h.uniqueId=function(n){var r=++W+"";return n?n+r:r},h.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var C=/(.)^/,J={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},U=/\\|'|\r|\n|\u2028|\u2029/g,V=function(n){return"\\"+J[n]};h.template=function(i,n,r){!n&&r&&(n=r),n=h.defaults({},n,h.templateSettings);var t,e=RegExp([(n.escape||C).source,(n.interpolate||C).source,(n.evaluate||C).source].join("|")+"|$","g"),o=0,a="__p+='";i.replace(e,function(n,r,t,e,u){return a+=i.slice(o,u).replace(U,V),o=u+n.length,r?a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":t?a+="'+\n((__t=("+t+"))==null?'':__t)+\n'":e&&(a+="';\n"+e+"\n__p+='"),n}),a+="';\n",n.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{t=new Function(n.variable||"obj","_",a)}catch(n){throw n.source=a,n}var u=function(n){return t.call(this,n,h)},c=n.variable||"obj";return u.source="function("+c+"){\n"+a+"}",u},h.chain=function(n){var r=h(n);return r._chain=!0,r};var $=function(n,r){return n._chain?h(r).chain():r};h.mixin=function(t){return h.each(h.functions(t),function(n){var r=h[n]=t[n];h.prototype[n]=function(){var n=[this._wrapped];return u.apply(n,arguments),$(this,r.apply(h,n))}}),h},h.mixin(h),h.each(["pop","push","reverse","shift","sort","splice","unshift"],function(r){var t=e[r];h.prototype[r]=function(){var n=this._wrapped;return t.apply(n,arguments),"shift"!==r&&"splice"!==r||0!==n.length||delete n[0],$(this,n)}}),h.each(["concat","join","slice"],function(n){var r=e[n];h.prototype[n]=function(){return $(this,r.apply(this._wrapped,arguments))}}),h.prototype.value=function(){return this._wrapped},h.prototype.valueOf=h.prototype.toJSON=h.prototype.value,h.prototype.toString=function(){return String(this._wrapped)},"function"==typeof define&&define.amd&&define("underscore",[],function(){return h})}(); |
@@ -1,4 +0,4 @@ | ||
// Underscore.js 1.8.3 | ||
// Underscore.js 1.9.0 | ||
// http://underscorejs.org | ||
// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
// (c) 2009-2018 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
// Underscore may be freely distributed under the MIT license. | ||
@@ -11,4 +11,9 @@ | ||
// Establish the root object, `window` in the browser, or `exports` on the server. | ||
var root = this; | ||
// Establish the root object, `window` (`self`) in the browser, `global` | ||
// on the server, or `this` in some virtual machines. We use `self` | ||
// instead of `window` for `WebWorker` support. | ||
var root = typeof self == 'object' && self.self === self && self || | ||
typeof global == 'object' && global.global === global && global || | ||
this || | ||
{}; | ||
@@ -19,18 +24,16 @@ // Save the previous value of the `_` variable. | ||
// Save bytes in the minified (but not gzipped) version: | ||
var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; | ||
var ArrayProto = Array.prototype, ObjProto = Object.prototype; | ||
var SymbolProto = typeof Symbol !== 'undefined' ? Symbol.prototype : null; | ||
// Create quick reference variables for speed access to core prototypes. | ||
var | ||
push = ArrayProto.push, | ||
slice = ArrayProto.slice, | ||
toString = ObjProto.toString, | ||
hasOwnProperty = ObjProto.hasOwnProperty; | ||
var push = ArrayProto.push, | ||
slice = ArrayProto.slice, | ||
toString = ObjProto.toString, | ||
hasOwnProperty = ObjProto.hasOwnProperty; | ||
// All **ECMAScript 5** native function implementations that we hope to use | ||
// are declared here. | ||
var | ||
nativeIsArray = Array.isArray, | ||
nativeKeys = Object.keys, | ||
nativeBind = FuncProto.bind, | ||
nativeCreate = Object.create; | ||
var nativeIsArray = Array.isArray, | ||
nativeKeys = Object.keys, | ||
nativeCreate = Object.create; | ||
@@ -48,6 +51,8 @@ // Naked function reference for surrogate-prototype-swapping. | ||
// Export the Underscore object for **Node.js**, with | ||
// backwards-compatibility for the old `require()` API. If we're in | ||
// backwards-compatibility for their old module API. If we're in | ||
// the browser, add `_` as a global object. | ||
if (typeof exports !== 'undefined') { | ||
if (typeof module !== 'undefined' && module.exports) { | ||
// (`nodeType` is checked to ensure that `module` | ||
// and `exports` are not HTML elements.) | ||
if (typeof exports != 'undefined' && !exports.nodeType) { | ||
if (typeof module != 'undefined' && !module.nodeType && module.exports) { | ||
exports = module.exports = _; | ||
@@ -61,3 +66,3 @@ } | ||
// Current version. | ||
_.VERSION = '1.8.3'; | ||
_.VERSION = '1.9.0'; | ||
@@ -73,5 +78,3 @@ // Internal function that returns an efficient (for current engines) version | ||
}; | ||
case 2: return function(value, other) { | ||
return func.call(context, value, other); | ||
}; | ||
// The 2-argument case is omitted because we’re not using it. | ||
case 3: return function(value, index, collection) { | ||
@@ -89,30 +92,47 @@ return func.call(context, value, index, collection); | ||
// A mostly-internal function to generate callbacks that can be applied | ||
// to each element in a collection, returning the desired result — either | ||
// identity, an arbitrary callback, a property matcher, or a property accessor. | ||
var builtinIteratee; | ||
// An internal function to generate callbacks that can be applied to each | ||
// element in a collection, returning the desired result — either `identity`, | ||
// an arbitrary callback, a property matcher, or a property accessor. | ||
var cb = function(value, context, argCount) { | ||
if (_.iteratee !== builtinIteratee) return _.iteratee(value, context); | ||
if (value == null) return _.identity; | ||
if (_.isFunction(value)) return optimizeCb(value, context, argCount); | ||
if (_.isObject(value)) return _.matcher(value); | ||
if (_.isObject(value) && !_.isArray(value)) return _.matcher(value); | ||
return _.property(value); | ||
}; | ||
_.iteratee = function(value, context) { | ||
// External wrapper for our callback generator. Users may customize | ||
// `_.iteratee` if they want additional predicate/iteratee shorthand styles. | ||
// This abstraction hides the internal-only argCount argument. | ||
_.iteratee = builtinIteratee = function(value, context) { | ||
return cb(value, context, Infinity); | ||
}; | ||
// An internal function for creating assigner functions. | ||
var createAssigner = function(keysFunc, undefinedOnly) { | ||
return function(obj) { | ||
var length = arguments.length; | ||
if (length < 2 || obj == null) return obj; | ||
for (var index = 1; index < length; index++) { | ||
var source = arguments[index], | ||
keys = keysFunc(source), | ||
l = keys.length; | ||
for (var i = 0; i < l; i++) { | ||
var key = keys[i]; | ||
if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key]; | ||
} | ||
// Some functions take a variable number of arguments, or a few expected | ||
// arguments at the beginning and then a variable number of values to operate | ||
// on. This helper accumulates all remaining arguments past the function’s | ||
// argument length (or an explicit `startIndex`), into an array that becomes | ||
// the last argument. Similar to ES6’s "rest parameter". | ||
var restArguments = function(func, startIndex) { | ||
startIndex = startIndex == null ? func.length - 1 : +startIndex; | ||
return function() { | ||
var length = Math.max(arguments.length - startIndex, 0), | ||
rest = Array(length), | ||
index = 0; | ||
for (; index < length; index++) { | ||
rest[index] = arguments[index + startIndex]; | ||
} | ||
return obj; | ||
switch (startIndex) { | ||
case 0: return func.call(this, rest); | ||
case 1: return func.call(this, arguments[0], rest); | ||
case 2: return func.call(this, arguments[0], arguments[1], rest); | ||
} | ||
var args = Array(startIndex + 1); | ||
for (index = 0; index < startIndex; index++) { | ||
args[index] = arguments[index]; | ||
} | ||
args[startIndex] = rest; | ||
return func.apply(this, args); | ||
}; | ||
@@ -131,3 +151,3 @@ }; | ||
var property = function(key) { | ||
var shallowProperty = function(key) { | ||
return function(obj) { | ||
@@ -138,8 +158,17 @@ return obj == null ? void 0 : obj[key]; | ||
var deepGet = function(obj, path) { | ||
var length = path.length; | ||
for (var i = 0; i < length; i++) { | ||
if (obj == null) return void 0; | ||
obj = obj[path[i]]; | ||
} | ||
return length ? obj : void 0; | ||
}; | ||
// Helper for collection methods to determine whether a collection | ||
// should be iterated as an array or as an object | ||
// should be iterated as an array or as an object. | ||
// Related: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength | ||
// Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094 | ||
var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; | ||
var getLength = property('length'); | ||
var getLength = shallowProperty('length'); | ||
var isArrayLike = function(collection) { | ||
@@ -186,6 +215,13 @@ var length = getLength(collection); | ||
// Create a reducing function iterating left or right. | ||
function createReduce(dir) { | ||
// Optimized iterator function as using arguments.length | ||
// in the main function will deoptimize the, see #1991. | ||
function iterator(obj, iteratee, memo, keys, index, length) { | ||
var createReduce = function(dir) { | ||
// Wrap code that reassigns argument variables in a separate function than | ||
// the one that accesses `arguments.length` to avoid a perf hit. (#1991) | ||
var reducer = function(obj, iteratee, memo, initial) { | ||
var keys = !isArrayLike(obj) && _.keys(obj), | ||
length = (keys || obj).length, | ||
index = dir > 0 ? 0 : length - 1; | ||
if (!initial) { | ||
memo = obj[keys ? keys[index] : index]; | ||
index += dir; | ||
} | ||
for (; index >= 0 && index < length; index += dir) { | ||
@@ -196,17 +232,9 @@ var currentKey = keys ? keys[index] : index; | ||
return memo; | ||
} | ||
}; | ||
return function(obj, iteratee, memo, context) { | ||
iteratee = optimizeCb(iteratee, context, 4); | ||
var keys = !isArrayLike(obj) && _.keys(obj), | ||
length = (keys || obj).length, | ||
index = dir > 0 ? 0 : length - 1; | ||
// Determine the initial value if none is provided. | ||
if (arguments.length < 3) { | ||
memo = obj[keys ? keys[index] : index]; | ||
index += dir; | ||
} | ||
return iterator(obj, iteratee, memo, keys, index, length); | ||
var initial = arguments.length >= 3; | ||
return reducer(obj, optimizeCb(iteratee, context, 4), memo, initial); | ||
}; | ||
} | ||
}; | ||
@@ -222,8 +250,4 @@ // **Reduce** builds up a single result from a list of values, aka `inject`, | ||
_.find = _.detect = function(obj, predicate, context) { | ||
var key; | ||
if (isArrayLike(obj)) { | ||
key = _.findIndex(obj, predicate, context); | ||
} else { | ||
key = _.findKey(obj, predicate, context); | ||
} | ||
var keyFinder = isArrayLike(obj) ? _.findIndex : _.findKey; | ||
var key = keyFinder(obj, predicate, context); | ||
if (key !== void 0 && key !== -1) return obj[key]; | ||
@@ -283,10 +307,22 @@ }; | ||
// Invoke a method (with arguments) on every item in a collection. | ||
_.invoke = function(obj, method) { | ||
var args = slice.call(arguments, 2); | ||
var isFunc = _.isFunction(method); | ||
return _.map(obj, function(value) { | ||
var func = isFunc ? method : value[method]; | ||
return func == null ? func : func.apply(value, args); | ||
_.invoke = restArguments(function(obj, path, args) { | ||
var contextPath, func; | ||
if (_.isFunction(path)) { | ||
func = path; | ||
} else if (_.isArray(path)) { | ||
contextPath = path.slice(0, -1); | ||
path = path[path.length - 1]; | ||
} | ||
return _.map(obj, function(context) { | ||
var method = func; | ||
if (!method) { | ||
if (contextPath && contextPath.length) { | ||
context = deepGet(context, contextPath); | ||
} | ||
if (context == null) return void 0; | ||
method = context[path]; | ||
} | ||
return method == null ? method : method.apply(context, args); | ||
}); | ||
}; | ||
}); | ||
@@ -314,7 +350,7 @@ // Convenience version of a common use case of `map`: fetching a property. | ||
value, computed; | ||
if (iteratee == null && obj != null) { | ||
if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) { | ||
obj = isArrayLike(obj) ? obj : _.values(obj); | ||
for (var i = 0, length = obj.length; i < length; i++) { | ||
value = obj[i]; | ||
if (value > result) { | ||
if (value != null && value > result) { | ||
result = value; | ||
@@ -325,6 +361,6 @@ } | ||
iteratee = cb(iteratee, context); | ||
_.each(obj, function(value, index, list) { | ||
computed = iteratee(value, index, list); | ||
_.each(obj, function(v, index, list) { | ||
computed = iteratee(v, index, list); | ||
if (computed > lastComputed || computed === -Infinity && result === -Infinity) { | ||
result = value; | ||
result = v; | ||
lastComputed = computed; | ||
@@ -341,7 +377,7 @@ } | ||
value, computed; | ||
if (iteratee == null && obj != null) { | ||
if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) { | ||
obj = isArrayLike(obj) ? obj : _.values(obj); | ||
for (var i = 0, length = obj.length; i < length; i++) { | ||
value = obj[i]; | ||
if (value < result) { | ||
if (value != null && value < result) { | ||
result = value; | ||
@@ -352,6 +388,6 @@ } | ||
iteratee = cb(iteratee, context); | ||
_.each(obj, function(value, index, list) { | ||
computed = iteratee(value, index, list); | ||
_.each(obj, function(v, index, list) { | ||
computed = iteratee(v, index, list); | ||
if (computed < lastComputed || computed === Infinity && result === Infinity) { | ||
result = value; | ||
result = v; | ||
lastComputed = computed; | ||
@@ -364,17 +400,9 @@ } | ||
// Shuffle a collection, using the modern version of the | ||
// [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle). | ||
// Shuffle a collection. | ||
_.shuffle = function(obj) { | ||
var set = isArrayLike(obj) ? obj : _.values(obj); | ||
var length = set.length; | ||
var shuffled = Array(length); | ||
for (var index = 0, rand; index < length; index++) { | ||
rand = _.random(0, index); | ||
if (rand !== index) shuffled[index] = shuffled[rand]; | ||
shuffled[rand] = set[index]; | ||
} | ||
return shuffled; | ||
return _.sample(obj, Infinity); | ||
}; | ||
// Sample **n** random values from a collection. | ||
// Sample **n** random values from a collection using the modern version of the | ||
// [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle). | ||
// If **n** is not specified, returns a single random element. | ||
@@ -387,3 +415,13 @@ // The internal `guard` argument allows it to work with `map`. | ||
} | ||
return _.shuffle(obj).slice(0, Math.max(0, n)); | ||
var sample = isArrayLike(obj) ? _.clone(obj) : _.values(obj); | ||
var length = getLength(sample); | ||
n = Math.max(Math.min(n, length), 0); | ||
var last = length - 1; | ||
for (var index = 0; index < n; index++) { | ||
var rand = _.random(index, last); | ||
var temp = sample[index]; | ||
sample[index] = sample[rand]; | ||
sample[rand] = temp; | ||
} | ||
return sample.slice(0, n); | ||
}; | ||
@@ -393,8 +431,9 @@ | ||
_.sortBy = function(obj, iteratee, context) { | ||
var index = 0; | ||
iteratee = cb(iteratee, context); | ||
return _.pluck(_.map(obj, function(value, index, list) { | ||
return _.pluck(_.map(obj, function(value, key, list) { | ||
return { | ||
value: value, | ||
index: index, | ||
criteria: iteratee(value, index, list) | ||
index: index++, | ||
criteria: iteratee(value, key, list) | ||
}; | ||
@@ -413,5 +452,5 @@ }).sort(function(left, right) { | ||
// An internal function used for aggregate "group by" operations. | ||
var group = function(behavior) { | ||
var group = function(behavior, partition) { | ||
return function(obj, iteratee, context) { | ||
var result = {}; | ||
var result = partition ? [[], []] : {}; | ||
iteratee = cb(iteratee, context); | ||
@@ -445,2 +484,3 @@ _.each(obj, function(value, index) { | ||
var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g; | ||
// Safely create a real, live array from anything iterable. | ||
@@ -450,2 +490,6 @@ _.toArray = function(obj) { | ||
if (_.isArray(obj)) return slice.call(obj); | ||
if (_.isString(obj)) { | ||
// Keep surrogate pair characters together | ||
return obj.match(reStrSymbol); | ||
} | ||
if (isArrayLike(obj)) return _.map(obj, _.identity); | ||
@@ -463,10 +507,5 @@ return _.values(obj); | ||
// predicate, and one whose elements all do not satisfy the predicate. | ||
_.partition = function(obj, predicate, context) { | ||
predicate = cb(predicate, context); | ||
var pass = [], fail = []; | ||
_.each(obj, function(value, key, obj) { | ||
(predicate(value, key, obj) ? pass : fail).push(value); | ||
}); | ||
return [pass, fail]; | ||
}; | ||
_.partition = group(function(result, value, pass) { | ||
result[pass ? 0 : 1].push(value); | ||
}, true); | ||
@@ -480,3 +519,3 @@ // Array Functions | ||
_.first = _.head = _.take = function(array, n, guard) { | ||
if (array == null) return void 0; | ||
if (array == null || array.length < 1) return void 0; | ||
if (n == null || guard) return array[0]; | ||
@@ -496,3 +535,3 @@ return _.initial(array, array.length - n); | ||
_.last = function(array, n, guard) { | ||
if (array == null) return void 0; | ||
if (array == null || array.length < 1) return void 0; | ||
if (n == null || guard) return array[array.length - 1]; | ||
@@ -511,17 +550,19 @@ return _.rest(array, Math.max(0, array.length - n)); | ||
_.compact = function(array) { | ||
return _.filter(array, _.identity); | ||
return _.filter(array, Boolean); | ||
}; | ||
// Internal implementation of a recursive `flatten` function. | ||
var flatten = function(input, shallow, strict, startIndex) { | ||
var output = [], idx = 0; | ||
for (var i = startIndex || 0, length = getLength(input); i < length; i++) { | ||
var flatten = function(input, shallow, strict, output) { | ||
output = output || []; | ||
var idx = output.length; | ||
for (var i = 0, length = getLength(input); i < length; i++) { | ||
var value = input[i]; | ||
if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) { | ||
//flatten current level of array or arguments object | ||
if (!shallow) value = flatten(value, shallow, strict); | ||
var j = 0, len = value.length; | ||
output.length += len; | ||
while (j < len) { | ||
output[idx++] = value[j++]; | ||
// Flatten current level of array or arguments object. | ||
if (shallow) { | ||
var j = 0, len = value.length; | ||
while (j < len) output[idx++] = value[j++]; | ||
} else { | ||
flatten(value, shallow, strict, output); | ||
idx = output.length; | ||
} | ||
@@ -541,8 +582,11 @@ } else if (!strict) { | ||
// Return a version of the array that does not contain the specified value(s). | ||
_.without = function(array) { | ||
return _.difference(array, slice.call(arguments, 1)); | ||
}; | ||
_.without = restArguments(function(array, otherArrays) { | ||
return _.difference(array, otherArrays); | ||
}); | ||
// Produce a duplicate-free version of the array. If the array has already | ||
// been sorted, you have the option of using a faster algorithm. | ||
// The faster algorithm will not work with an iteratee if the iteratee | ||
// is not a one-to-one function, so providing an iteratee will disable | ||
// the faster algorithm. | ||
// Aliased as `unique`. | ||
@@ -561,3 +605,3 @@ _.uniq = _.unique = function(array, isSorted, iteratee, context) { | ||
computed = iteratee ? iteratee(value, i, array) : value; | ||
if (isSorted) { | ||
if (isSorted && !iteratee) { | ||
if (!i || seen !== computed) result.push(value); | ||
@@ -579,5 +623,5 @@ seen = computed; | ||
// the passed-in arrays. | ||
_.union = function() { | ||
return _.uniq(flatten(arguments, true, true)); | ||
}; | ||
_.union = restArguments(function(arrays) { | ||
return _.uniq(flatten(arrays, true, true)); | ||
}); | ||
@@ -592,3 +636,4 @@ // Produce an array that contains every item shared between all the | ||
if (_.contains(result, item)) continue; | ||
for (var j = 1; j < argsLength; j++) { | ||
var j; | ||
for (j = 1; j < argsLength; j++) { | ||
if (!_.contains(arguments[j], item)) break; | ||
@@ -603,17 +648,11 @@ } | ||
// Only the elements present in just the first array will remain. | ||
_.difference = function(array) { | ||
var rest = flatten(arguments, true, true, 1); | ||
_.difference = restArguments(function(array, rest) { | ||
rest = flatten(rest, true, true); | ||
return _.filter(array, function(value){ | ||
return !_.contains(rest, value); | ||
}); | ||
}; | ||
}); | ||
// Zip together multiple lists into a single array -- elements that share | ||
// an index go together. | ||
_.zip = function() { | ||
return _.unzip(arguments); | ||
}; | ||
// Complement of _.zip. Unzip accepts an array of arrays and groups | ||
// each array's elements on shared indices | ||
// each array's elements on shared indices. | ||
_.unzip = function(array) { | ||
@@ -629,5 +668,9 @@ var length = array && _.max(array, getLength).length || 0; | ||
// Zip together multiple lists into a single array -- elements that share | ||
// an index go together. | ||
_.zip = restArguments(_.unzip); | ||
// Converts lists into objects. Pass either a single array of `[key, value]` | ||
// pairs, or two parallel arrays of the same length -- one of keys, and one of | ||
// the corresponding values. | ||
// the corresponding values. Passing by pairs is the reverse of _.pairs. | ||
_.object = function(list, values) { | ||
@@ -645,4 +688,4 @@ var result = {}; | ||
// Generator function to create the findIndex and findLastIndex functions | ||
function createPredicateIndexFinder(dir) { | ||
// Generator function to create the findIndex and findLastIndex functions. | ||
var createPredicateIndexFinder = function(dir) { | ||
return function(array, predicate, context) { | ||
@@ -657,5 +700,5 @@ predicate = cb(predicate, context); | ||
}; | ||
} | ||
}; | ||
// Returns the first index on an array-like that passes a predicate test | ||
// Returns the first index on an array-like that passes a predicate test. | ||
_.findIndex = createPredicateIndexFinder(1); | ||
@@ -677,4 +720,4 @@ _.findLastIndex = createPredicateIndexFinder(-1); | ||
// Generator function to create the indexOf and lastIndexOf functions | ||
function createIndexFinder(dir, predicateFind, sortedIndex) { | ||
// Generator function to create the indexOf and lastIndexOf functions. | ||
var createIndexFinder = function(dir, predicateFind, sortedIndex) { | ||
return function(array, item, idx) { | ||
@@ -684,5 +727,5 @@ var i = 0, length = getLength(array); | ||
if (dir > 0) { | ||
i = idx >= 0 ? idx : Math.max(idx + length, i); | ||
i = idx >= 0 ? idx : Math.max(idx + length, i); | ||
} else { | ||
length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; | ||
length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; | ||
} | ||
@@ -702,3 +745,3 @@ } else if (sortedIndex && idx && length) { | ||
}; | ||
} | ||
}; | ||
@@ -720,3 +763,5 @@ // Return the position of the first occurrence of an item in an array, | ||
} | ||
step = step || 1; | ||
if (!step) { | ||
step = stop < start ? -1 : 1; | ||
} | ||
@@ -733,2 +778,14 @@ var length = Math.max(Math.ceil((stop - start) / step), 0); | ||
// Chunk a single array into multiple arrays, each containing `count` or fewer | ||
// items. | ||
_.chunk = function(array, count) { | ||
if (count == null || count < 1) return []; | ||
var result = []; | ||
var i = 0, length = array.length; | ||
while (i < length) { | ||
result.push(slice.call(array, i, i += count)); | ||
} | ||
return result; | ||
}; | ||
// Function (ahem) Functions | ||
@@ -738,3 +795,3 @@ // ------------------ | ||
// Determines whether to execute a function as a constructor | ||
// or a normal function with the provided arguments | ||
// or a normal function with the provided arguments. | ||
var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) { | ||
@@ -751,17 +808,16 @@ if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args); | ||
// available. | ||
_.bind = function(func, context) { | ||
if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); | ||
_.bind = restArguments(function(func, context, args) { | ||
if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function'); | ||
var args = slice.call(arguments, 2); | ||
var bound = function() { | ||
return executeBound(func, bound, context, this, args.concat(slice.call(arguments))); | ||
}; | ||
var bound = restArguments(function(callArgs) { | ||
return executeBound(func, bound, context, this, args.concat(callArgs)); | ||
}); | ||
return bound; | ||
}; | ||
}); | ||
// Partially apply a function by creating a version that has had some of its | ||
// arguments pre-filled, without changing its dynamic `this` context. _ acts | ||
// as a placeholder, allowing any combination of arguments to be pre-filled. | ||
_.partial = function(func) { | ||
var boundArgs = slice.call(arguments, 1); | ||
// as a placeholder by default, allowing any combination of arguments to be | ||
// pre-filled. Set `_.partial.placeholder` for a custom placeholder argument. | ||
_.partial = restArguments(function(func, boundArgs) { | ||
var placeholder = _.partial.placeholder; | ||
var bound = function() { | ||
@@ -771,3 +827,3 @@ var position = 0, length = boundArgs.length; | ||
for (var i = 0; i < length; i++) { | ||
args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i]; | ||
args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i]; | ||
} | ||
@@ -778,16 +834,18 @@ while (position < arguments.length) args.push(arguments[position++]); | ||
return bound; | ||
}; | ||
}); | ||
_.partial.placeholder = _; | ||
// Bind a number of an object's methods to that object. Remaining arguments | ||
// are the method names to be bound. Useful for ensuring that all callbacks | ||
// defined on an object belong to it. | ||
_.bindAll = function(obj) { | ||
var i, length = arguments.length, key; | ||
if (length <= 1) throw new Error('bindAll must be passed function names'); | ||
for (i = 1; i < length; i++) { | ||
key = arguments[i]; | ||
_.bindAll = restArguments(function(obj, keys) { | ||
keys = flatten(keys, false, false); | ||
var index = keys.length; | ||
if (index < 1) throw new Error('bindAll must be passed function names'); | ||
while (index--) { | ||
var key = keys[index]; | ||
obj[key] = _.bind(obj[key], obj); | ||
} | ||
return obj; | ||
}; | ||
}); | ||
@@ -808,8 +866,7 @@ // Memoize an expensive function by storing its results. | ||
// it with the arguments supplied. | ||
_.delay = function(func, wait) { | ||
var args = slice.call(arguments, 2); | ||
return setTimeout(function(){ | ||
_.delay = restArguments(function(func, wait, args) { | ||
return setTimeout(function() { | ||
return func.apply(null, args); | ||
}, wait); | ||
}; | ||
}); | ||
@@ -826,6 +883,6 @@ // Defers a function, scheduling it to run after the current call stack has | ||
_.throttle = function(func, wait, options) { | ||
var context, args, result; | ||
var timeout = null; | ||
var timeout, context, args, result; | ||
var previous = 0; | ||
if (!options) options = {}; | ||
var later = function() { | ||
@@ -837,3 +894,4 @@ previous = options.leading === false ? 0 : _.now(); | ||
}; | ||
return function() { | ||
var throttled = function() { | ||
var now = _.now(); | ||
@@ -857,2 +915,10 @@ if (!previous && options.leading === false) previous = now; | ||
}; | ||
throttled.cancel = function() { | ||
clearTimeout(timeout); | ||
previous = 0; | ||
timeout = context = args = null; | ||
}; | ||
return throttled; | ||
}; | ||
@@ -865,31 +931,28 @@ | ||
_.debounce = function(func, wait, immediate) { | ||
var timeout, args, context, timestamp, result; | ||
var timeout, result; | ||
var later = function() { | ||
var last = _.now() - timestamp; | ||
var later = function(context, args) { | ||
timeout = null; | ||
if (args) result = func.apply(context, args); | ||
}; | ||
if (last < wait && last >= 0) { | ||
timeout = setTimeout(later, wait - last); | ||
var debounced = restArguments(function(args) { | ||
if (timeout) clearTimeout(timeout); | ||
if (immediate) { | ||
var callNow = !timeout; | ||
timeout = setTimeout(later, wait); | ||
if (callNow) result = func.apply(this, args); | ||
} else { | ||
timeout = null; | ||
if (!immediate) { | ||
result = func.apply(context, args); | ||
if (!timeout) context = args = null; | ||
} | ||
timeout = _.delay(later, wait, this, args); | ||
} | ||
}; | ||
return function() { | ||
context = this; | ||
args = arguments; | ||
timestamp = _.now(); | ||
var callNow = immediate && !timeout; | ||
if (!timeout) timeout = setTimeout(later, wait); | ||
if (callNow) { | ||
result = func.apply(context, args); | ||
context = args = null; | ||
} | ||
return result; | ||
}); | ||
return result; | ||
debounced.cancel = function() { | ||
clearTimeout(timeout); | ||
timeout = null; | ||
}; | ||
return debounced; | ||
}; | ||
@@ -949,2 +1012,4 @@ | ||
_.restArguments = restArguments; | ||
// Object Functions | ||
@@ -956,8 +1021,8 @@ // ---------------- | ||
var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString', | ||
'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; | ||
'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; | ||
function collectNonEnumProps(obj, keys) { | ||
var collectNonEnumProps = function(obj, keys) { | ||
var nonEnumIdx = nonEnumerableProps.length; | ||
var constructor = obj.constructor; | ||
var proto = (_.isFunction(constructor) && constructor.prototype) || ObjProto; | ||
var proto = _.isFunction(constructor) && constructor.prototype || ObjProto; | ||
@@ -974,6 +1039,6 @@ // Constructor is a special case. | ||
} | ||
} | ||
}; | ||
// Retrieve the names of an object's own properties. | ||
// Delegates to **ECMAScript 5**'s native `Object.keys` | ||
// Delegates to **ECMAScript 5**'s native `Object.keys`. | ||
_.keys = function(obj) { | ||
@@ -1010,18 +1075,18 @@ if (!_.isObject(obj)) return []; | ||
// Returns the results of applying the iteratee to each element of the object | ||
// In contrast to _.map it returns an object | ||
// Returns the results of applying the iteratee to each element of the object. | ||
// In contrast to _.map it returns an object. | ||
_.mapObject = function(obj, iteratee, context) { | ||
iteratee = cb(iteratee, context); | ||
var keys = _.keys(obj), | ||
length = keys.length, | ||
results = {}, | ||
currentKey; | ||
for (var index = 0; index < length; index++) { | ||
currentKey = keys[index]; | ||
results[currentKey] = iteratee(obj[currentKey], currentKey, obj); | ||
} | ||
return results; | ||
var keys = _.keys(obj), | ||
length = keys.length, | ||
results = {}; | ||
for (var index = 0; index < length; index++) { | ||
var currentKey = keys[index]; | ||
results[currentKey] = iteratee(obj[currentKey], currentKey, obj); | ||
} | ||
return results; | ||
}; | ||
// Convert an object into a list of `[key, value]` pairs. | ||
// The opposite of _.object. | ||
_.pairs = function(obj) { | ||
@@ -1048,3 +1113,3 @@ var keys = _.keys(obj); | ||
// Return a sorted list of the function names available on the object. | ||
// Aliased as `methods` | ||
// Aliased as `methods`. | ||
_.functions = _.methods = function(obj) { | ||
@@ -1058,10 +1123,29 @@ var names = []; | ||
// An internal function for creating assigner functions. | ||
var createAssigner = function(keysFunc, defaults) { | ||
return function(obj) { | ||
var length = arguments.length; | ||
if (defaults) obj = Object(obj); | ||
if (length < 2 || obj == null) return obj; | ||
for (var index = 1; index < length; index++) { | ||
var source = arguments[index], | ||
keys = keysFunc(source), | ||
l = keys.length; | ||
for (var i = 0; i < l; i++) { | ||
var key = keys[i]; | ||
if (!defaults || obj[key] === void 0) obj[key] = source[key]; | ||
} | ||
} | ||
return obj; | ||
}; | ||
}; | ||
// Extend a given object with all the properties in passed-in object(s). | ||
_.extend = createAssigner(_.allKeys); | ||
// Assigns a given object with all the own properties in the passed-in object(s) | ||
// Assigns a given object with all the own properties in the passed-in object(s). | ||
// (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) | ||
_.extendOwn = _.assign = createAssigner(_.keys); | ||
// Returns the first key on an object that passes a predicate test | ||
// Returns the first key on an object that passes a predicate test. | ||
_.findKey = function(obj, predicate, context) { | ||
@@ -1076,12 +1160,17 @@ predicate = cb(predicate, context); | ||
// Internal pick helper function to determine if `obj` has key `key`. | ||
var keyInObj = function(value, key, obj) { | ||
return key in obj; | ||
}; | ||
// Return a copy of the object only containing the whitelisted properties. | ||
_.pick = function(object, oiteratee, context) { | ||
var result = {}, obj = object, iteratee, keys; | ||
_.pick = restArguments(function(obj, keys) { | ||
var result = {}, iteratee = keys[0]; | ||
if (obj == null) return result; | ||
if (_.isFunction(oiteratee)) { | ||
if (_.isFunction(iteratee)) { | ||
if (keys.length > 1) iteratee = optimizeCb(iteratee, keys[1]); | ||
keys = _.allKeys(obj); | ||
iteratee = optimizeCb(oiteratee, context); | ||
} else { | ||
keys = flatten(arguments, false, false, 1); | ||
iteratee = function(value, key, obj) { return key in obj; }; | ||
iteratee = keyInObj; | ||
keys = flatten(keys, false, false); | ||
obj = Object(obj); | ||
@@ -1095,10 +1184,12 @@ } | ||
return result; | ||
}; | ||
}); | ||
// Return a copy of the object without the blacklisted properties. | ||
_.omit = function(obj, iteratee, context) { | ||
// Return a copy of the object without the blacklisted properties. | ||
_.omit = restArguments(function(obj, keys) { | ||
var iteratee = keys[0], context; | ||
if (_.isFunction(iteratee)) { | ||
iteratee = _.negate(iteratee); | ||
if (keys.length > 1) context = keys[1]; | ||
} else { | ||
var keys = _.map(flatten(arguments, false, false, 1), String); | ||
keys = _.map(flatten(keys, false, false), String); | ||
iteratee = function(value, key) { | ||
@@ -1109,3 +1200,3 @@ return !_.contains(keys, key); | ||
return _.pick(obj, iteratee, context); | ||
}; | ||
}); | ||
@@ -1152,8 +1243,19 @@ // Fill in a given object with default properties. | ||
// Internal recursive comparison function for `isEqual`. | ||
var eq = function(a, b, aStack, bStack) { | ||
var eq, deepEq; | ||
eq = function(a, b, aStack, bStack) { | ||
// Identical objects are equal. `0 === -0`, but they aren't identical. | ||
// See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). | ||
if (a === b) return a !== 0 || 1 / a === 1 / b; | ||
// A strict comparison is necessary because `null == undefined`. | ||
if (a == null || b == null) return a === b; | ||
// `null` or `undefined` only equal to itself (strict comparison). | ||
if (a == null || b == null) return false; | ||
// `NaN`s are equivalent, but non-reflexive. | ||
if (a !== a) return b !== b; | ||
// Exhaust primitive checks | ||
var type = typeof a; | ||
if (type !== 'function' && type !== 'object' && typeof b != 'object') return false; | ||
return deepEq(a, b, aStack, bStack); | ||
}; | ||
// Internal recursive comparison function for `isEqual`. | ||
deepEq = function(a, b, aStack, bStack) { | ||
// Unwrap any wrapped objects. | ||
@@ -1175,3 +1277,3 @@ if (a instanceof _) a = a._wrapped; | ||
// `NaN`s are equivalent, but non-reflexive. | ||
// Object(NaN) is equivalent to NaN | ||
// Object(NaN) is equivalent to NaN. | ||
if (+a !== +a) return +b !== +b; | ||
@@ -1186,2 +1288,4 @@ // An `egal` comparison is performed for other numeric values. | ||
return +a === +b; | ||
case '[object Symbol]': | ||
return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b); | ||
} | ||
@@ -1277,4 +1381,4 @@ | ||
// Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError. | ||
_.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error'], function(name) { | ||
// Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError, isMap, isWeakMap, isSet, isWeakSet. | ||
_.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error', 'Symbol', 'Map', 'WeakMap', 'Set', 'WeakSet'], function(name) { | ||
_['is' + name] = function(obj) { | ||
@@ -1294,4 +1398,5 @@ return toString.call(obj) === '[object ' + name + ']'; | ||
// Optimize `isFunction` if appropriate. Work around some typeof bugs in old v8, | ||
// IE 11 (#1621), and in Safari 8 (#1929). | ||
if (typeof /./ != 'function' && typeof Int8Array != 'object') { | ||
// IE 11 (#1621), Safari 8 (#1929), and PhantomJS (#2236). | ||
var nodelist = root.document && root.document.childNodes; | ||
if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') { | ||
_.isFunction = function(obj) { | ||
@@ -1304,8 +1409,8 @@ return typeof obj == 'function' || false; | ||
_.isFinite = function(obj) { | ||
return isFinite(obj) && !isNaN(parseFloat(obj)); | ||
return !_.isSymbol(obj) && isFinite(obj) && !isNaN(parseFloat(obj)); | ||
}; | ||
// Is the given value `NaN`? (NaN is the only number which does not equal itself). | ||
// Is the given value `NaN`? | ||
_.isNaN = function(obj) { | ||
return _.isNumber(obj) && obj !== +obj; | ||
return _.isNumber(obj) && isNaN(obj); | ||
}; | ||
@@ -1330,4 +1435,15 @@ | ||
// on itself (in other words, not on a prototype). | ||
_.has = function(obj, key) { | ||
return obj != null && hasOwnProperty.call(obj, key); | ||
_.has = function(obj, path) { | ||
if (!_.isArray(path)) { | ||
return obj != null && hasOwnProperty.call(obj, path); | ||
} | ||
var length = path.length; | ||
for (var i = 0; i < length; i++) { | ||
var key = path[i]; | ||
if (obj == null || !hasOwnProperty.call(obj, key)) { | ||
return false; | ||
} | ||
obj = obj[key]; | ||
} | ||
return !!length; | ||
}; | ||
@@ -1359,8 +1475,20 @@ | ||
_.property = property; | ||
// Creates a function that, when passed an object, will traverse that object’s | ||
// properties down the given `path`, specified as an array of keys or indexes. | ||
_.property = function(path) { | ||
if (!_.isArray(path)) { | ||
return shallowProperty(path); | ||
} | ||
return function(obj) { | ||
return deepGet(obj, path); | ||
}; | ||
}; | ||
// Generates a function for a given object that returns a given property. | ||
_.propertyOf = function(obj) { | ||
return obj == null ? function(){} : function(key) { | ||
return obj[key]; | ||
if (obj == null) { | ||
return function(){}; | ||
} | ||
return function(path) { | ||
return !_.isArray(path) ? obj[path] : deepGet(obj, path); | ||
}; | ||
@@ -1400,3 +1528,3 @@ }; | ||
// List of HTML entities for escaping. | ||
// List of HTML entities for escaping. | ||
var escapeMap = { | ||
@@ -1417,3 +1545,3 @@ '&': '&', | ||
}; | ||
// Regexes for identifying a key that needs to be escaped | ||
// Regexes for identifying a key that needs to be escaped. | ||
var source = '(?:' + _.keys(map).join('|') + ')'; | ||
@@ -1430,10 +1558,20 @@ var testRegexp = RegExp(source); | ||
// If the value of the named `property` is a function then invoke it with the | ||
// `object` as context; otherwise, return it. | ||
_.result = function(object, property, fallback) { | ||
var value = object == null ? void 0 : object[property]; | ||
if (value === void 0) { | ||
value = fallback; | ||
// Traverses the children of `obj` along `path`. If a child is a function, it | ||
// is invoked with its parent as context. Returns the value of the final | ||
// child, or `fallback` if any child is undefined. | ||
_.result = function(obj, path, fallback) { | ||
if (!_.isArray(path)) path = [path]; | ||
var length = path.length; | ||
if (!length) { | ||
return _.isFunction(fallback) ? fallback.call(obj) : fallback; | ||
} | ||
return _.isFunction(value) ? value.call(object) : value; | ||
for (var i = 0; i < length; i++) { | ||
var prop = obj == null ? void 0 : obj[path[i]]; | ||
if (prop === void 0) { | ||
prop = fallback; | ||
i = length; // Ensure we don't continue iterating. | ||
} | ||
obj = _.isFunction(prop) ? prop.call(obj) : prop; | ||
} | ||
return obj; | ||
}; | ||
@@ -1452,5 +1590,5 @@ | ||
_.templateSettings = { | ||
evaluate : /<%([\s\S]+?)%>/g, | ||
interpolate : /<%=([\s\S]+?)%>/g, | ||
escape : /<%-([\s\S]+?)%>/g | ||
evaluate: /<%([\s\S]+?)%>/g, | ||
interpolate: /<%=([\s\S]+?)%>/g, | ||
escape: /<%-([\s\S]+?)%>/g | ||
}; | ||
@@ -1466,6 +1604,6 @@ | ||
var escapes = { | ||
"'": "'", | ||
'\\': '\\', | ||
'\r': 'r', | ||
'\n': 'n', | ||
"'": "'", | ||
'\\': '\\', | ||
'\r': 'r', | ||
'\n': 'n', | ||
'\u2028': 'u2028', | ||
@@ -1475,3 +1613,3 @@ '\u2029': 'u2029' | ||
var escaper = /\\|'|\r|\n|\u2028|\u2029/g; | ||
var escapeRegExp = /\\|'|\r|\n|\u2028|\u2029/g; | ||
@@ -1501,3 +1639,3 @@ var escapeChar = function(match) { | ||
text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { | ||
source += text.slice(index, offset).replace(escaper, escapeChar); | ||
source += text.slice(index, offset).replace(escapeRegExp, escapeChar); | ||
index = offset + match.length; | ||
@@ -1513,3 +1651,3 @@ | ||
// Adobe VMs need the match returned to produce the correct offest. | ||
// Adobe VMs need the match returned to produce the correct offset. | ||
return match; | ||
@@ -1526,4 +1664,5 @@ }); | ||
var render; | ||
try { | ||
var render = new Function(settings.variable || 'obj', '_', source); | ||
render = new Function(settings.variable || 'obj', '_', source); | ||
} catch (e) { | ||
@@ -1559,3 +1698,3 @@ e.source = source; | ||
// Helper function to continue chaining intermediate results. | ||
var result = function(instance, obj) { | ||
var chainResult = function(instance, obj) { | ||
return instance._chain ? _(obj).chain() : obj; | ||
@@ -1571,5 +1710,6 @@ }; | ||
push.apply(args, arguments); | ||
return result(this, func.apply(_, args)); | ||
return chainResult(this, func.apply(_, args)); | ||
}; | ||
}); | ||
return _; | ||
}; | ||
@@ -1587,3 +1727,3 @@ | ||
if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0]; | ||
return result(this, obj); | ||
return chainResult(this, obj); | ||
}; | ||
@@ -1596,3 +1736,3 @@ }); | ||
_.prototype[name] = function() { | ||
return result(this, method.apply(this._wrapped, arguments)); | ||
return chainResult(this, method.apply(this._wrapped, arguments)); | ||
}; | ||
@@ -1611,3 +1751,3 @@ }); | ||
_.prototype.toString = function() { | ||
return '' + this._wrapped; | ||
return String(this._wrapped); | ||
}; | ||
@@ -1622,3 +1762,3 @@ | ||
// anonymous define() is called outside of a loader request. | ||
if (typeof define === 'function' && define.amd) { | ||
if (typeof define == 'function' && define.amd) { | ||
define('underscore', [], function() { | ||
@@ -1628,2 +1768,2 @@ return _; | ||
} | ||
}.call(this)); | ||
}()); |
Sorry, the diff of this file is not supported yet
110852
1501
29
11