Compare commits

...

14 Commits
3.3.0 ... 3.3.1

Author SHA1 Message Date
jdalton
bf4a70d91c Bump to v3.3.1. 2015-02-23 23:49:50 -08:00
jdalton
a35ab3937a Rebuild lodash and docs. 2015-02-23 23:49:40 -08:00
jdalton
5ef9a4be8a Ensure isIterateeCall doesn't error if index is an object without a toString method. [closes #994] 2015-02-23 23:48:49 -08:00
jdalton
d76d7582fe Simplify lazy filter, map, & takeWhile assignment. 2015-02-23 21:25:24 -08:00
jdalton
44006142c7 Ensure wait of _.debounce and _.throttle defaults to 0. [closes #991] 2015-02-23 08:28:20 -08:00
jdalton
6840b2cfe5 Consistent use of callCount variable. 2015-02-23 08:28:20 -08:00
jdalton
5613f60403 Ensure lazy takeWhile works with reverse and last`. [closes #990] 2015-02-23 02:05:09 -08:00
jdalton
76d3959f1a Use square in more places. 2015-02-23 01:26:07 -08:00
jdalton
b681759000 Remove unnecessary excused tests. 2015-02-23 00:35:24 -08:00
jdalton
d6336c4302 Fix code styling in _.template doc example. [ci skip] 2015-02-23 00:35:24 -08:00
jdalton
35b161450a Update benchmark and underscore vendor files. 2015-02-23 00:35:24 -08:00
jdalton
861aaf06c6 Optimize _.uniq and others in Firefox. 2015-02-23 00:35:23 -08:00
jdalton
a910884e7d Fix _.indexOf doc example typo. [closes #986] [ci skip] 2015-02-23 00:35:23 -08:00
Jarrett Meyer
0e7bef9014 Fixes missing single quotes in docs. [ci skip] 2015-02-23 00:35:23 -08:00
20 changed files with 1889 additions and 984 deletions

View File

@@ -1,4 +1,4 @@
# lodash v3.3.0 # lodash v3.3.1
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) with packages for [Bower](http://bower.io/), [Component](http://component.github.io/), & [Volo](http://volojs.org/). The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) with packages for [Bower](http://bower.io/), [Component](http://component.github.io/), & [Volo](http://volojs.org/).
@@ -12,8 +12,8 @@ $ lodash modern -o ./lodash.js
lodash is also available in a variety of other builds & module formats. lodash is also available in a variety of other builds & module formats.
* npm packages for [modern](https://www.npmjs.com/package/lodash), [compatibility](https://www.npmjs.com/package/lodash-compat), & [per method](https://www.npmjs.com/browse/keyword/lodash-modularized) builds * npm packages for [modern](https://www.npmjs.com/package/lodash), [compatibility](https://www.npmjs.com/package/lodash-compat), & [per method](https://www.npmjs.com/browse/keyword/lodash-modularized) builds
* AMD modules for [modern](https://github.com/lodash/lodash/tree/3.3.0-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.3.0-amd) builds * AMD modules for [modern](https://github.com/lodash/lodash/tree/3.3.1-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.3.1-amd) builds
* ES modules for the [modern](https://github.com/lodash/lodash/tree/3.3.0-es) build * ES modules for the [modern](https://github.com/lodash/lodash/tree/3.3.1-es) build
## Further Reading ## Further Reading

View File

@@ -1,6 +1,6 @@
{ {
"name": "lodash", "name": "lodash",
"version": "3.3.0", "version": "3.3.1",
"main": "lodash.js", "main": "lodash.js",
"ignore": [ "ignore": [
".*", ".*",

View File

@@ -1,7 +1,7 @@
{ {
"name": "lodash", "name": "lodash",
"repo": "lodash/lodash", "repo": "lodash/lodash",
"version": "3.3.0", "version": "3.3.1",
"description": "The modern build of lodash.", "description": "The modern build of lodash.",
"license": "MIT", "license": "MIT",
"main": "lodash.js", "main": "lodash.js",

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,9 @@
/** /**
* @license * @license
* lodash 3.3.0 (Custom Build) <https://lodash.com/> * lodash 3.3.1 (Custom Build) <https://lodash.com/>
* Build: `lodash modern -o ./lodash.js` * Build: `lodash modern -o ./lodash.js`
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE> * Based on Underscore.js 1.8.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <https://lodash.com/license> * Available under MIT license <https://lodash.com/license>
*/ */
@@ -13,7 +13,7 @@
var undefined; var undefined;
/** Used as the semantic version number. */ /** Used as the semantic version number. */
var VERSION = '3.3.0'; var VERSION = '3.3.1';
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1, var BIND_FLAG = 1,
@@ -1804,7 +1804,7 @@
var index = -1, var index = -1,
indexOf = getIndexOf(), indexOf = getIndexOf(),
isCommon = indexOf == baseIndexOf, isCommon = indexOf == baseIndexOf,
cache = isCommon && values.length >= 200 && createCache(values), cache = (isCommon && values.length >= 200) ? createCache(values) : null,
valuesLength = values.length; valuesLength = values.length;
if (cache) { if (cache) {
@@ -2624,7 +2624,7 @@
length = array.length, length = array.length,
isCommon = indexOf == baseIndexOf, isCommon = indexOf == baseIndexOf,
isLarge = isCommon && length >= 200, isLarge = isCommon && length >= 200,
seen = isLarge && createCache(), seen = isLarge ? createCache() : null,
result = []; result = [];
if (seen) { if (seen) {
@@ -3676,8 +3676,11 @@
} else { } else {
prereq = type == 'string' && index in object; prereq = type == 'string' && index in object;
} }
var other = object[index]; if (prereq) {
return prereq && (value === value ? value === other : other !== other); var other = object[index];
return value === value ? value === other : other !== other;
}
return false;
} }
/** /**
@@ -4403,7 +4406,7 @@
* // => 2 * // => 2
* *
* // using the `_.matches` callback shorthand * // using the `_.matches` callback shorthand
* _.findLastIndex(users, { user': 'barney', 'active': true }); * _.findLastIndex(users, { 'user': 'barney', 'active': true });
* // => 0 * // => 0
* *
* // using the `_.matchesProperty` callback shorthand * // using the `_.matchesProperty` callback shorthand
@@ -4514,7 +4517,7 @@
* @example * @example
* *
* _.indexOf([1, 2, 1, 2], 2); * _.indexOf([1, 2, 1, 2], 2);
* // => 2 * // => 1
* *
* // using `fromIndex` * // using `fromIndex`
* _.indexOf([1, 2, 1, 2], 2, 2); * _.indexOf([1, 2, 1, 2], 2, 2);
@@ -4587,7 +4590,7 @@
var value = arguments[argsIndex]; var value = arguments[argsIndex];
if (isArray(value) || isArguments(value)) { if (isArray(value) || isArguments(value)) {
args.push(value); args.push(value);
caches.push(isCommon && value.length >= 120 && createCache(argsIndex && value)); caches.push((isCommon && value.length >= 120) ? createCache(argsIndex && value) : null);
} }
} }
argsLength = args.length; argsLength = args.length;
@@ -6655,7 +6658,7 @@
* ]; * ];
* *
* // using the `_.matches` callback shorthand * // using the `_.matches` callback shorthand
* _.some(users, { user': 'barney', 'active': false }); * _.some(users, { 'user': 'barney', 'active': false });
* // => false * // => false
* *
* // using the `_.matchesProperty` callback shorthand * // using the `_.matchesProperty` callback shorthand
@@ -7191,7 +7194,7 @@
* @memberOf _ * @memberOf _
* @category Function * @category Function
* @param {Function} func The function to debounce. * @param {Function} func The function to debounce.
* @param {number} wait The number of milliseconds to delay. * @param {number} [wait=0] The number of milliseconds to delay.
* @param {Object} [options] The options object. * @param {Object} [options] The options object.
* @param {boolean} [options.leading=false] Specify invoking on the leading * @param {boolean} [options.leading=false] Specify invoking on the leading
* edge of the timeout. * edge of the timeout.
@@ -7249,7 +7252,7 @@
if (typeof func != 'function') { if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT); throw new TypeError(FUNC_ERROR_TEXT);
} }
wait = wait < 0 ? 0 : wait; wait = wait < 0 ? 0 : (+wait || 0);
if (options === true) { if (options === true) {
var leading = true; var leading = true;
trailing = false; trailing = false;
@@ -7770,7 +7773,7 @@
* @memberOf _ * @memberOf _
* @category Function * @category Function
* @param {Function} func The function to throttle. * @param {Function} func The function to throttle.
* @param {number} wait The number of milliseconds to throttle invocations to. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
* @param {Object} [options] The options object. * @param {Object} [options] The options object.
* @param {boolean} [options.leading=true] Specify invoking on the leading * @param {boolean} [options.leading=true] Specify invoking on the leading
* edge of the timeout. * edge of the timeout.
@@ -10087,10 +10090,10 @@
* var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
* compiled.source; * compiled.source;
* // => function(data) { * // => function(data) {
* var __t, __p = ''; * // var __t, __p = '';
* __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
* return __p; * // return __p;
* } * // }
* *
* // using the `source` property to inline compiled templates for meaningful * // using the `source` property to inline compiled templates for meaningful
* // line numbers in error messages and a stack trace * // line numbers in error messages and a stack trace
@@ -11204,15 +11207,13 @@
// Add `LazyWrapper` methods that accept an `iteratee` value. // Add `LazyWrapper` methods that accept an `iteratee` value.
arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
var isFilter = index == LAZY_FILTER_FLAG, var isFilter = index == LAZY_FILTER_FLAG || index == LAZY_WHILE_FLAG;
isWhile = index == LAZY_WHILE_FLAG;
LazyWrapper.prototype[methodName] = function(iteratee, thisArg) { LazyWrapper.prototype[methodName] = function(iteratee, thisArg) {
var result = this.clone(), var result = this.clone(),
filtered = result.__filtered__,
iteratees = result.__iteratees__ || (result.__iteratees__ = []); iteratees = result.__iteratees__ || (result.__iteratees__ = []);
result.__filtered__ = filtered || isFilter || (isWhile && result.__dir__ < 0); result.__filtered__ = result.__filtered__ || isFilter;
iteratees.push({ 'iteratee': getCallback(iteratee, thisArg, 3), 'type': index }); iteratees.push({ 'iteratee': getCallback(iteratee, thisArg, 3), 'type': index });
return result; return result;
}; };
@@ -11279,9 +11280,14 @@
}; };
LazyWrapper.prototype.dropWhile = function(predicate, thisArg) { LazyWrapper.prototype.dropWhile = function(predicate, thisArg) {
var done; var done,
lastIndex,
isRight = this.__dir__ < 0;
predicate = getCallback(predicate, thisArg, 3); predicate = getCallback(predicate, thisArg, 3);
return this.filter(function(value, index, array) { return this.filter(function(value, index, array) {
done = done && (isRight ? index < lastIndex : index > lastIndex);
lastIndex = index;
return done || (done = !predicate(value, index, array)); return done || (done = !predicate(value, index, array));
}); });
}; };

27
lodash.min.js vendored
View File

@@ -1,6 +1,6 @@
/** /**
* @license * @license
* lodash 3.3.0 (Custom Build) lodash.com/license | Underscore.js 1.7.0 underscorejs.org/LICENSE * lodash 3.3.1 (Custom Build) lodash.com/license | Underscore.js 1.8.2 underscorejs.org/LICENSE
* Build: `lodash modern -o ./lodash.js` * Build: `lodash modern -o ./lodash.js`
*/ */
;(function(){function n(n,t){if(n!==t){var r=n===n,e=t===t;if(n>t||!r||typeof n=="undefined"&&e)return 1;if(n<t||!e||typeof t=="undefined"&&r)return-1}return 0}function t(n,t,r){if(t!==t)return h(n,r);r=(r||0)-1;for(var e=n.length;++r<e;)if(n[r]===t)return r;return-1}function r(n){return typeof n=="function"||false}function e(n,t){var r=n.length;for(n.sort(t);r--;)n[r]=n[r].c;return n}function u(n){return typeof n=="string"?n:null==n?"":n+""}function o(n){return n.charCodeAt(0)}function i(n,t){for(var r=-1,e=n.length;++r<e&&-1<t.indexOf(n.charAt(r)););return r ;(function(){function n(n,t){if(n!==t){var r=n===n,e=t===t;if(n>t||!r||typeof n=="undefined"&&e)return 1;if(n<t||!e||typeof t=="undefined"&&r)return-1}return 0}function t(n,t,r){if(t!==t)return h(n,r);r=(r||0)-1;for(var e=n.length;++r<e;)if(n[r]===t)return r;return-1}function r(n){return typeof n=="function"||false}function e(n,t){var r=n.length;for(n.sort(t);r--;)n[r]=n[r].c;return n}function u(n){return typeof n=="string"?n:null==n?"":n+""}function o(n){return n.charCodeAt(0)}function i(n,t){for(var r=-1,e=n.length;++r<e&&-1<t.indexOf(n.charAt(r)););return r
@@ -10,7 +10,7 @@
}function Kt(n,t){for(var r=-1,e=n.length;++r<e;)if(!t(n[r],r,n))return false;return true}function Vt(n,t){for(var r=-1,e=n.length,u=-1,o=[];++r<e;){var i=n[r];t(i,r,n)&&(o[++u]=i)}return o}function Yt(n,t){for(var r=-1,e=n.length,u=bu(e);++r<e;)u[r]=t(n[r],r,n);return u}function Zt(n){for(var t=-1,r=n.length,e=so;++t<r;){var u=n[t];u>e&&(e=u)}return e}function Gt(n,t,r,e){var u=-1,o=n.length;for(e&&o&&(r=n[++u]);++u<o;)r=t(r,n[u],u,n);return r}function Jt(n,t,r,e){var u=n.length;for(e&&u&&(r=n[--u]);u--;)r=t(r,n[u],u,n); }function Kt(n,t){for(var r=-1,e=n.length;++r<e;)if(!t(n[r],r,n))return false;return true}function Vt(n,t){for(var r=-1,e=n.length,u=-1,o=[];++r<e;){var i=n[r];t(i,r,n)&&(o[++u]=i)}return o}function Yt(n,t){for(var r=-1,e=n.length,u=bu(e);++r<e;)u[r]=t(n[r],r,n);return u}function Zt(n){for(var t=-1,r=n.length,e=so;++t<r;){var u=n[t];u>e&&(e=u)}return e}function Gt(n,t,r,e){var u=-1,o=n.length;for(e&&o&&(r=n[++u]);++u<o;)r=t(r,n[u],u,n);return r}function Jt(n,t,r,e){var u=n.length;for(e&&u&&(r=n[--u]);u--;)r=t(r,n[u],u,n);
return r}function Xt(n,t){for(var r=-1,e=n.length;++r<e;)if(t(n[r],r,n))return true;return false}function Ht(n,t){return typeof n=="undefined"?t:n}function Qt(n,t,r,e){return typeof n!="undefined"&&Fu.call(e,r)?n:t}function nr(n,t,r){var e=$o(t);if(!r)return rr(t,n,e);for(var u=-1,o=e.length;++u<o;){var i=e[u],f=n[i],a=r(f,t[i],i,n,t);(a===a?a===f:f!==f)&&(typeof f!="undefined"||i in n)||(n[i]=a)}return n}function tr(n,t){for(var r=-1,e=n.length,u=fe(e),o=t.length,i=bu(o);++r<o;){var f=t[r];u?(f=parseFloat(f),i[r]=oe(f,e)?n[f]:b):i[r]=n[f] return r}function Xt(n,t){for(var r=-1,e=n.length;++r<e;)if(t(n[r],r,n))return true;return false}function Ht(n,t){return typeof n=="undefined"?t:n}function Qt(n,t,r,e){return typeof n!="undefined"&&Fu.call(e,r)?n:t}function nr(n,t,r){var e=$o(t);if(!r)return rr(t,n,e);for(var u=-1,o=e.length;++u<o;){var i=e[u],f=n[i],a=r(f,t[i],i,n,t);(a===a?a===f:f!==f)&&(typeof f!="undefined"||i in n)||(n[i]=a)}return n}function tr(n,t){for(var r=-1,e=n.length,u=fe(e),o=t.length,i=bu(o);++r<o;){var f=t[r];u?(f=parseFloat(f),i[r]=oe(f,e)?n[f]:b):i[r]=n[f]
}return i}function rr(n,t,r){r||(r=t,t={});for(var e=-1,u=r.length;++e<u;){var o=r[e];t[o]=n[o]}return t}function er(n,t,r){var e=typeof n;if("function"==e){if(e=typeof t!="undefined"){var e=Nt.support,u=!(e.funcNames?n.name:e.funcDecomp);if(!u){var o=Nu.call(n);e.funcNames||(u=!mt.test(o)),u||(u=Et.test(o)||Qe(n),xo(n,u))}e=u}n=e?Fr(n,t,r):n}else n=null==n?yu:"object"==e?Ar(n):typeof t=="undefined"?Er(n+""):jr(n+"",t);return n}function ur(n,t,r,e,u,o,i){var f;if(r&&(f=u?r(n,e,u):r(n)),typeof f!="undefined")return f; }return i}function rr(n,t,r){r||(r=t,t={});for(var e=-1,u=r.length;++e<u;){var o=r[e];t[o]=n[o]}return t}function er(n,t,r){var e=typeof n;if("function"==e){if(e=typeof t!="undefined"){var e=Nt.support,u=!(e.funcNames?n.name:e.funcDecomp);if(!u){var o=Nu.call(n);e.funcNames||(u=!mt.test(o)),u||(u=Et.test(o)||Qe(n),xo(n,u))}e=u}n=e?Fr(n,t,r):n}else n=null==n?yu:"object"==e?Ar(n):typeof t=="undefined"?Er(n+""):jr(n+"",t);return n}function ur(n,t,r,e,u,o,i){var f;if(r&&(f=u?r(n,e,u):r(n)),typeof f!="undefined")return f;
if(!He(n))return n;if(e=Wo(n)){if(f=re(n),!t)return qt(n,f)}else{var a=$u.call(n),c=a==V;if(a!=Z&&a!=D&&(!c||u))return St[a]?ue(n,a,t):u?n:{};if(f=ee(c?{}:n),!t)return rr(n,f,$o(n))}for(o||(o=[]),i||(i=[]),u=o.length;u--;)if(o[u]==n)return i[u];return o.push(n),i.push(f),(e?Pt:vr)(n,function(e,u){f[u]=ur(e,t,r,u,n,o,i)}),f}function or(n,t,r,e){if(typeof n!="function")throw new Cu(B);return Ju(function(){n.apply(b,Or(r,e))},t)}function ir(n,r){var e=n?n.length:0,u=[];if(!e)return u;var o=-1,i=te(),f=i==t,a=f&&200<=r.length&&Ao(r),c=r.length; if(!He(n))return n;if(e=Wo(n)){if(f=re(n),!t)return qt(n,f)}else{var a=$u.call(n),c=a==V;if(a!=Z&&a!=D&&(!c||u))return St[a]?ue(n,a,t):u?n:{};if(f=ee(c?{}:n),!t)return rr(n,f,$o(n))}for(o||(o=[]),i||(i=[]),u=o.length;u--;)if(o[u]==n)return i[u];return o.push(n),i.push(f),(e?Pt:vr)(n,function(e,u){f[u]=ur(e,t,r,u,n,o,i)}),f}function or(n,t,r,e){if(typeof n!="function")throw new Cu(B);return Ju(function(){n.apply(b,Or(r,e))},t)}function ir(n,r){var e=n?n.length:0,u=[];if(!e)return u;var o=-1,i=te(),f=i==t,a=f&&200<=r.length?Ao(r):null,c=r.length;
a&&(i=Dt,f=false,r=a);n:for(;++o<e;)if(a=n[o],f&&a===a){for(var l=c;l--;)if(r[l]===a)continue n;u.push(a)}else 0>i(r,a)&&u.push(a);return u}function fr(n,t){var r=n?n.length:0;if(!fe(r))return vr(n,t);for(var e=-1,u=_e(n);++e<r&&false!==t(u[e],e,u););return n}function ar(n,t){var r=n?n.length:0;if(!fe(r))return yr(n,t);for(var e=_e(n);r--&&false!==t(e[r],r,e););return n}function cr(n,t){var r=true;return fr(n,function(n,e,u){return r=!!t(n,e,u)}),r}function lr(n,t){var r=[];return fr(n,function(n,e,u){t(n,e,u)&&r.push(n) a&&(i=Dt,f=false,r=a);n:for(;++o<e;)if(a=n[o],f&&a===a){for(var l=c;l--;)if(r[l]===a)continue n;u.push(a)}else 0>i(r,a)&&u.push(a);return u}function fr(n,t){var r=n?n.length:0;if(!fe(r))return vr(n,t);for(var e=-1,u=_e(n);++e<r&&false!==t(u[e],e,u););return n}function ar(n,t){var r=n?n.length:0;if(!fe(r))return yr(n,t);for(var e=_e(n);r--&&false!==t(e[r],r,e););return n}function cr(n,t){var r=true;return fr(n,function(n,e,u){return r=!!t(n,e,u)}),r}function lr(n,t){var r=[];return fr(n,function(n,e,u){t(n,e,u)&&r.push(n)
}),r}function sr(n,t,r,e){var u;return r(n,function(n,r,o){return t(n,r,o)?(u=e?r:n,false):void 0}),u}function pr(n,t,r,e){e=(e||0)-1;for(var u=n.length,o=-1,i=[];++e<u;){var f=n[e];if(_(f)&&fe(f.length)&&(Wo(f)||Ge(f))){t&&(f=pr(f,t,r));var a=-1,c=f.length;for(i.length+=c;++a<c;)i[++o]=f[a]}else r||(i[++o]=f)}return i}function hr(n,t,r){var e=-1,u=_e(n);r=r(n);for(var o=r.length;++e<o;){var i=r[e];if(false===t(u[i],i,u))break}return n}function _r(n,t,r){var e=_e(n);r=r(n);for(var u=r.length;u--;){var o=r[u]; }),r}function sr(n,t,r,e){var u;return r(n,function(n,r,o){return t(n,r,o)?(u=e?r:n,false):void 0}),u}function pr(n,t,r,e){e=(e||0)-1;for(var u=n.length,o=-1,i=[];++e<u;){var f=n[e];if(_(f)&&fe(f.length)&&(Wo(f)||Ge(f))){t&&(f=pr(f,t,r));var a=-1,c=f.length;for(i.length+=c;++a<c;)i[++o]=f[a]}else r||(i[++o]=f)}return i}function hr(n,t,r){var e=-1,u=_e(n);r=r(n);for(var o=r.length;++e<o;){var i=r[e];if(false===t(u[i],i,u))break}return n}function _r(n,t,r){var e=_e(n);r=r(n);for(var u=r.length;u--;){var o=r[u];
if(false===t(e[o],o,e))break}return n}function gr(n,t){hr(n,t,iu)}function vr(n,t){return hr(n,t,$o)}function yr(n,t){return _r(n,t,$o)}function dr(n,t){for(var r=-1,e=t.length,u=-1,o=[];++r<e;){var i=t[r];Uo(n[i])&&(o[++u]=i)}return o}function mr(n,t,r){var e=-1,u=typeof t=="function",o=n?n.length:0,i=fe(o)?bu(o):[];return fr(n,function(n){var o=u?t:null!=n&&n[t];i[++e]=o?o.apply(n,r):b}),i}function wr(n,t,r,e,u,o){if(n===t)return 0!==n||1/n==1/t;var i=typeof n,f=typeof t;if("function"!=i&&"object"!=i&&"function"!=f&&"object"!=f||null==n||null==t)n=n!==n&&t!==t; if(false===t(e[o],o,e))break}return n}function gr(n,t){hr(n,t,iu)}function vr(n,t){return hr(n,t,$o)}function yr(n,t){return _r(n,t,$o)}function dr(n,t){for(var r=-1,e=t.length,u=-1,o=[];++r<e;){var i=t[r];Uo(n[i])&&(o[++u]=i)}return o}function mr(n,t,r){var e=-1,u=typeof t=="function",o=n?n.length:0,i=fe(o)?bu(o):[];return fr(n,function(n){var o=u?t:null!=n&&n[t];i[++e]=o?o.apply(n,r):b}),i}function wr(n,t,r,e,u,o){if(n===t)return 0!==n||1/n==1/t;var i=typeof n,f=typeof t;if("function"!=i&&"object"!=i&&"function"!=f&&"object"!=f||null==n||null==t)n=n!==n&&t!==t;
@@ -18,7 +18,7 @@ else n:{var i=wr,f=Wo(n),a=Wo(t),c=M,l=M;f||(c=$u.call(n),c==D?c=Z:c!=Z&&(f=eu(n
for(var i=-1,f=!u;++i<o;)if(f&&e[i]?r[i]!==n[t[i]]:!Fu.call(n,t[i]))return false;for(i=-1;++i<o;){var a=t[i];if(f&&e[i])a=Fu.call(n,a);else{var c=n[a],l=r[i],a=u?u(c,l,a):b;typeof a=="undefined"&&(a=wr(l,c,u,true))}if(!a)return false}return true}function xr(n,t){var r=[];return fr(n,function(n,e,u){r.push(t(n,e,u))}),r}function Ar(n){var t=$o(n),r=t.length;if(1==r){var e=t[0],u=n[e];if(ae(u))return function(n){return null!=n&&n[e]===u&&Fu.call(n,e)}}for(var o=bu(r),i=bu(r);r--;)u=n[t[r]],o[r]=u,i[r]=ae(u);return function(n){return br(n,t,o,i) for(var i=-1,f=!u;++i<o;)if(f&&e[i]?r[i]!==n[t[i]]:!Fu.call(n,t[i]))return false;for(i=-1;++i<o;){var a=t[i];if(f&&e[i])a=Fu.call(n,a);else{var c=n[a],l=r[i],a=u?u(c,l,a):b;typeof a=="undefined"&&(a=wr(l,c,u,true))}if(!a)return false}return true}function xr(n,t){var r=[];return fr(n,function(n,e,u){r.push(t(n,e,u))}),r}function Ar(n){var t=$o(n),r=t.length;if(1==r){var e=t[0],u=n[e];if(ae(u))return function(n){return null!=n&&n[e]===u&&Fu.call(n,e)}}for(var o=bu(r),i=bu(r);r--;)u=n[t[r]],o[r]=u,i[r]=ae(u);return function(n){return br(n,t,o,i)
}}function jr(n,t){return ae(t)?function(r){return null!=r&&r[n]===t}:function(r){return null!=r&&wr(t,r[n],null,true)}}function kr(n,t,r,e,u){if(!He(n))return n;var o=fe(t.length)&&(Wo(t)||eu(t));return(o?Pt:vr)(t,function(t,i,f){if(_(t)){e||(e=[]),u||(u=[]);n:{t=e;for(var a=u,c=t.length,l=f[i];c--;)if(t[c]==l){n[i]=a[c],i=void 0;break n}c=n[i],f=r?r(c,l,i,n,f):b;var s=typeof f=="undefined";s&&(f=l,fe(l.length)&&(Wo(l)||eu(l))?f=Wo(c)?c:c?qt(c):[]:Fo(l)||Ge(l)?f=Ge(c)?uu(c):Fo(c)?c:{}:s=false),t.push(l),a.push(f),s?n[i]=kr(f,l,r,t,a):(f===f?f!==c:c===c)&&(n[i]=f),i=void 0 }}function jr(n,t){return ae(t)?function(r){return null!=r&&r[n]===t}:function(r){return null!=r&&wr(t,r[n],null,true)}}function kr(n,t,r,e,u){if(!He(n))return n;var o=fe(t.length)&&(Wo(t)||eu(t));return(o?Pt:vr)(t,function(t,i,f){if(_(t)){e||(e=[]),u||(u=[]);n:{t=e;for(var a=u,c=t.length,l=f[i];c--;)if(t[c]==l){n[i]=a[c],i=void 0;break n}c=n[i],f=r?r(c,l,i,n,f):b;var s=typeof f=="undefined";s&&(f=l,fe(l.length)&&(Wo(l)||eu(l))?f=Wo(c)?c:c?qt(c):[]:Fo(l)||Ge(l)?f=Ge(c)?uu(c):Fo(c)?c:{}:s=false),t.push(l),a.push(f),s?n[i]=kr(f,l,r,t,a):(f===f?f!==c:c===c)&&(n[i]=f),i=void 0
}return i}a=n[i],f=r?r(a,t,i,n,f):b,(l=typeof f=="undefined")&&(f=t),!o&&typeof f=="undefined"||!l&&(f===f?f===a:a!==a)||(n[i]=f)}),n}function Er(n){return function(t){return null==t?b:t[n]}}function Rr(n,t){return n+Ku(lo()*(t-n+1))}function Ir(n,t,r,e,u){return u(n,function(n,u,o){r=e?(e=false,n):t(r,n,u,o)}),r}function Or(n,t,r){var e=-1,u=n.length;for(t=null==t?0:+t||0,0>t&&(t=-t>u?0:u+t),r=typeof r=="undefined"||r>u?u:+r||0,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=bu(u);++e<u;)r[e]=n[e+t];return r}function Cr(n,t){var r; }return i}a=n[i],f=r?r(a,t,i,n,f):b,(l=typeof f=="undefined")&&(f=t),!o&&typeof f=="undefined"||!l&&(f===f?f===a:a!==a)||(n[i]=f)}),n}function Er(n){return function(t){return null==t?b:t[n]}}function Rr(n,t){return n+Ku(lo()*(t-n+1))}function Ir(n,t,r,e,u){return u(n,function(n,u,o){r=e?(e=false,n):t(r,n,u,o)}),r}function Or(n,t,r){var e=-1,u=n.length;for(t=null==t?0:+t||0,0>t&&(t=-t>u?0:u+t),r=typeof r=="undefined"||r>u?u:+r||0,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=bu(u);++e<u;)r[e]=n[e+t];return r}function Cr(n,t){var r;
return fr(n,function(n,e,u){return r=t(n,e,u),!r}),!!r}function Tr(n,r){var e=-1,u=te(),o=n.length,i=u==t,f=i&&200<=o,a=f&&Ao(),c=[];a?(u=Dt,i=false):(f=false,a=r?[]:c);n:for(;++e<o;){var l=n[e],s=r?r(l,e,n):l;if(i&&l===l){for(var p=a.length;p--;)if(a[p]===s)continue n;r&&a.push(s),c.push(l)}else 0>u(a,s)&&((r||f)&&a.push(s),c.push(l))}return c}function Sr(n,t){for(var r=-1,e=t.length,u=bu(e);++r<e;)u[r]=n[t[r]];return u}function Wr(n,t){var r=n;r instanceof Lt&&(r=r.value());for(var e=-1,u=t.length;++e<u;){var r=[r],o=t[e]; return fr(n,function(n,e,u){return r=t(n,e,u),!r}),!!r}function Tr(n,r){var e=-1,u=te(),o=n.length,i=u==t,f=i&&200<=o,a=f?Ao():null,c=[];a?(u=Dt,i=false):(f=false,a=r?[]:c);n:for(;++e<o;){var l=n[e],s=r?r(l,e,n):l;if(i&&l===l){for(var p=a.length;p--;)if(a[p]===s)continue n;r&&a.push(s),c.push(l)}else 0>u(a,s)&&((r||f)&&a.push(s),c.push(l))}return c}function Sr(n,t){for(var r=-1,e=t.length,u=bu(e);++r<e;)u[r]=n[t[r]];return u}function Wr(n,t){var r=n;r instanceof Lt&&(r=r.value());for(var e=-1,u=t.length;++e<u;){var r=[r],o=t[e];
Yu.apply(r,o.args),r=o.func.apply(o.thisArg,r)}return r}function Nr(n,t,r){var e=0,u=n?n.length:e;if(typeof t=="number"&&t===t&&u<=go){for(;e<u;){var o=e+u>>>1,i=n[o];(r?i<=t:i<t)?e=o+1:u=o}return u}return Ur(n,t,yu,r)}function Ur(n,t,r,e){t=r(t);for(var u=0,o=n?n.length:0,i=t!==t,f=typeof t=="undefined";u<o;){var a=Ku((u+o)/2),c=r(n[a]),l=c===c;(i?l||e:f?l&&(e||typeof c!="undefined"):e?c<=t:c<t)?u=a+1:o=a}return io(o,_o)}function Fr(n,t,r){if(typeof n!="function")return yu;if(typeof t=="undefined")return n; Yu.apply(r,o.args),r=o.func.apply(o.thisArg,r)}return r}function Nr(n,t,r){var e=0,u=n?n.length:e;if(typeof t=="number"&&t===t&&u<=go){for(;e<u;){var o=e+u>>>1,i=n[o];(r?i<=t:i<t)?e=o+1:u=o}return u}return Ur(n,t,yu,r)}function Ur(n,t,r,e){t=r(t);for(var u=0,o=n?n.length:0,i=t!==t,f=typeof t=="undefined";u<o;){var a=Ku((u+o)/2),c=r(n[a]),l=c===c;(i?l||e:f?l&&(e||typeof c!="undefined"):e?c<=t:c<t)?u=a+1:o=a}return io(o,_o)}function Fr(n,t,r){if(typeof n!="function")return yu;if(typeof t=="undefined")return n;
switch(r){case 1:return function(r){return n.call(t,r)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,o){return n.call(t,r,e,u,o)};case 5:return function(r,e,u,o,i){return n.call(t,r,e,u,o,i)}}return function(){return n.apply(t,arguments)}}function Lr(n){return Mu.call(n,0)}function $r(n,t,r){for(var e=r.length,u=-1,o=oo(n.length-e,0),i=-1,f=t.length,a=bu(o+f);++i<f;)a[i]=t[i];for(;++u<e;)a[r[u]]=n[u];for(;o--;)a[i++]=n[u++];return a}function Br(n,t,r){for(var e=-1,u=r.length,o=-1,i=oo(n.length-u,0),f=-1,a=t.length,c=bu(i+a);++o<i;)c[o]=n[o]; switch(r){case 1:return function(r){return n.call(t,r)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,o){return n.call(t,r,e,u,o)};case 5:return function(r,e,u,o,i){return n.call(t,r,e,u,o,i)}}return function(){return n.apply(t,arguments)}}function Lr(n){return Mu.call(n,0)}function $r(n,t,r){for(var e=r.length,u=-1,o=oo(n.length-e,0),i=-1,f=t.length,a=bu(o+f);++i<f;)a[i]=t[i];for(;++u<e;)a[r[u]]=n[u];for(;o--;)a[i++]=n[u++];return a}function Br(n,t,r){for(var e=-1,u=r.length,o=-1,i=oo(n.length-u,0),f=-1,a=t.length,c=bu(i+a);++o<i;)c[o]=n[o];
for(i=o;++f<a;)c[i+f]=t[f];for(;++e<u;)c[i+r[e]]=n[o++];return c}function zr(n,t){return function(r,e,u){var o=t?t():{};if(e=ne(e,u,3),Wo(r)){u=-1;for(var i=r.length;++u<i;){var f=r[u];n(o,f,e(f,u,r),r)}}else fr(r,function(t,r,u){n(o,t,e(t,r,u),u)});return o}}function Dr(n){return function(){var t=arguments.length,r=arguments[0];if(2>t||null==r)return r;if(3<t&&ie(arguments[1],arguments[2],arguments[3])&&(t=2),3<t&&"function"==typeof arguments[t-2])var e=Fr(arguments[--t-1],arguments[t--],5);else 2<t&&"function"==typeof arguments[t-1]&&(e=arguments[--t]); for(i=o;++f<a;)c[i+f]=t[f];for(;++e<u;)c[i+r[e]]=n[o++];return c}function zr(n,t){return function(r,e,u){var o=t?t():{};if(e=ne(e,u,3),Wo(r)){u=-1;for(var i=r.length;++u<i;){var f=r[u];n(o,f,e(f,u,r),r)}}else fr(r,function(t,r,u){n(o,t,e(t,r,u),u)});return o}}function Dr(n){return function(){var t=arguments.length,r=arguments[0];if(2>t||null==r)return r;if(3<t&&ie(arguments[1],arguments[2],arguments[3])&&(t=2),3<t&&"function"==typeof arguments[t-2])var e=Fr(arguments[--t-1],arguments[t--],5);else 2<t&&"function"==typeof arguments[t-1]&&(e=arguments[--t]);
@@ -29,7 +29,7 @@ e=u=null}var p=!a&&jo(n);if(r=[n,t,r,e,u,l,s,o,i,f],p&&true!==p){e=r[1],t=p[1],f
}return r[9]=null==f?a?0:n.length:oo(f-c,0)||0,(p?xo:ko)(t==A?Mr(r[0],r[2]):t!=I&&t!=(A|I)||r[4].length?Vr.apply(b,r):Zr.apply(b,r),r)}function Jr(n,t,r,e,u,o,i){var f=-1,a=n.length,c=t.length,l=true;if(a!=c&&(!u||c<=a))return false;for(;l&&++f<a;){var s=n[f],p=t[f],l=b;if(e&&(l=u?e(p,s,f):e(s,p,f)),typeof l=="undefined")if(u)for(var h=c;h--&&(p=t[h],!(l=s&&s===p||r(s,p,e,u,o,i))););else l=s&&s===p||r(s,p,e,u,o,i)}return!!l}function Xr(n,t,r){switch(r){case q:case P:return+n==+t;case K:return n.name==t.name&&n.message==t.message; }return r[9]=null==f?a?0:n.length:oo(f-c,0)||0,(p?xo:ko)(t==A?Mr(r[0],r[2]):t!=I&&t!=(A|I)||r[4].length?Vr.apply(b,r):Zr.apply(b,r),r)}function Jr(n,t,r,e,u,o,i){var f=-1,a=n.length,c=t.length,l=true;if(a!=c&&(!u||c<=a))return false;for(;l&&++f<a;){var s=n[f],p=t[f],l=b;if(e&&(l=u?e(p,s,f):e(s,p,f)),typeof l=="undefined")if(u)for(var h=c;h--&&(p=t[h],!(l=s&&s===p||r(s,p,e,u,o,i))););else l=s&&s===p||r(s,p,e,u,o,i)}return!!l}function Xr(n,t,r){switch(r){case q:case P:return+n==+t;case K:return n.name==t.name&&n.message==t.message;
case Y:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case G:case J:return n==t+""}return false}function Hr(n,t,r,e,u,o,i){var f=$o(n),a=f.length,c=$o(t).length;if(a!=c&&!u)return false;for(var l,c=-1;++c<a;){var s=f[c],p=Fu.call(t,s);if(p){var h=n[s],_=t[s],p=b;e&&(p=u?e(_,h,s):e(h,_,s)),typeof p=="undefined"&&(p=h&&h===_||r(h,_,e,u,o,i))}if(!p)return false;l||(l="constructor"==s)}return l||(r=n.constructor,e=t.constructor,!(r!=e&&"constructor"in n&&"constructor"in t)||typeof r=="function"&&r instanceof r&&typeof e=="function"&&e instanceof e)?true:false case Y:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case G:case J:return n==t+""}return false}function Hr(n,t,r,e,u,o,i){var f=$o(n),a=f.length,c=$o(t).length;if(a!=c&&!u)return false;for(var l,c=-1;++c<a;){var s=f[c],p=Fu.call(t,s);if(p){var h=n[s],_=t[s],p=b;e&&(p=u?e(_,h,s):e(h,_,s)),typeof p=="undefined"&&(p=h&&h===_||r(h,_,e,u,o,i))}if(!p)return false;l||(l="constructor"==s)}return l||(r=n.constructor,e=t.constructor,!(r!=e&&"constructor"in n&&"constructor"in t)||typeof r=="function"&&r instanceof r&&typeof e=="function"&&e instanceof e)?true:false
}function Qr(n,t,r){var e=r?po:so,u=e,o=u;return fr(n,function(n,i,f){i=t(n,i,f),((r?i<u:i>u)||i===e&&i===o)&&(u=i,o=n)}),o}function ne(n,t,r){var e=Nt.callback||gu,e=e===gu?er:e;return r?e(n,t,r):e}function te(n,r,e){var u=Nt.indexOf||we,u=u===we?t:u;return n?u(n,r,e):u}function re(n){var t=n.length,r=new n.constructor(t);return t&&"string"==typeof n[0]&&Fu.call(n,"index")&&(r.index=n.index,r.input=n.input),r}function ee(n){return n=n.constructor,typeof n=="function"&&n instanceof n||(n=Ru),new n }function Qr(n,t,r){var e=r?po:so,u=e,o=u;return fr(n,function(n,i,f){i=t(n,i,f),((r?i<u:i>u)||i===e&&i===o)&&(u=i,o=n)}),o}function ne(n,t,r){var e=Nt.callback||gu,e=e===gu?er:e;return r?e(n,t,r):e}function te(n,r,e){var u=Nt.indexOf||we,u=u===we?t:u;return n?u(n,r,e):u}function re(n){var t=n.length,r=new n.constructor(t);return t&&"string"==typeof n[0]&&Fu.call(n,"index")&&(r.index=n.index,r.input=n.input),r}function ee(n){return n=n.constructor,typeof n=="function"&&n instanceof n||(n=Ru),new n
}function ue(n,t,r){var e=n.constructor;switch(t){case X:return Lr(n);case q:case P:return new e(+n);case H:case Q:case nt:case tt:case rt:case et:case ut:case ot:case it:return t=n.buffer,new e(r?Lr(t):t,n.byteOffset,n.length);case Y:case J:return new e(n);case G:var u=new e(n.source,dt.exec(n));u.lastIndex=n.lastIndex}return u}function oe(n,t){return n=+n,t=null==t?yo:t,-1<n&&0==n%1&&n<t}function ie(n,t,r){if(!He(r))return false;var e=typeof t;return"number"==e?(e=r.length,e=fe(e)&&oe(t,e)):e="string"==e&&t in r,t=r[t],e&&(n===n?n===t:t!==t) }function ue(n,t,r){var e=n.constructor;switch(t){case X:return Lr(n);case q:case P:return new e(+n);case H:case Q:case nt:case tt:case rt:case et:case ut:case ot:case it:return t=n.buffer,new e(r?Lr(t):t,n.byteOffset,n.length);case Y:case J:return new e(n);case G:var u=new e(n.source,dt.exec(n));u.lastIndex=n.lastIndex}return u}function oe(n,t){return n=+n,t=null==t?yo:t,-1<n&&0==n%1&&n<t}function ie(n,t,r){if(!He(r))return false;var e=typeof t;return"number"==e?(e=r.length,e=fe(e)&&oe(t,e)):e="string"==e&&t in r,e?(t=r[t],n===n?n===t:t!==t):false
}function fe(n){return typeof n=="number"&&-1<n&&0==n%1&&n<=yo}function ae(n){return n===n&&(0===n?0<1/n:!He(n))}function ce(n,t){n=_e(n);for(var r=-1,e=t.length,u={};++r<e;){var o=t[r];o in n&&(u[o]=n[o])}return u}function le(n,t){var r={};return gr(n,function(n,e,u){t(n,e,u)&&(r[e]=n)}),r}function se(n){var t;if(!_(n)||$u.call(n)!=Z||!(Fu.call(n,"constructor")||(t=n.constructor,typeof t!="function"||t instanceof t)))return false;var r;return gr(n,function(n,t){r=t}),typeof r=="undefined"||Fu.call(n,r) }function fe(n){return typeof n=="number"&&-1<n&&0==n%1&&n<=yo}function ae(n){return n===n&&(0===n?0<1/n:!He(n))}function ce(n,t){n=_e(n);for(var r=-1,e=t.length,u={};++r<e;){var o=t[r];o in n&&(u[o]=n[o])}return u}function le(n,t){var r={};return gr(n,function(n,e,u){t(n,e,u)&&(r[e]=n)}),r}function se(n){var t;if(!_(n)||$u.call(n)!=Z||!(Fu.call(n,"constructor")||(t=n.constructor,typeof t!="function"||t instanceof t)))return false;var r;return gr(n,function(n,t){r=t}),typeof r=="undefined"||Fu.call(n,r)
}function pe(n){for(var t=iu(n),r=t.length,e=r&&n.length,u=Nt.support,u=e&&fe(e)&&(Wo(n)||u.nonEnumArgs&&Ge(n)),o=-1,i=[];++o<r;){var f=t[o];(u&&oe(f,e)||Fu.call(n,f))&&i.push(f)}return i}function he(n){return null==n?[]:fe(n.length)?He(n)?n:Ru(n):fu(n)}function _e(n){return He(n)?n:Ru(n)}function ge(n){return n instanceof Lt?n.clone():new Ft(n.__wrapped__,n.__chain__,qt(n.__actions__))}function ve(n,t,r){return n&&n.length?((r?ie(n,t,r):null==t)&&(t=1),Or(n,0>t?0:t)):[]}function ye(n,t,r){var e=n?n.length:0; }function pe(n){for(var t=iu(n),r=t.length,e=r&&n.length,u=Nt.support,u=e&&fe(e)&&(Wo(n)||u.nonEnumArgs&&Ge(n)),o=-1,i=[];++o<r;){var f=t[o];(u&&oe(f,e)||Fu.call(n,f))&&i.push(f)}return i}function he(n){return null==n?[]:fe(n.length)?He(n)?n:Ru(n):fu(n)}function _e(n){return He(n)?n:Ru(n)}function ge(n){return n instanceof Lt?n.clone():new Ft(n.__wrapped__,n.__chain__,qt(n.__actions__))}function ve(n,t,r){return n&&n.length?((r?ie(n,t,r):null==t)&&(t=1),Or(n,0>t?0:t)):[]}function ye(n,t,r){var e=n?n.length:0;
return e?((r?ie(n,t,r):null==t)&&(t=1),t=e-(+t||0),Or(n,0,0>t?0:t)):[]}function de(n,t,r){var e=-1,u=n?n.length:0;for(t=ne(t,r,3);++e<u;)if(t(n[e],e,n))return e;return-1}function me(n){return n?n[0]:b}function we(n,r,e){var u=n?n.length:0;if(!u)return-1;if(typeof e=="number")e=0>e?oo(u+e,0):e||0;else if(e)return e=Nr(n,r),n=n[e],(r===r?r===n:n!==n)?e:-1;return t(n,r,e)}function be(n){return ve(n,1)}function xe(n,r,e,u){if(!n||!n.length)return[];null!=r&&typeof r!="boolean"&&(u=e,e=ie(n,r,u)?null:r,r=false); return e?((r?ie(n,t,r):null==t)&&(t=1),t=e-(+t||0),Or(n,0,0>t?0:t)):[]}function de(n,t,r){var e=-1,u=n?n.length:0;for(t=ne(t,r,3);++e<u;)if(t(n[e],e,n))return e;return-1}function me(n){return n?n[0]:b}function we(n,r,e){var u=n?n.length:0;if(!u)return-1;if(typeof e=="number")e=0>e?oo(u+e,0):e||0;else if(e)return e=Nr(n,r),n=n[e],(r===r?r===n:n!==n)?e:-1;return t(n,r,e)}function be(n){return ve(n,1)}function xe(n,r,e,u){if(!n||!n.length)return[];null!=r&&typeof r!="boolean"&&(u=e,e=ie(n,r,u)?null:r,r=false);
@@ -38,7 +38,7 @@ var o=ne();if((o!==er||null!=e)&&(e=o(e,u,3)),r&&te()==t){r=e;var i;e=-1,u=n.len
}function Se(n,t,r){var e=n?n.length:0;return fe(e)||(n=fu(n),e=n.length),e?(r=typeof r=="number"?0>r?oo(e+r,0):r||0:0,typeof n=="string"||!Wo(n)&&ru(n)?r<e&&-1<n.indexOf(t,r):-1<te(n,t,r)):false}function We(n,t,r){var e=Wo(n)?Yt:xr;return t=ne(t,r,3),e(n,t)}function Ne(n,t,r,e){return(Wo(n)?Gt:Ir)(n,ne(t,e,4),r,3>arguments.length,fr)}function Ue(n,t,r,e){return(Wo(n)?Jt:Ir)(n,ne(t,e,4),r,3>arguments.length,ar)}function Fe(n,t,r){return(r?ie(n,t,r):null==t)?(n=he(n),t=n.length,0<t?n[Rr(0,t-1)]:b):(n=Le(n),n.length=io(0>t?0:+t||0,n.length),n) }function Se(n,t,r){var e=n?n.length:0;return fe(e)||(n=fu(n),e=n.length),e?(r=typeof r=="number"?0>r?oo(e+r,0):r||0:0,typeof n=="string"||!Wo(n)&&ru(n)?r<e&&-1<n.indexOf(t,r):-1<te(n,t,r)):false}function We(n,t,r){var e=Wo(n)?Yt:xr;return t=ne(t,r,3),e(n,t)}function Ne(n,t,r,e){return(Wo(n)?Gt:Ir)(n,ne(t,e,4),r,3>arguments.length,fr)}function Ue(n,t,r,e){return(Wo(n)?Jt:Ir)(n,ne(t,e,4),r,3>arguments.length,ar)}function Fe(n,t,r){return(r?ie(n,t,r):null==t)?(n=he(n),t=n.length,0<t?n[Rr(0,t-1)]:b):(n=Le(n),n.length=io(0>t?0:+t||0,n.length),n)
}function Le(n){n=he(n);for(var t=-1,r=n.length,e=bu(r);++t<r;){var u=Rr(0,t);t!=u&&(e[t]=e[u]),e[u]=n[t]}return e}function $e(n,t,r){var e=Wo(n)?Xt:Cr;return(typeof t!="function"||typeof r!="undefined")&&(t=ne(t,r,3)),e(n,t)}function Be(n,t){var r;if(typeof t!="function"){if(typeof n!="function")throw new Cu(B);var e=n;n=t,t=e}return function(){return 0<--n?r=t.apply(this,arguments):t=null,r}}function ze(n,t){var r=A;if(2<arguments.length)var e=Or(arguments,2),u=v(e,ze.placeholder),r=r|I;return Gr(n,r,t,e,u) }function Le(n){n=he(n);for(var t=-1,r=n.length,e=bu(r);++t<r;){var u=Rr(0,t);t!=u&&(e[t]=e[u]),e[u]=n[t]}return e}function $e(n,t,r){var e=Wo(n)?Xt:Cr;return(typeof t!="function"||typeof r!="undefined")&&(t=ne(t,r,3)),e(n,t)}function Be(n,t){var r;if(typeof t!="function"){if(typeof n!="function")throw new Cu(B);var e=n;n=t,t=e}return function(){return 0<--n?r=t.apply(this,arguments):t=null,r}}function ze(n,t){var r=A;if(2<arguments.length)var e=Or(arguments,2),u=v(e,ze.placeholder),r=r|I;return Gr(n,r,t,e,u)
}function De(n,t){var r=A|j;if(2<arguments.length)var e=Or(arguments,2),u=v(e,De.placeholder),r=r|I;return Gr(t,r,n,e,u)}function Me(n,t,r){return r&&ie(n,t,r)&&(t=null),n=Gr(n,E,null,null,null,null,null,t),n.placeholder=Me.placeholder,n}function qe(n,t,r){return r&&ie(n,t,r)&&(t=null),n=Gr(n,R,null,null,null,null,null,t),n.placeholder=qe.placeholder,n}function Pe(n,t,r){function e(){var r=t-(So()-c);0>=r||r>t?(f&&Pu(f),r=p,f=s=p=b,r&&(h=So(),a=n.apply(l,i),s||f||(i=l=null))):s=Ju(e,r)}function u(){s&&Pu(s),f=s=p=b,(g||_!==t)&&(h=So(),a=n.apply(l,i),s||f||(i=l=null)) }function De(n,t){var r=A|j;if(2<arguments.length)var e=Or(arguments,2),u=v(e,De.placeholder),r=r|I;return Gr(t,r,n,e,u)}function Me(n,t,r){return r&&ie(n,t,r)&&(t=null),n=Gr(n,E,null,null,null,null,null,t),n.placeholder=Me.placeholder,n}function qe(n,t,r){return r&&ie(n,t,r)&&(t=null),n=Gr(n,R,null,null,null,null,null,t),n.placeholder=qe.placeholder,n}function Pe(n,t,r){function e(){var r=t-(So()-c);0>=r||r>t?(f&&Pu(f),r=p,f=s=p=b,r&&(h=So(),a=n.apply(l,i),s||f||(i=l=null))):s=Ju(e,r)}function u(){s&&Pu(s),f=s=p=b,(g||_!==t)&&(h=So(),a=n.apply(l,i),s||f||(i=l=null))
}function o(){if(i=arguments,c=So(),l=this,p=g&&(s||!v),false===_)var r=v&&!s;else{f||v||(h=c);var o=_-(c-h),y=0>=o||o>_;y?(f&&(f=Pu(f)),h=c,a=n.apply(l,i)):f||(f=Ju(u,o))}return y&&s?s=Pu(s):s||t===_||(s=Ju(e,t)),r&&(y=true,a=n.apply(l,i)),!y||s||f||(i=l=null),a}var i,f,a,c,l,s,p,h=0,_=false,g=true;if(typeof n!="function")throw new Cu(B);if(t=0>t?0:t,true===r)var v=true,g=false;else He(r)&&(v=r.leading,_="maxWait"in r&&oo(+r.maxWait||0,t),g="trailing"in r?r.trailing:g);return o.cancel=function(){s&&Pu(s),f&&Pu(f),f=s=p=b }function o(){if(i=arguments,c=So(),l=this,p=g&&(s||!v),false===_)var r=v&&!s;else{f||v||(h=c);var o=_-(c-h),y=0>=o||o>_;y?(f&&(f=Pu(f)),h=c,a=n.apply(l,i)):f||(f=Ju(u,o))}return y&&s?s=Pu(s):s||t===_||(s=Ju(e,t)),r&&(y=true,a=n.apply(l,i)),!y||s||f||(i=l=null),a}var i,f,a,c,l,s,p,h=0,_=false,g=true;if(typeof n!="function")throw new Cu(B);if(t=0>t?0:+t||0,true===r)var v=true,g=false;else He(r)&&(v=r.leading,_="maxWait"in r&&oo(+r.maxWait||0,t),g="trailing"in r?r.trailing:g);return o.cancel=function(){s&&Pu(s),f&&Pu(f),f=s=p=b
},o}function Ke(){var n=arguments,t=n.length-1;if(0>t)return function(n){return n};if(!Kt(n,r))throw new Cu(B);return function(){for(var r=t,e=n[r].apply(this,arguments);r--;)e=n[r].call(this,e);return e}}function Ve(n,t){function r(){var e=r.cache,u=t?t.apply(this,arguments):arguments[0];if(e.has(u))return e.get(u);var o=n.apply(this,arguments);return e.set(u,o),o}if(typeof n!="function"||t&&typeof t!="function")throw new Cu(B);return r.cache=new Ve.Cache,r}function Ye(n){var t=Or(arguments,1),r=v(t,Ye.placeholder); },o}function Ke(){var n=arguments,t=n.length-1;if(0>t)return function(n){return n};if(!Kt(n,r))throw new Cu(B);return function(){for(var r=t,e=n[r].apply(this,arguments);r--;)e=n[r].call(this,e);return e}}function Ve(n,t){function r(){var e=r.cache,u=t?t.apply(this,arguments):arguments[0];if(e.has(u))return e.get(u);var o=n.apply(this,arguments);return e.set(u,o),o}if(typeof n!="function"||t&&typeof t!="function")throw new Cu(B);return r.cache=new Ve.Cache,r}function Ye(n){var t=Or(arguments,1),r=v(t,Ye.placeholder);
return Gr(n,I,null,t,r)}function Ze(n){var t=Or(arguments,1),r=v(t,Ze.placeholder);return Gr(n,O,null,t,r)}function Ge(n){return fe(_(n)?n.length:b)&&$u.call(n)==D||false}function Je(n){return n&&1===n.nodeType&&_(n)&&-1<$u.call(n).indexOf("Element")||false}function Xe(n){return _(n)&&typeof n.message=="string"&&$u.call(n)==K||false}function He(n){var t=typeof n;return"function"==t||n&&"object"==t||false}function Qe(n){return null==n?false:$u.call(n)==V?zu.test(Nu.call(n)):_(n)&&bt.test(n)||false}function nu(n){return typeof n=="number"||_(n)&&$u.call(n)==Y||false return Gr(n,I,null,t,r)}function Ze(n){var t=Or(arguments,1),r=v(t,Ze.placeholder);return Gr(n,O,null,t,r)}function Ge(n){return fe(_(n)?n.length:b)&&$u.call(n)==D||false}function Je(n){return n&&1===n.nodeType&&_(n)&&-1<$u.call(n).indexOf("Element")||false}function Xe(n){return _(n)&&typeof n.message=="string"&&$u.call(n)==K||false}function He(n){var t=typeof n;return"function"==t||n&&"object"==t||false}function Qe(n){return null==n?false:$u.call(n)==V?zu.test(Nu.call(n)):_(n)&&bt.test(n)||false}function nu(n){return typeof n=="number"||_(n)&&$u.call(n)==Y||false
}function tu(n){return _(n)&&$u.call(n)==G||false}function ru(n){return typeof n=="string"||_(n)&&$u.call(n)==J||false}function eu(n){return _(n)&&fe(n.length)&&Tt[$u.call(n)]||false}function uu(n){return rr(n,iu(n))}function ou(n){return dr(n,iu(n))}function iu(n){if(null==n)return[];He(n)||(n=Ru(n));for(var t=n.length,t=t&&fe(t)&&(Wo(n)||wo.nonEnumArgs&&Ge(n))&&t||0,r=n.constructor,e=-1,r=typeof r=="function"&&r.prototype===n,u=bu(t),o=0<t;++e<t;)u[e]=e+"";for(var i in n)o&&oe(i,t)||"constructor"==i&&(r||!Fu.call(n,i))||u.push(i); }function tu(n){return _(n)&&$u.call(n)==G||false}function ru(n){return typeof n=="string"||_(n)&&$u.call(n)==J||false}function eu(n){return _(n)&&fe(n.length)&&Tt[$u.call(n)]||false}function uu(n){return rr(n,iu(n))}function ou(n){return dr(n,iu(n))}function iu(n){if(null==n)return[];He(n)||(n=Ru(n));for(var t=n.length,t=t&&fe(t)&&(Wo(n)||wo.nonEnumArgs&&Ge(n))&&t||0,r=n.constructor,e=-1,r=typeof r=="function"&&r.prototype===n,u=bu(t),o=0<t;++e<t;)u[e]=e+"";for(var i in n)o&&oe(i,t)||"constructor"==i&&(r||!Fu.call(n,i))||u.push(i);
@@ -56,7 +56,7 @@ t[o]=Gr(t[o],A,t)}return t},Nt.bindKey=De,Nt.callback=gu,Nt.chain=ke,Nt.chunk=fu
var t=qt(arguments);return t.push(Ht),Lo.apply(b,t)},Nt.defer=function(n){return or(n,1,arguments,1)},Nt.delay=function(n,t){return or(n,t,arguments,2)},Nt.difference=function(){for(var n=-1,t=arguments.length;++n<t;){var r=arguments[n];if(Wo(r)||Ge(r))break}return ir(r,pr(arguments,false,true,++n))},Nt.drop=ve,Nt.dropRight=ye,Nt.dropRightWhile=function(n,t,r){var e=n?n.length:0;if(!e)return[];for(t=ne(t,r,3);e--&&t(n[e],e,n););return Or(n,0,e+1)},Nt.dropWhile=function(n,t,r){var e=n?n.length:0;if(!e)return[]; var t=qt(arguments);return t.push(Ht),Lo.apply(b,t)},Nt.defer=function(n){return or(n,1,arguments,1)},Nt.delay=function(n,t){return or(n,t,arguments,2)},Nt.difference=function(){for(var n=-1,t=arguments.length;++n<t;){var r=arguments[n];if(Wo(r)||Ge(r))break}return ir(r,pr(arguments,false,true,++n))},Nt.drop=ve,Nt.dropRight=ye,Nt.dropRightWhile=function(n,t,r){var e=n?n.length:0;if(!e)return[];for(t=ne(t,r,3);e--&&t(n[e],e,n););return Or(n,0,e+1)},Nt.dropWhile=function(n,t,r){var e=n?n.length:0;if(!e)return[];
var u=-1;for(t=ne(t,r,3);++u<e&&t(n[u],u,n););return Or(n,u)},Nt.fill=function(n,t,r,e){var u=n?n.length:0;if(!u)return[];for(r&&typeof r!="number"&&ie(n,t,r)&&(r=0,e=u),u=n.length,r=null==r?0:+r||0,0>r&&(r=-r>u?0:u+r),e=typeof e=="undefined"||e>u?u:+e||0,0>e&&(e+=u),u=r>e?0:e>>>0,r>>>=0;r<u;)n[r++]=t;return n},Nt.filter=Ie,Nt.flatten=function(n,t,r){var e=n?n.length:0;return r&&ie(n,t,r)&&(t=false),e?pr(n,t):[]},Nt.flattenDeep=function(n){return n&&n.length?pr(n,true):[]},Nt.flow=function(){var n=arguments,t=n.length; var u=-1;for(t=ne(t,r,3);++u<e&&t(n[u],u,n););return Or(n,u)},Nt.fill=function(n,t,r,e){var u=n?n.length:0;if(!u)return[];for(r&&typeof r!="number"&&ie(n,t,r)&&(r=0,e=u),u=n.length,r=null==r?0:+r||0,0>r&&(r=-r>u?0:u+r),e=typeof e=="undefined"||e>u?u:+e||0,0>e&&(e+=u),u=r>e?0:e>>>0,r>>>=0;r<u;)n[r++]=t;return n},Nt.filter=Ie,Nt.flatten=function(n,t,r){var e=n?n.length:0;return r&&ie(n,t,r)&&(t=false),e?pr(n,t):[]},Nt.flattenDeep=function(n){return n&&n.length?pr(n,true):[]},Nt.flow=function(){var n=arguments,t=n.length;
if(!t)return function(n){return n};if(!Kt(n,r))throw new Cu(B);return function(){for(var r=0,e=n[r].apply(this,arguments);++r<t;)e=n[r].call(this,e);return e}},Nt.flowRight=Ke,Nt.forEach=Ce,Nt.forEachRight=Te,Nt.forIn=function(n,t,r){return(typeof t!="function"||typeof r!="undefined")&&(t=Fr(t,r,3)),hr(n,t,iu)},Nt.forInRight=function(n,t,r){return t=Fr(t,r,3),_r(n,t,iu)},Nt.forOwn=function(n,t,r){return(typeof t!="function"||typeof r!="undefined")&&(t=Fr(t,r,3)),vr(n,t)},Nt.forOwnRight=function(n,t,r){return t=Fr(t,r,3),_r(n,t,$o) if(!t)return function(n){return n};if(!Kt(n,r))throw new Cu(B);return function(){for(var r=0,e=n[r].apply(this,arguments);++r<t;)e=n[r].call(this,e);return e}},Nt.flowRight=Ke,Nt.forEach=Ce,Nt.forEachRight=Te,Nt.forIn=function(n,t,r){return(typeof t!="function"||typeof r!="undefined")&&(t=Fr(t,r,3)),hr(n,t,iu)},Nt.forInRight=function(n,t,r){return t=Fr(t,r,3),_r(n,t,iu)},Nt.forOwn=function(n,t,r){return(typeof t!="function"||typeof r!="undefined")&&(t=Fr(t,r,3)),vr(n,t)},Nt.forOwnRight=function(n,t,r){return t=Fr(t,r,3),_r(n,t,$o)
},Nt.functions=ou,Nt.groupBy=Ro,Nt.indexBy=Io,Nt.initial=function(n){return ye(n,1)},Nt.intersection=function(){for(var n=[],r=-1,e=arguments.length,u=[],o=te(),i=o==t;++r<e;){var f=arguments[r];(Wo(f)||Ge(f))&&(n.push(f),u.push(i&&120<=f.length&&Ao(r&&f)))}var e=n.length,i=n[0],a=-1,c=i?i.length:0,l=[],s=u[0];n:for(;++a<c;)if(f=i[a],0>(s?Dt(s,f):o(l,f))){for(r=e;--r;){var p=u[r];if(0>(p?Dt(p,f):o(n[r],f)))continue n}s&&s.push(f),l.push(f)}return l},Nt.invert=function(n,t,r){r&&ie(n,t,r)&&(t=null),r=-1; },Nt.functions=ou,Nt.groupBy=Ro,Nt.indexBy=Io,Nt.initial=function(n){return ye(n,1)},Nt.intersection=function(){for(var n=[],r=-1,e=arguments.length,u=[],o=te(),i=o==t;++r<e;){var f=arguments[r];(Wo(f)||Ge(f))&&(n.push(f),u.push(i&&120<=f.length?Ao(r&&f):null))}var e=n.length,i=n[0],a=-1,c=i?i.length:0,l=[],s=u[0];n:for(;++a<c;)if(f=i[a],0>(s?Dt(s,f):o(l,f))){for(r=e;--r;){var p=u[r];if(0>(p?Dt(p,f):o(n[r],f)))continue n}s&&s.push(f),l.push(f)}return l},Nt.invert=function(n,t,r){r&&ie(n,t,r)&&(t=null),r=-1;
for(var e=$o(n),u=e.length,o={};++r<u;){var i=e[r],f=n[i];t?Fu.call(o,f)?o[f].push(i):o[f]=[i]:o[f]=i}return o},Nt.invoke=function(n,t){return mr(n,t,Or(arguments,2))},Nt.keys=$o,Nt.keysIn=iu,Nt.map=We,Nt.mapValues=function(n,t,r){var e={};return t=ne(t,r,3),vr(n,function(n,r,u){e[r]=t(n,r,u)}),e},Nt.matches=du,Nt.matchesProperty=function(n,t){return jr(n+"",ur(t,true))},Nt.memoize=Ve,Nt.merge=Bo,Nt.mixin=mu,Nt.negate=function(n){if(typeof n!="function")throw new Cu(B);return function(){return!n.apply(this,arguments) for(var e=$o(n),u=e.length,o={};++r<u;){var i=e[r],f=n[i];t?Fu.call(o,f)?o[f].push(i):o[f]=[i]:o[f]=i}return o},Nt.invoke=function(n,t){return mr(n,t,Or(arguments,2))},Nt.keys=$o,Nt.keysIn=iu,Nt.map=We,Nt.mapValues=function(n,t,r){var e={};return t=ne(t,r,3),vr(n,function(n,r,u){e[r]=t(n,r,u)}),e},Nt.matches=du,Nt.matchesProperty=function(n,t){return jr(n+"",ur(t,true))},Nt.memoize=Ve,Nt.merge=Bo,Nt.mixin=mu,Nt.negate=function(n){if(typeof n!="function")throw new Cu(B);return function(){return!n.apply(this,arguments)
}},Nt.omit=function(n,t,r){if(null==n)return{};if(typeof t!="function"){var e=Yt(pr(arguments,false,false,1),Ou);return ce(n,ir(iu(n),e))}return t=Fr(t,r,3),le(n,function(n,r,e){return!t(n,r,e)})},Nt.once=function(n){return Be(n,2)},Nt.pairs=function(n){for(var t=-1,r=$o(n),e=r.length,u=bu(e);++t<e;){var o=r[t];u[t]=[o,n[o]]}return u},Nt.partial=Ye,Nt.partialRight=Ze,Nt.partition=To,Nt.pick=function(n,t,r){return null==n?{}:typeof t=="function"?le(n,Fr(t,r,3)):ce(n,pr(arguments,false,false,1))},Nt.pluck=function(n,t){return We(n,Er(t)) }},Nt.omit=function(n,t,r){if(null==n)return{};if(typeof t!="function"){var e=Yt(pr(arguments,false,false,1),Ou);return ce(n,ir(iu(n),e))}return t=Fr(t,r,3),le(n,function(n,r,e){return!t(n,r,e)})},Nt.once=function(n){return Be(n,2)},Nt.pairs=function(n){for(var t=-1,r=$o(n),e=r.length,u=bu(e);++t<e;){var o=r[t];u[t]=[o,n[o]]}return u},Nt.partial=Ye,Nt.partialRight=Ze,Nt.partition=To,Nt.pick=function(n,t,r){return null==n?{}:typeof t=="function"?le(n,Fr(t,r,3)):ce(n,pr(arguments,false,false,1))},Nt.pluck=function(n,t){return We(n,Er(t))
},Nt.property=function(n){return Er(n+"")},Nt.propertyOf=function(n){return function(t){return null==n?b:n[t]}},Nt.pull=function(){var n=arguments[0];if(!n||!n.length)return n;for(var t=0,r=te(),e=arguments.length;++t<e;)for(var u=0,o=arguments[t];-1<(u=r(n,o,u));)Xu.call(n,u,1);return n},Nt.pullAt=function(t){var r=t||[],e=pr(arguments,false,false,1),u=e.length,o=tr(r,e);for(e.sort(n);u--;){var i=parseFloat(e[u]);if(i!=f&&oe(i)){var f=i;Xu.call(r,i,1)}}return o},Nt.range=function(n,t,r){r&&ie(n,t,r)&&(t=r=null),n=+n||0,r=null==r?1:+r||0,null==t?(t=n,n=0):t=+t||0; },Nt.property=function(n){return Er(n+"")},Nt.propertyOf=function(n){return function(t){return null==n?b:n[t]}},Nt.pull=function(){var n=arguments[0];if(!n||!n.length)return n;for(var t=0,r=te(),e=arguments.length;++t<e;)for(var u=0,o=arguments[t];-1<(u=r(n,o,u));)Xu.call(n,u,1);return n},Nt.pullAt=function(t){var r=t||[],e=pr(arguments,false,false,1),u=e.length,o=tr(r,e);for(e.sort(n);u--;){var i=parseFloat(e[u]);if(i!=f&&oe(i)){var f=i;Xu.call(r,i,1)}}return o},Nt.range=function(n,t,r){r&&ie(n,t,r)&&(t=r=null),n=+n||0,r=null==r?1:+r||0,null==t?(t=n,n=0):t=+t||0;
@@ -76,13 +76,14 @@ return u===er&&null==r?Nr(n,t):Ur(n,t,u(r,e,1))},Nt.sortedLastIndex=function(n,t
var s="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,u,f,a){return e||(e=u),l+=n.slice(c,a).replace(Rt,p),r&&(o=true,l+="'+__e("+r+")+'"),f&&(i=true,l+="';"+f+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),c=a+t.length,t}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(i?l.replace(ft,""):l).replace(at,"$1").replace(ct,"$1;"),l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(o?",__e=_.escape":"")+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=_u(function(){return ju(f,s+"return "+l).apply(b,a) var s="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,u,f,a){return e||(e=u),l+=n.slice(c,a).replace(Rt,p),r&&(o=true,l+="'+__e("+r+")+'"),f&&(i=true,l+="';"+f+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),c=a+t.length,t}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(i?l.replace(ft,""):l).replace(at,"$1").replace(ct,"$1;"),l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(o?",__e=_.escape":"")+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=_u(function(){return ju(f,s+"return "+l).apply(b,a)
}),t.source=l,Xe(t))throw t;return t},Nt.trim=pu,Nt.trimLeft=function(n,t,r){var e=n;return(n=u(n))?n.slice((r?ie(e,t,r):null==t)?y(n):i(n,t+"")):n},Nt.trimRight=function(n,t,r){var e=n;return(n=u(n))?(r?ie(e,t,r):null==t)?n.slice(0,d(n)+1):n.slice(0,f(n,t+"")+1):n},Nt.trunc=function(n,t,r){r&&ie(n,t,r)&&(t=null);var e=S;if(r=W,null!=t)if(He(t)){var o="separator"in t?t.separator:o,e="length"in t?+t.length||0:e;r="omission"in t?u(t.omission):r}else e=+t||0;if(n=u(n),e>=n.length)return n;if(e-=r.length,1>e)return r; }),t.source=l,Xe(t))throw t;return t},Nt.trim=pu,Nt.trimLeft=function(n,t,r){var e=n;return(n=u(n))?n.slice((r?ie(e,t,r):null==t)?y(n):i(n,t+"")):n},Nt.trimRight=function(n,t,r){var e=n;return(n=u(n))?(r?ie(e,t,r):null==t)?n.slice(0,d(n)+1):n.slice(0,f(n,t+"")+1):n},Nt.trunc=function(n,t,r){r&&ie(n,t,r)&&(t=null);var e=S;if(r=W,null!=t)if(He(t)){var o="separator"in t?t.separator:o,e="length"in t?+t.length||0:e;r="omission"in t?u(t.omission):r}else e=+t||0;if(n=u(n),e>=n.length)return n;if(e-=r.length,1>e)return r;
if(t=n.slice(0,e),null==o)return t+r;if(tu(o)){if(n.slice(e).search(o)){var i,f=n.slice(0,e);for(o.global||(o=Iu(o.source,(dt.exec(o)||"")+"g")),o.lastIndex=0;n=o.exec(f);)i=n.index;t=t.slice(0,null==i?e:i)}}else n.indexOf(o,e)!=e&&(o=t.lastIndexOf(o),-1<o&&(t=t.slice(0,o)));return t+r},Nt.unescape=function(n){return(n=u(n))&&pt.test(n)?n.replace(lt,m):n},Nt.uniqueId=function(n){var t=++Lu;return u(n)+t},Nt.words=hu,Nt.all=Re,Nt.any=$e,Nt.contains=Se,Nt.detect=Oe,Nt.foldl=Ne,Nt.foldr=Ue,Nt.head=me,Nt.include=Se,Nt.inject=Ne,mu(Nt,function(){var n={}; if(t=n.slice(0,e),null==o)return t+r;if(tu(o)){if(n.slice(e).search(o)){var i,f=n.slice(0,e);for(o.global||(o=Iu(o.source,(dt.exec(o)||"")+"g")),o.lastIndex=0;n=o.exec(f);)i=n.index;t=t.slice(0,null==i?e:i)}}else n.indexOf(o,e)!=e&&(o=t.lastIndexOf(o),-1<o&&(t=t.slice(0,o)));return t+r},Nt.unescape=function(n){return(n=u(n))&&pt.test(n)?n.replace(lt,m):n},Nt.uniqueId=function(n){var t=++Lu;return u(n)+t},Nt.words=hu,Nt.all=Re,Nt.any=$e,Nt.contains=Se,Nt.detect=Oe,Nt.foldl=Ne,Nt.foldr=Ue,Nt.head=me,Nt.include=Se,Nt.inject=Ne,mu(Nt,function(){var n={};
return vr(Nt,function(t,r){Nt.prototype[r]||(n[r]=t)}),n}(),false),Nt.sample=Fe,Nt.prototype.sample=function(n){return this.__chain__||null!=n?this.thru(function(t){return Fe(t,n)}):Fe(this.value())},Nt.VERSION=x,Pt("bind bindKey curry curryRight partial partialRight".split(" "),function(n){Nt[n].placeholder=Nt}),Pt(["filter","map","takeWhile"],function(n,t){var r=t==F,e=t==$;Lt.prototype[n]=function(n,u){var o=this.clone(),i=o.__filtered__,f=o.__iteratees__||(o.__iteratees__=[]);return o.__filtered__=i||r||e&&0>o.__dir__,f.push({iteratee:ne(n,u,3),type:t}),o return vr(Nt,function(t,r){Nt.prototype[r]||(n[r]=t)}),n}(),false),Nt.sample=Fe,Nt.prototype.sample=function(n){return this.__chain__||null!=n?this.thru(function(t){return Fe(t,n)}):Fe(this.value())},Nt.VERSION=x,Pt("bind bindKey curry curryRight partial partialRight".split(" "),function(n){Nt[n].placeholder=Nt}),Pt(["filter","map","takeWhile"],function(n,t){var r=t==F||t==$;Lt.prototype[n]=function(n,e){var u=this.clone(),o=u.__iteratees__||(u.__iteratees__=[]);return u.__filtered__=u.__filtered__||r,o.push({iteratee:ne(n,e,3),type:t}),u
}}),Pt(["drop","take"],function(n,t){var r="__"+n+"Count__",e=n+"While";Lt.prototype[n]=function(e){e=null==e?1:oo(Ku(e)||0,0);var u=this.clone();if(u.__filtered__){var o=u[r];u[r]=t?io(o,e):o+e}else(u.__views__||(u.__views__=[])).push({size:e,type:n+(0>u.__dir__?"Right":"")});return u},Lt.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()},Lt.prototype[n+"RightWhile"]=function(n,t){return this.reverse()[e](n,t).reverse()}}),Pt(["first","last"],function(n,t){var r="take"+(t?"Right":""); }}),Pt(["drop","take"],function(n,t){var r="__"+n+"Count__",e=n+"While";Lt.prototype[n]=function(e){e=null==e?1:oo(Ku(e)||0,0);var u=this.clone();if(u.__filtered__){var o=u[r];u[r]=t?io(o,e):o+e}else(u.__views__||(u.__views__=[])).push({size:e,type:n+(0>u.__dir__?"Right":"")});return u},Lt.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()},Lt.prototype[n+"RightWhile"]=function(n,t){return this.reverse()[e](n,t).reverse()}}),Pt(["first","last"],function(n,t){var r="take"+(t?"Right":"");
Lt.prototype[n]=function(){return this[r](1).value()[0]}}),Pt(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right");Lt.prototype[n]=function(){return this[r](1)}}),Pt(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?Ar:Er;Lt.prototype[n]=function(n){return this[r](e(n))}}),Lt.prototype.compact=function(){return this.filter(yu)},Lt.prototype.dropWhile=function(n,t){var r;return n=ne(n,t,3),this.filter(function(t,e,u){return r||(r=!n(t,e,u))})},Lt.prototype.reject=function(n,t){return n=ne(n,t,3),this.filter(function(t,r,e){return!n(t,r,e) Lt.prototype[n]=function(){return this[r](1).value()[0]}}),Pt(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right");Lt.prototype[n]=function(){return this[r](1)}}),Pt(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?Ar:Er;Lt.prototype[n]=function(n){return this[r](e(n))}}),Lt.prototype.compact=function(){return this.filter(yu)},Lt.prototype.dropWhile=function(n,t){var r,e,u=0>this.__dir__;return n=ne(n,t,3),this.filter(function(t,o,i){return r=r&&(u?o<e:o>e),e=o,r||(r=!n(t,o,i))})
})},Lt.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=0>n?this.takeRight(-n):this.drop(n);return typeof t!="undefined"&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r},Lt.prototype.toArray=function(){return this.drop(0)},vr(Lt.prototype,function(n,t){var r=Nt[t],e=/^(?:first|last)$/.test(t);Nt.prototype[t]=function(){function t(n){return n=[n],Yu.apply(n,o),r.apply(Nt,n)}var u=this.__wrapped__,o=arguments,i=this.__chain__,f=!!this.__actions__.length,a=u instanceof Lt,c=a&&!f;return e&&!i?c?n.call(u):r.call(Nt,this.value()):a||Wo(u)?(u=n.apply(c?u:new Lt(this),o),e||!f&&!u.__actions__||(u.__actions__||(u.__actions__=[])).push({func:Ee,args:[t],thisArg:Nt}),new Ft(u,i)):this.thru(t) },Lt.prototype.reject=function(n,t){return n=ne(n,t,3),this.filter(function(t,r,e){return!n(t,r,e)})},Lt.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=0>n?this.takeRight(-n):this.drop(n);return typeof t!="undefined"&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r},Lt.prototype.toArray=function(){return this.drop(0)},vr(Lt.prototype,function(n,t){var r=Nt[t],e=/^(?:first|last)$/.test(t);Nt.prototype[t]=function(){function t(n){return n=[n],Yu.apply(n,o),r.apply(Nt,n)}var u=this.__wrapped__,o=arguments,i=this.__chain__,f=!!this.__actions__.length,a=u instanceof Lt,c=a&&!f;
}}),Pt("concat join pop push shift sort splice unshift".split(" "),function(n){var t=Tu[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|shift)$/.test(n);Nt.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),Lt.prototype.clone=function(){var n=this.__actions__,t=this.__iteratees__,r=this.__views__,e=new Lt(this.__wrapped__);return e.__actions__=n?qt(n):null,e.__dir__=this.__dir__,e.__dropCount__=this.__dropCount__,e.__filtered__=this.__filtered__,e.__iteratees__=t?qt(t):null,e.__takeCount__=this.__takeCount__,e.__views__=r?qt(r):null,e return e&&!i?c?n.call(u):r.call(Nt,this.value()):a||Wo(u)?(u=n.apply(c?u:new Lt(this),o),e||!f&&!u.__actions__||(u.__actions__||(u.__actions__=[])).push({func:Ee,args:[t],thisArg:Nt}),new Ft(u,i)):this.thru(t)}}),Pt("concat join pop push shift sort splice unshift".split(" "),function(n){var t=Tu[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|shift)$/.test(n);Nt.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)
},Lt.prototype.reverse=function(){if(this.__filtered__){var n=new Lt(this);n.__dir__=-1,n.__filtered__=true}else n=this.clone(),n.__dir__*=-1;return n},Lt.prototype.value=function(){var n=this.__wrapped__.value();if(!Wo(n))return Wr(n,this.__actions__);var t,r=this.__dir__,e=0>r;t=n.length;for(var u=this.__views__,o=0,i=-1,f=u?u.length:0;++i<f;){var a=u[i],c=a.size;switch(a.type){case"drop":o+=c;break;case"dropRight":t-=c;break;case"take":t=io(t,o+c);break;case"takeRight":o=oo(o,t-c)}}t={start:o,end:t},i=t.start,f=t.end,t=f-i,u=this.__dropCount__,o=io(t,this.__takeCount__),e=e?f:i-1,f=(i=this.__iteratees__)?i.length:0,a=0,c=[]; })}}),Lt.prototype.clone=function(){var n=this.__actions__,t=this.__iteratees__,r=this.__views__,e=new Lt(this.__wrapped__);return e.__actions__=n?qt(n):null,e.__dir__=this.__dir__,e.__dropCount__=this.__dropCount__,e.__filtered__=this.__filtered__,e.__iteratees__=t?qt(t):null,e.__takeCount__=this.__takeCount__,e.__views__=r?qt(r):null,e},Lt.prototype.reverse=function(){if(this.__filtered__){var n=new Lt(this);n.__dir__=-1,n.__filtered__=true}else n=this.clone(),n.__dir__*=-1;return n},Lt.prototype.value=function(){var n=this.__wrapped__.value();
n:for(;t--&&a<o;){for(var e=e+r,l=-1,s=n[e];++l<f;){var p=i[l],h=p.iteratee(s,e,n),p=p.type;if(p==L)s=h;else if(!h){if(p==F)continue n;break n}}u?u--:c[a++]=s}return c},Nt.prototype.chain=function(){return ke(this)},Nt.prototype.commit=function(){return new Ft(this.value(),this.__chain__)},Nt.prototype.plant=function(n){for(var t,r=this;r instanceof Ut;){var e=ge(r);t?u.__wrapped__=e:t=e;var u=e,r=r.__wrapped__}return u.__wrapped__=n,t},Nt.prototype.reverse=function(){var n=this.__wrapped__;return n instanceof Lt?(this.__actions__.length&&(n=new Lt(this)),new Ft(n.reverse(),this.__chain__)):this.thru(function(n){return n.reverse() if(!Wo(n))return Wr(n,this.__actions__);var t,r=this.__dir__,e=0>r;t=n.length;for(var u=this.__views__,o=0,i=-1,f=u?u.length:0;++i<f;){var a=u[i],c=a.size;switch(a.type){case"drop":o+=c;break;case"dropRight":t-=c;break;case"take":t=io(t,o+c);break;case"takeRight":o=oo(o,t-c)}}t={start:o,end:t},i=t.start,f=t.end,t=f-i,u=this.__dropCount__,o=io(t,this.__takeCount__),e=e?f:i-1,f=(i=this.__iteratees__)?i.length:0,a=0,c=[];n:for(;t--&&a<o;){for(var e=e+r,l=-1,s=n[e];++l<f;){var p=i[l],h=p.iteratee(s,e,n),p=p.type;
})},Nt.prototype.toString=function(){return this.value()+""},Nt.prototype.run=Nt.prototype.toJSON=Nt.prototype.valueOf=Nt.prototype.value=function(){return Wr(this.__wrapped__,this.__actions__)},Nt.prototype.collect=Nt.prototype.map,Nt.prototype.head=Nt.prototype.first,Nt.prototype.select=Nt.prototype.filter,Nt.prototype.tail=Nt.prototype.rest,Nt}var b,x="3.3.0",A=1,j=2,k=4,E=8,R=16,I=32,O=64,C=128,T=256,S=30,W="...",N=150,U=16,F=0,L=1,$=2,B="Expected a function",z="__lodash_placeholder__",D="[object Arguments]",M="[object Array]",q="[object Boolean]",P="[object Date]",K="[object Error]",V="[object Function]",Y="[object Number]",Z="[object Object]",G="[object RegExp]",J="[object String]",X="[object ArrayBuffer]",H="[object Float32Array]",Q="[object Float64Array]",nt="[object Int8Array]",tt="[object Int16Array]",rt="[object Int32Array]",et="[object Uint8Array]",ut="[object Uint8ClampedArray]",ot="[object Uint16Array]",it="[object Uint32Array]",ft=/\b__p\+='';/g,at=/\b(__p\+=)''\+/g,ct=/(__e\(.*?\)|\b__t\))\+'';/g,lt=/&(?:amp|lt|gt|quot|#39|#96);/g,st=/[&<>"'`]/g,pt=RegExp(lt.source),ht=RegExp(st.source),_t=/<%-([\s\S]+?)%>/g,gt=/<%([\s\S]+?)%>/g,vt=/<%=([\s\S]+?)%>/g,yt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,dt=/\w*$/,mt=/^\s*function[ \n\r\t]+\w/,wt=/^0[xX]/,bt=/^\[object .+?Constructor\]$/,xt=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,At=/($^)/,jt=/[.*+?^${}()|[\]\/\\]/g,kt=RegExp(jt.source),Et=/\bthis\b/,Rt=/['\n\r\u2028\u2029\\]/g,It=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]{2,}(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),Ot=" \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",Ct="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout document isFinite parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap window WinRTError".split(" "),Tt={}; if(p==L)s=h;else if(!h){if(p==F)continue n;break n}}u?u--:c[a++]=s}return c},Nt.prototype.chain=function(){return ke(this)},Nt.prototype.commit=function(){return new Ft(this.value(),this.__chain__)},Nt.prototype.plant=function(n){for(var t,r=this;r instanceof Ut;){var e=ge(r);t?u.__wrapped__=e:t=e;var u=e,r=r.__wrapped__}return u.__wrapped__=n,t},Nt.prototype.reverse=function(){var n=this.__wrapped__;return n instanceof Lt?(this.__actions__.length&&(n=new Lt(this)),new Ft(n.reverse(),this.__chain__)):this.thru(function(n){return n.reverse()
})},Nt.prototype.toString=function(){return this.value()+""},Nt.prototype.run=Nt.prototype.toJSON=Nt.prototype.valueOf=Nt.prototype.value=function(){return Wr(this.__wrapped__,this.__actions__)},Nt.prototype.collect=Nt.prototype.map,Nt.prototype.head=Nt.prototype.first,Nt.prototype.select=Nt.prototype.filter,Nt.prototype.tail=Nt.prototype.rest,Nt}var b,x="3.3.1",A=1,j=2,k=4,E=8,R=16,I=32,O=64,C=128,T=256,S=30,W="...",N=150,U=16,F=0,L=1,$=2,B="Expected a function",z="__lodash_placeholder__",D="[object Arguments]",M="[object Array]",q="[object Boolean]",P="[object Date]",K="[object Error]",V="[object Function]",Y="[object Number]",Z="[object Object]",G="[object RegExp]",J="[object String]",X="[object ArrayBuffer]",H="[object Float32Array]",Q="[object Float64Array]",nt="[object Int8Array]",tt="[object Int16Array]",rt="[object Int32Array]",et="[object Uint8Array]",ut="[object Uint8ClampedArray]",ot="[object Uint16Array]",it="[object Uint32Array]",ft=/\b__p\+='';/g,at=/\b(__p\+=)''\+/g,ct=/(__e\(.*?\)|\b__t\))\+'';/g,lt=/&(?:amp|lt|gt|quot|#39|#96);/g,st=/[&<>"'`]/g,pt=RegExp(lt.source),ht=RegExp(st.source),_t=/<%-([\s\S]+?)%>/g,gt=/<%([\s\S]+?)%>/g,vt=/<%=([\s\S]+?)%>/g,yt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,dt=/\w*$/,mt=/^\s*function[ \n\r\t]+\w/,wt=/^0[xX]/,bt=/^\[object .+?Constructor\]$/,xt=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,At=/($^)/,jt=/[.*+?^${}()|[\]\/\\]/g,kt=RegExp(jt.source),Et=/\bthis\b/,Rt=/['\n\r\u2028\u2029\\]/g,It=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]{2,}(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),Ot=" \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",Ct="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout document isFinite parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap window WinRTError".split(" "),Tt={};
Tt[H]=Tt[Q]=Tt[nt]=Tt[tt]=Tt[rt]=Tt[et]=Tt[ut]=Tt[ot]=Tt[it]=true,Tt[D]=Tt[M]=Tt[X]=Tt[q]=Tt[P]=Tt[K]=Tt[V]=Tt["[object Map]"]=Tt[Y]=Tt[Z]=Tt[G]=Tt["[object Set]"]=Tt[J]=Tt["[object WeakMap]"]=false;var St={};St[D]=St[M]=St[X]=St[q]=St[P]=St[H]=St[Q]=St[nt]=St[tt]=St[rt]=St[Y]=St[Z]=St[G]=St[J]=St[et]=St[ut]=St[ot]=St[it]=true,St[K]=St[V]=St["[object Map]"]=St["[object Set]"]=St["[object WeakMap]"]=false;var Wt={leading:false,maxWait:0,trailing:false},Nt={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss"},Ut={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","`":"&#96;"},Ft={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'","&#96;":"`"},Lt={"function":true,object:true},$t={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Bt=Lt[typeof window]&&window!==(this&&this.window)?window:this,zt=Lt[typeof exports]&&exports&&!exports.nodeType&&exports,Lt=Lt[typeof module]&&module&&!module.nodeType&&module,Dt=zt&&Lt&&typeof global=="object"&&global; Tt[H]=Tt[Q]=Tt[nt]=Tt[tt]=Tt[rt]=Tt[et]=Tt[ut]=Tt[ot]=Tt[it]=true,Tt[D]=Tt[M]=Tt[X]=Tt[q]=Tt[P]=Tt[K]=Tt[V]=Tt["[object Map]"]=Tt[Y]=Tt[Z]=Tt[G]=Tt["[object Set]"]=Tt[J]=Tt["[object WeakMap]"]=false;var St={};St[D]=St[M]=St[X]=St[q]=St[P]=St[H]=St[Q]=St[nt]=St[tt]=St[rt]=St[Y]=St[Z]=St[G]=St[J]=St[et]=St[ut]=St[ot]=St[it]=true,St[K]=St[V]=St["[object Map]"]=St["[object Set]"]=St["[object WeakMap]"]=false;var Wt={leading:false,maxWait:0,trailing:false},Nt={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss"},Ut={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","`":"&#96;"},Ft={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'","&#96;":"`"},Lt={"function":true,object:true},$t={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Bt=Lt[typeof window]&&window!==(this&&this.window)?window:this,zt=Lt[typeof exports]&&exports&&!exports.nodeType&&exports,Lt=Lt[typeof module]&&module&&!module.nodeType&&module,Dt=zt&&Lt&&typeof global=="object"&&global;
!Dt||Dt.global!==Dt&&Dt.window!==Dt&&Dt.self!==Dt||(Bt=Dt);var Dt=Lt&&Lt.exports===zt&&zt,Mt=w();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Bt._=Mt, define(function(){return Mt})):zt&&Lt?Dt?(Lt.exports=Mt)._=Mt:zt._=Mt:Bt._=Mt}).call(this); !Dt||Dt.global!==Dt&&Dt.window!==Dt&&Dt.self!==Dt||(Bt=Dt);var Dt=Lt&&Lt.exports===zt&&zt,Mt=w();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Bt._=Mt, define(function(){return Mt})):zt&&Lt?Dt?(Lt.exports=Mt)._=Mt:zt._=Mt:Bt._=Mt}).call(this);

View File

@@ -1,8 +1,8 @@
/** /**
* @license * @license
* lodash 3.3.0 <https://lodash.com/> * lodash 3.3.1 <https://lodash.com/>
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE> * Based on Underscore.js 1.8.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <https://lodash.com/license> * Available under MIT license <https://lodash.com/license>
*/ */
@@ -12,7 +12,7 @@
var undefined; var undefined;
/** Used as the semantic version number. */ /** Used as the semantic version number. */
var VERSION = '3.3.0'; var VERSION = '3.3.1';
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1, var BIND_FLAG = 1,
@@ -1963,7 +1963,7 @@
var index = -1, var index = -1,
indexOf = getIndexOf(), indexOf = getIndexOf(),
isCommon = indexOf == baseIndexOf, isCommon = indexOf == baseIndexOf,
cache = isCommon && values.length >= 200 && createCache(values), cache = (isCommon && values.length >= 200) ? createCache(values) : null,
valuesLength = values.length; valuesLength = values.length;
if (cache) { if (cache) {
@@ -2783,7 +2783,7 @@
length = array.length, length = array.length,
isCommon = indexOf == baseIndexOf, isCommon = indexOf == baseIndexOf,
isLarge = isCommon && length >= 200, isLarge = isCommon && length >= 200,
seen = isLarge && createCache(), seen = isLarge ? createCache() : null,
result = []; result = [];
if (seen) { if (seen) {
@@ -3839,8 +3839,11 @@
} else { } else {
prereq = type == 'string' && index in object; prereq = type == 'string' && index in object;
} }
var other = object[index]; if (prereq) {
return prereq && (value === value ? value === other : other !== other); var other = object[index];
return value === value ? value === other : other !== other;
}
return false;
} }
/** /**
@@ -4588,7 +4591,7 @@
* // => 2 * // => 2
* *
* // using the `_.matches` callback shorthand * // using the `_.matches` callback shorthand
* _.findLastIndex(users, { user': 'barney', 'active': true }); * _.findLastIndex(users, { 'user': 'barney', 'active': true });
* // => 0 * // => 0
* *
* // using the `_.matchesProperty` callback shorthand * // using the `_.matchesProperty` callback shorthand
@@ -4699,7 +4702,7 @@
* @example * @example
* *
* _.indexOf([1, 2, 1, 2], 2); * _.indexOf([1, 2, 1, 2], 2);
* // => 2 * // => 1
* *
* // using `fromIndex` * // using `fromIndex`
* _.indexOf([1, 2, 1, 2], 2, 2); * _.indexOf([1, 2, 1, 2], 2, 2);
@@ -4772,7 +4775,7 @@
var value = arguments[argsIndex]; var value = arguments[argsIndex];
if (isArray(value) || isArguments(value)) { if (isArray(value) || isArguments(value)) {
args.push(value); args.push(value);
caches.push(isCommon && value.length >= 120 && createCache(argsIndex && value)); caches.push((isCommon && value.length >= 120) ? createCache(argsIndex && value) : null);
} }
} }
argsLength = args.length; argsLength = args.length;
@@ -6840,7 +6843,7 @@
* ]; * ];
* *
* // using the `_.matches` callback shorthand * // using the `_.matches` callback shorthand
* _.some(users, { user': 'barney', 'active': false }); * _.some(users, { 'user': 'barney', 'active': false });
* // => false * // => false
* *
* // using the `_.matchesProperty` callback shorthand * // using the `_.matchesProperty` callback shorthand
@@ -7376,7 +7379,7 @@
* @memberOf _ * @memberOf _
* @category Function * @category Function
* @param {Function} func The function to debounce. * @param {Function} func The function to debounce.
* @param {number} wait The number of milliseconds to delay. * @param {number} [wait=0] The number of milliseconds to delay.
* @param {Object} [options] The options object. * @param {Object} [options] The options object.
* @param {boolean} [options.leading=false] Specify invoking on the leading * @param {boolean} [options.leading=false] Specify invoking on the leading
* edge of the timeout. * edge of the timeout.
@@ -7434,7 +7437,7 @@
if (typeof func != 'function') { if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT); throw new TypeError(FUNC_ERROR_TEXT);
} }
wait = wait < 0 ? 0 : wait; wait = wait < 0 ? 0 : (+wait || 0);
if (options === true) { if (options === true) {
var leading = true; var leading = true;
trailing = false; trailing = false;
@@ -7955,7 +7958,7 @@
* @memberOf _ * @memberOf _
* @category Function * @category Function
* @param {Function} func The function to throttle. * @param {Function} func The function to throttle.
* @param {number} wait The number of milliseconds to throttle invocations to. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
* @param {Object} [options] The options object. * @param {Object} [options] The options object.
* @param {boolean} [options.leading=true] Specify invoking on the leading * @param {boolean} [options.leading=true] Specify invoking on the leading
* edge of the timeout. * edge of the timeout.
@@ -10312,10 +10315,10 @@
* var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
* compiled.source; * compiled.source;
* // => function(data) { * // => function(data) {
* var __t, __p = ''; * // var __t, __p = '';
* __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
* return __p; * // return __p;
* } * // }
* *
* // using the `source` property to inline compiled templates for meaningful * // using the `source` property to inline compiled templates for meaningful
* // line numbers in error messages and a stack trace * // line numbers in error messages and a stack trace
@@ -11429,15 +11432,13 @@
// Add `LazyWrapper` methods that accept an `iteratee` value. // Add `LazyWrapper` methods that accept an `iteratee` value.
arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
var isFilter = index == LAZY_FILTER_FLAG, var isFilter = index == LAZY_FILTER_FLAG || index == LAZY_WHILE_FLAG;
isWhile = index == LAZY_WHILE_FLAG;
LazyWrapper.prototype[methodName] = function(iteratee, thisArg) { LazyWrapper.prototype[methodName] = function(iteratee, thisArg) {
var result = this.clone(), var result = this.clone(),
filtered = result.__filtered__,
iteratees = result.__iteratees__ || (result.__iteratees__ = []); iteratees = result.__iteratees__ || (result.__iteratees__ = []);
result.__filtered__ = filtered || isFilter || (isWhile && result.__dir__ < 0); result.__filtered__ = result.__filtered__ || isFilter;
iteratees.push({ 'iteratee': getCallback(iteratee, thisArg, 3), 'type': index }); iteratees.push({ 'iteratee': getCallback(iteratee, thisArg, 3), 'type': index });
return result; return result;
}; };
@@ -11504,9 +11505,14 @@
}; };
LazyWrapper.prototype.dropWhile = function(predicate, thisArg) { LazyWrapper.prototype.dropWhile = function(predicate, thisArg) {
var done; var done,
lastIndex,
isRight = this.__dir__ < 0;
predicate = getCallback(predicate, thisArg, 3); predicate = getCallback(predicate, thisArg, 3);
return this.filter(function(value, index, array) { return this.filter(function(value, index, array) {
done = done && (isRight ? index < lastIndex : index > lastIndex);
lastIndex = index;
return done || (done = !predicate(value, index, array)); return done || (done = !predicate(value, index, array));
}); });
}; };

View File

@@ -1,6 +1,6 @@
{ {
"name": "lodash", "name": "lodash",
"version": "3.3.0", "version": "3.3.1",
"main": "lodash.src.js", "main": "lodash.src.js",
"private": true, "private": true,
"devDependencies": { "devDependencies": {

View File

@@ -833,6 +833,18 @@
} }
}); });
test('should return `false` for non-iteratee calls', 4, function() {
if (func) {
strictEqual(func(2, 0, array), false);
strictEqual(func(1, 1.1, array), false);
strictEqual(func(1, 0, { 'length': MAX_SAFE_INTEGER + 1 }), false);
strictEqual(func(1, 'b', object), false);
}
else {
skipTest(4);
}
});
test('should work with `NaN` values', 2, function() { test('should work with `NaN` values', 2, function() {
if (func) { if (func) {
strictEqual(func(NaN, 0, [NaN]), true); strictEqual(func(NaN, 0, [NaN]), true);
@@ -843,15 +855,17 @@
} }
}); });
test('should return `false` for non-iteratee calls', 4, function() { test('should not error when `index` is an object without a `toString` method', 1, function() {
if (func) { if (func) {
strictEqual(func(2, 0, array), false); try {
strictEqual(func(1, 1.1, array), false); var actual = func(1, { 'toString': null }, [1]);
strictEqual(func(1, 0, { 'length': MAX_SAFE_INTEGER + 1 }), false); } catch(e) {
strictEqual(func(1, 'b', object), false); var message = e.message;
}
strictEqual(actual, false, message || '');
} }
else { else {
skipTest(4); skipTest();
} }
}); });
}()); }());
@@ -1758,7 +1772,7 @@
.concat([2, 1]) .concat([2, 1])
.unshift(5) .unshift(5)
.tap(function(value) { value.pop(); }) .tap(function(value) { value.pop(); })
.map(function(n) { return n * n; }) .map(square)
.value(); .value();
deepEqual(actual,[25, 16, 9, 4]); deepEqual(actual,[25, 16, 9, 4]);
@@ -3212,17 +3226,17 @@
(function() { (function() {
asyncTest('should debounce a function', 2, function() { asyncTest('should debounce a function', 2, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var count = 0, var callCount = 0,
debounced = _.debounce(function() { count++; }, 32); debounced = _.debounce(function() { callCount++; }, 32);
debounced(); debounced();
debounced(); debounced();
debounced(); debounced();
strictEqual(count, 0); strictEqual(callCount, 0);
setTimeout(function() { setTimeout(function() {
strictEqual(count, 1); strictEqual(callCount, 1);
QUnit.start(); QUnit.start();
}, 96); }, 96);
} }
@@ -3273,17 +3287,17 @@
asyncTest('should apply default options correctly', 2, function() { asyncTest('should apply default options correctly', 2, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var count = 0; var callCount = 0;
var debounced = _.debounce(function(value) { var debounced = _.debounce(function(value) {
count++; callCount++;
return value; return value;
}, 32, {}); }, 32, {});
strictEqual(debounced('x'), undefined); strictEqual(debounced('x'), undefined);
setTimeout(function() { setTimeout(function() {
strictEqual(count, 1); strictEqual(callCount, 1);
QUnit.start(); QUnit.start();
}, 64); }, 64);
} }
@@ -3296,11 +3310,11 @@
asyncTest('should support a `leading` option', 7, function() { asyncTest('should support a `leading` option', 7, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var withLeading, var withLeading,
counts = [0, 0, 0]; callCounts = [0, 0, 0];
_.each([true, { 'leading': true }], function(options, index) { _.each([true, { 'leading': true }], function(options, index) {
var debounced = _.debounce(function(value) { var debounced = _.debounce(function(value) {
counts[index]++; callCounts[index]++;
return value; return value;
}, 32, options); }, 32, options);
@@ -3316,19 +3330,19 @@
}); });
var withLeadingAndTrailing = _.debounce(function() { var withLeadingAndTrailing = _.debounce(function() {
counts[2]++; callCounts[2]++;
}, 32, { 'leading': true }); }, 32, { 'leading': true });
withLeadingAndTrailing(); withLeadingAndTrailing();
withLeadingAndTrailing(); withLeadingAndTrailing();
strictEqual(counts[2], 1); strictEqual(callCounts[2], 1);
setTimeout(function() { setTimeout(function() {
deepEqual(counts, [1, 1, 2]); deepEqual(callCounts, [1, 1, 2]);
withLeading('x'); withLeading('x');
strictEqual(counts[1], 2); strictEqual(callCounts[1], 2);
QUnit.start(); QUnit.start();
}, 64); }, 64);
@@ -3403,16 +3417,16 @@
asyncTest('should cancel `maxDelayed` when `delayed` is invoked', 1, function() { asyncTest('should cancel `maxDelayed` when `delayed` is invoked', 1, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var count = 0; var callCount = 0;
var debounced = _.debounce(function() { var debounced = _.debounce(function() {
count++; callCount++;
}, 32, { 'maxWait': 64 }); }, 32, { 'maxWait': 64 });
debounced(); debounced();
setTimeout(function() { setTimeout(function() {
strictEqual(count, 1); strictEqual(callCount, 1);
QUnit.start(); QUnit.start();
}, 128); }, 128);
} }
@@ -3425,13 +3439,13 @@
asyncTest('should invoke the `trailing` call with the correct arguments and `this` binding', 2, function() { asyncTest('should invoke the `trailing` call with the correct arguments and `this` binding', 2, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var actual, var actual,
count = 0, callCount = 0,
object = {}; object = {};
var debounced = _.debounce(function(value) { var debounced = _.debounce(function(value) {
actual = [this]; actual = [this];
push.apply(actual, arguments); push.apply(actual, arguments);
return ++count != 2; return ++callCount != 2;
}, 32, { 'leading': true, 'maxWait': 64 }); }, 32, { 'leading': true, 'maxWait': 64 });
while (true) { while (true) {
@@ -3440,7 +3454,7 @@
} }
} }
setTimeout(function() { setTimeout(function() {
strictEqual(count, 2); strictEqual(callCount, 2);
deepEqual(actual, [object, 'a']); deepEqual(actual, [object, 'a']);
QUnit.start(); QUnit.start();
}, 64); }, 64);
@@ -3908,7 +3922,7 @@
if (!isNpm) { if (!isNpm) {
var args; var args;
_(array).map(function(n) { return n * n; }).dropRightWhile(function() { _(array).map(square).dropRightWhile(function() {
args = slice.call(arguments); args = slice.call(arguments);
}).value(); }).value();
@@ -3971,17 +3985,18 @@
deepEqual(_.dropWhile(objects, 'b'), objects.slice(2)); deepEqual(_.dropWhile(objects, 'b'), objects.slice(2));
}); });
test('should return a wrapped value when chaining', 2, function() { test('should work in a lazy chain sequence', 3, function() {
if (!isNpm) { if (!isNpm) {
var wrapped = _(array).dropWhile(function(num) { var wrapped = _(array).dropWhile(function(num) {
return num < 3; return num < 3;
}); });
ok(wrapped instanceof _);
deepEqual(wrapped.value(), [3, 4]); deepEqual(wrapped.value(), [3, 4]);
deepEqual(wrapped.reverse().value(), [4, 3]);
strictEqual(wrapped.last(), 4);
} }
else { else {
skipTest(2); skipTest(3);
} }
}); });
@@ -3989,7 +4004,7 @@
if (!isNpm) { if (!isNpm) {
var args; var args;
_(array).map(function(n) { return n * n; }).dropWhile(function() { _(array).map(square).dropWhile(function() {
args = slice.call(arguments); args = slice.call(arguments);
}).value(); }).value();
@@ -4794,7 +4809,7 @@
if (!isNpm) { if (!isNpm) {
var args; var args;
_(array).map(function(n) { return n * n; }).takeRightWhile(function() { _(array).map(square).takeRightWhile(function() {
args = slice.call(arguments); args = slice.call(arguments);
}).value(); }).value();
@@ -4856,17 +4871,18 @@
deepEqual(_.takeWhile(objects, 'b'), objects.slice(0, 2)); deepEqual(_.takeWhile(objects, 'b'), objects.slice(0, 2));
}); });
test('should return a wrapped value when chaining', 2, function() { test('should work in a lazy chain sequence', 3, function() {
if (!isNpm) { if (!isNpm) {
var wrapped = _(array).takeWhile(function(num) { var wrapped = _(array).takeWhile(function(num) {
return num < 3; return num < 3;
}); });
ok(wrapped instanceof _);
deepEqual(wrapped.value(), [1, 2]); deepEqual(wrapped.value(), [1, 2]);
deepEqual(wrapped.reverse().value(), [2, 1]);
strictEqual(wrapped.last(), 2);
} }
else { else {
skipTest(2); skipTest(3);
} }
}); });
@@ -4874,7 +4890,7 @@
if (!isNpm) { if (!isNpm) {
var args; var args;
_(array).map(function(n) { return n * n; }).takeWhile(function() { _(array).map(square).takeWhile(function() {
args = slice.call(arguments); args = slice.call(arguments);
}).value(); }).value();
@@ -13636,18 +13652,18 @@
(function() { (function() {
asyncTest('should throttle a function', 2, function() { asyncTest('should throttle a function', 2, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var count = 0; var callCount = 0,
var throttled = _.throttle(function() { count++; }, 32); throttled = _.throttle(function() { callCount++; }, 32);
throttled(); throttled();
throttled(); throttled();
throttled(); throttled();
var lastCount = count; var lastCount = callCount;
ok(count > 0); ok(callCount > 0);
setTimeout(function() { setTimeout(function() {
ok(count > lastCount); ok(callCount > lastCount);
QUnit.start(); QUnit.start();
}, 64); }, 64);
} }
@@ -13716,14 +13732,14 @@
asyncTest('should not trigger a trailing call when invoked once', 2, function() { asyncTest('should not trigger a trailing call when invoked once', 2, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var count = 0, var callCount = 0,
throttled = _.throttle(function() { count++; }, 32); throttled = _.throttle(function() { callCount++; }, 32);
throttled(); throttled();
strictEqual(count, 1); strictEqual(callCount, 1);
setTimeout(function() { setTimeout(function() {
strictEqual(count, 1); strictEqual(callCount, 1);
QUnit.start(); QUnit.start();
}, 64); }, 64);
} }
@@ -13736,19 +13752,19 @@
_.times(2, function(index) { _.times(2, function(index) {
asyncTest('should trigger a call when invoked repeatedly' + (index ? ' and `leading` is `false`' : ''), 1, function() { asyncTest('should trigger a call when invoked repeatedly' + (index ? ' and `leading` is `false`' : ''), 1, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var count = 0, var callCount = 0,
limit = (argv || isPhantom) ? 1000 : 320, limit = (argv || isPhantom) ? 1000 : 320,
options = index ? { 'leading': false } : {}; options = index ? { 'leading': false } : {};
var throttled = _.throttle(function() { var throttled = _.throttle(function() {
count++; callCount++;
}, 32, options); }, 32, options);
var start = +new Date; var start = +new Date;
while ((new Date - start) < limit) { while ((new Date - start) < limit) {
throttled(); throttled();
} }
var actual = count > 1; var actual = callCount > 1;
setTimeout(function() { setTimeout(function() {
ok(actual); ok(actual);
@@ -13764,10 +13780,10 @@
asyncTest('should apply default options correctly', 3, function() { asyncTest('should apply default options correctly', 3, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var count = 0; var callCount = 0;
var throttled = _.throttle(function(value) { var throttled = _.throttle(function(value) {
count++; callCount++;
return value; return value;
}, 32, {}); }, 32, {});
@@ -13775,7 +13791,7 @@
strictEqual(throttled('b'), 'a'); strictEqual(throttled('b'), 'a');
setTimeout(function() { setTimeout(function() {
strictEqual(count, 2); strictEqual(callCount, 2);
QUnit.start(); QUnit.start();
}, 256); }, 256);
} }
@@ -13842,10 +13858,10 @@
asyncTest('should not update `lastCalled`, at the end of the timeout, when `trailing` is `false`', 1, function() { asyncTest('should not update `lastCalled`, at the end of the timeout, when `trailing` is `false`', 1, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var count = 0; var callCount = 0;
var throttled = _.throttle(function() { var throttled = _.throttle(function() {
count++; callCount++;
}, 64, { 'trailing': false }); }, 64, { 'trailing': false });
throttled(); throttled();
@@ -13857,7 +13873,7 @@
}, 96); }, 96);
setTimeout(function() { setTimeout(function() {
ok(count > 1); ok(callCount > 1);
QUnit.start(); QUnit.start();
}, 192); }, 192);
} }
@@ -13887,6 +13903,28 @@
ok(pass); ok(pass);
}); });
asyncTest('_.' + methodName + ' should have a default `wait` of `0`', 1, function() {
if (!(isRhino && isModularize)) {
var callCount = 0;
var funced = func(function() {
callCount++;
});
funced();
setTimeout(function() {
funced();
strictEqual(callCount, isDebounce ? 1 : 2);
QUnit.start();
}, 32);
}
else {
skipTest();
QUnit.start();
}
});
asyncTest('_.' + methodName + ' should call `func` with the correct `this` binding', 1, function() { asyncTest('_.' + methodName + ' should call `func` with the correct `this` binding', 1, function() {
if (!(isRhino && isModularize)) { if (!(isRhino && isModularize)) {
var object = { var object = {

View File

@@ -51,6 +51,7 @@
'0' '0'
], ],
'flatten': [ 'flatten': [
'Flattens empty arrays',
'can flatten nested arrays', 'can flatten nested arrays',
'can shallowly flatten nested arrays', 'can shallowly flatten nested arrays',
'works on an arguments object', 'works on an arguments object',
@@ -83,12 +84,9 @@
] ]
}, },
'Chaining': { 'Chaining': {
'select/reject/sortBy': [ 'pop': true,
'Died on test #1' 'shift': true,
], 'splice': true,
'select/reject/sortBy in functional style': [
'Died on test #1'
],
'reverse/concat/unshift/pop/map': [ 'reverse/concat/unshift/pop/map': [
'can chain together array functions.' 'can chain together array functions.'
] ]
@@ -97,21 +95,18 @@
'filter': [ 'filter': [
'OO-filter' 'OO-filter'
], ],
'invoke': [
'handles null & undefined'
],
'map': [ 'map': [
'OO-style doubled numbers' 'OO-style doubled numbers'
], ],
'reduce': [ 'Resistant to collection length and properties changing while iterating': [
'handles a null (without initial value) properly', 'Died on test #50'
'throws an error for empty arrays with no initial value'
],
'reduceRight': [
'handles a null (without initial value) properly',
'throws an error for empty arrays with no initial value'
] ]
}, },
'Functions': { 'Functions': {
'bind': [ 'bind': [
'can bind without specifying a context',
'Died on test #2' 'Died on test #2'
], ],
'bindAll': [ 'bindAll': [
@@ -127,14 +122,23 @@
'debounce asap': true 'debounce asap': true
}, },
'Objects': { 'Objects': {
'isEqual': [ '#1929 Typed Array constructors are functions': true,
'Died on test #60', 'allKeys': true,
'Died on test #63' 'extendOwn': true,
'mapObject': true,
'matcher': true,
'matcher ': true,
'extend': [
'extend copies all properties from source'
], ],
'isFinite': [ 'isFinite': [
'Numeric strings are numbers', 'Numeric strings are numbers',
'Number instances can be finite' 'Number instances can be finite'
], ],
'isMatch': [
'inherited and own properties are checked on the test object',
'doesnt falsey match constructor on undefined/null'
],
'keys': [ 'keys': [
'is not fooled by sparse arrays; see issue #95', 'is not fooled by sparse arrays; see issue #95',
'[]' '[]'
@@ -145,33 +149,21 @@
] ]
}, },
'Utility': { 'Utility': {
'now': [
'Produces the correct time in milliseconds'
],
'_.templateSettings.variable': [ '_.templateSettings.variable': [
'"x"' '"x"'
], ],
'times': [ 'times': [
'Died on test #1',
'works as a wrapper' 'works as a wrapper'
],
'uniqueId': [
'Died on test #1'
] ]
} }
}; };
// only excuse in Sauce Labs (buggy Safari and timers) // only excuse in Sauce Labs (buggy Safari and timers)
if (!ui.isSauceLabs) { if (!ui.isSauceLabs) {
QUnit.config.excused.Utility.times.shift();
delete QUnit.config.excused.Chaining['select/reject/sortBy'];
delete QUnit.config.excused.Chaining['select/reject/sortBy in functional style'];
delete QUnit.config.excused.Functions['throttle repeatedly with results']; delete QUnit.config.excused.Functions['throttle repeatedly with results'];
delete QUnit.config.excused.Functions['more throttle does not trigger leading call when leading is set to false']; delete QUnit.config.excused.Functions['more throttle does not trigger leading call when leading is set to false'];
delete QUnit.config.excused.Functions['throttle does not trigger trailing call when trailing is set to false']; delete QUnit.config.excused.Functions['throttle does not trigger trailing call when trailing is set to false'];
delete QUnit.config.excused.Functions['debounce asap']; delete QUnit.config.excused.Functions['debounce asap'];
delete QUnit.config.excused.Objects.isEqual;
delete QUnit.config.excused.Utility.uniqueId;
} }
// load test scripts // load test scripts
document.write(ui.urlParams.loader != 'none' document.write(ui.urlParams.loader != 'none'

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
Copyright (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Copyright (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative
Reporters & Editors Reporters & Editors
Permission is hereby granted, free of charge, to any person Permission is hereby granted, free of charge, to any person

View File

@@ -1,6 +1,7 @@
(function() { (function() {
var _ = typeof require == 'function' ? require('..') : window._;
module('Arrays'); QUnit.module('Arrays');
test('first', function() { test('first', function() {
equal(_.first([1, 2, 3]), 1, 'can pull out the first element of an array'); equal(_.first([1, 2, 3]), 1, 'can pull out the first element of an array');
@@ -79,6 +80,12 @@
}); });
test('flatten', function() { test('flatten', function() {
deepEqual(_.flatten(null), [], 'Flattens supports null');
deepEqual(_.flatten(void 0), [], 'Flattens supports undefined');
deepEqual(_.flatten([[], [[]], []]), [], 'Flattens empty arrays');
deepEqual(_.flatten([[], [[]], []], true), [[]], 'Flattens empty arrays');
var list = [1, [2], [3, [[[4]]]]]; var list = [1, [2], [3, [[[4]]]]];
deepEqual(_.flatten(list), [1, 2, 3, 4], 'can flatten nested arrays'); deepEqual(_.flatten(list), [1, 2, 3, 4], 'can flatten nested arrays');
deepEqual(_.flatten(list, true), [1, 2, 3, [[[4]]]], 'can shallowly flatten nested arrays'); deepEqual(_.flatten(list, true), [1, 2, 3, [[[4]]]], 'can shallowly flatten nested arrays');
@@ -86,6 +93,11 @@
deepEqual(result, [1, 2, 3, 4], 'works on an arguments object'); deepEqual(result, [1, 2, 3, 4], 'works on an arguments object');
list = [[1], [2], [3], [[4]]]; list = [[1], [2], [3], [[4]]];
deepEqual(_.flatten(list, true), [1, 2, 3, [4]], 'can shallowly flatten arrays containing only other arrays'); deepEqual(_.flatten(list, true), [1, 2, 3, [4]], 'can shallowly flatten arrays containing only other arrays');
equal(_.flatten([_.range(10), _.range(10), 5, 1, 3], true).length, 23);
equal(_.flatten([_.range(10), _.range(10), 5, 1, 3]).length, 23);
equal(_.flatten([new Array(1000000), _.range(56000), 5, 1, 3]).length, 1056003, 'Flatten can handle massive collections');
equal(_.flatten([new Array(1000000), _.range(56000), 5, 1, 3], true).length, 1056003, 'Flatten can handle massive collections');
}); });
test('without', function() { test('without', function() {
@@ -99,6 +111,32 @@
equal(_.without(list, list[0]).length, 1, 'ditto.'); equal(_.without(list, list[0]).length, 1, 'ditto.');
}); });
test('sortedIndex', function() {
var numbers = [10, 20, 30, 40, 50], num = 35;
var indexForNum = _.sortedIndex(numbers, num);
equal(indexForNum, 3, '35 should be inserted at index 3');
var indexFor30 = _.sortedIndex(numbers, 30);
equal(indexFor30, 2, '30 should be inserted at index 2');
var objects = [{x: 10}, {x: 20}, {x: 30}, {x: 40}];
var iterator = function(obj){ return obj.x; };
strictEqual(_.sortedIndex(objects, {x: 25}, iterator), 2);
strictEqual(_.sortedIndex(objects, {x: 35}, 'x'), 3);
var context = {1: 2, 2: 3, 3: 4};
iterator = function(obj){ return this[obj]; };
strictEqual(_.sortedIndex([1, 3], 2, iterator, context), 1);
var values = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647];
var array = Array(Math.pow(2, 32) - 1);
var length = values.length;
while (length--) {
array[values[length]] = values[length];
}
equal(_.sortedIndex(array, 2147483648), 2147483648, 'should work with large indexes');
});
test('uniq', function() { test('uniq', function() {
var list = [1, 2, 1, 3, 1, 4]; var list = [1, 2, 1, 3, 1, 4];
deepEqual(_.uniq(list), [1, 2, 3, 4], 'can find the unique values of an unsorted array'); deepEqual(_.uniq(list), [1, 2, 3, 4], 'can find the unique values of an unsorted array');
@@ -116,6 +154,20 @@
list = [1, 2, 2, 3, 4, 4]; list = [1, 2, 2, 3, 4, 4];
deepEqual(_.uniq(list, true, iterator), [1, 2, 3, 4], 'iterator works with sorted array'); deepEqual(_.uniq(list, true, iterator), [1, 2, 3, 4], 'iterator works with sorted array');
var kittens = [
{kitten: 'Celery', cuteness: 8},
{kitten: 'Juniper', cuteness: 10},
{kitten: 'Spottis', cuteness: 10}
];
var expected = [
{kitten: 'Celery', cuteness: 8},
{kitten: 'Juniper', cuteness: 10}
];
deepEqual(_.uniq(kittens, true, 'cuteness'), expected, 'string iterator works with sorted array');
var result = (function(){ return _.uniq(arguments); }(1, 2, 1, 3, 1, 4)); var result = (function(){ return _.uniq(arguments); }(1, 2, 1, 3, 1, 4));
deepEqual(result, [1, 2, 3, 4], 'works on an arguments object'); deepEqual(result, [1, 2, 3, 4], 'works on an arguments object');
@@ -209,6 +261,19 @@
deepEqual(_.zip(), [], '_.zip() returns []'); deepEqual(_.zip(), [], '_.zip() returns []');
}); });
test('unzip', function() {
deepEqual(_.unzip(null), [], 'handles null');
deepEqual(_.unzip([['a', 'b'], [1, 2]]), [['a', 1], ['b', 2]]);
// complements zip
var zipped = _.zip(['fred', 'barney'], [30, 40], [true, false]);
deepEqual(_.unzip(zipped), [['fred', 'barney'], [30, 40], [true, false]]);
zipped = _.zip(['moe', 30], ['larry', 40], ['curly', 50, 'extra data']);
deepEqual(_.unzip(zipped), [['moe', 30, void 0], ['larry', 40, void 0], ['curly', 50, 'extra data']], 'Uses length of largest array');
});
test('object', function() { test('object', function() {
var result = _.object(['moe', 'larry', 'curly'], [30, 40, 50]); var result = _.object(['moe', 'larry', 'curly'], [30, 40, 50]);
var shouldBe = {moe: 30, larry: 40, curly: 50}; var shouldBe = {moe: 30, larry: 40, curly: 50};
@@ -229,7 +294,14 @@
equal(_.indexOf(numbers, 2), 1, 'can compute indexOf'); equal(_.indexOf(numbers, 2), 1, 'can compute indexOf');
var result = (function(){ return _.indexOf(arguments, 2); }(1, 2, 3)); var result = (function(){ return _.indexOf(arguments, 2); }(1, 2, 3));
equal(result, 1, 'works on an arguments object'); equal(result, 1, 'works on an arguments object');
equal(_.indexOf(null, 2), -1, 'handles nulls properly');
_.each([null, void 0, [], false], function(val) {
var msg = 'Handles: ' + (_.isArray(val) ? '[]' : val);
equal(_.indexOf(val, 2), -1, msg);
equal(_.indexOf(val, 2, -1), -1, msg);
equal(_.indexOf(val, 2, -20), -1, msg);
equal(_.indexOf(val, 2, 15), -1, msg);
});
var num = 35; var num = 35;
numbers = [10, 20, 30, 40, 50]; numbers = [10, 20, 30, 40, 50];
@@ -263,6 +335,25 @@
strictEqual(_.indexOf(array, 1, fromIndex), 0); strictEqual(_.indexOf(array, 1, fromIndex), 0);
}); });
strictEqual(_.indexOf([1, 2, 3], 1, true), 0); strictEqual(_.indexOf([1, 2, 3], 1, true), 0);
index = _.indexOf([], undefined, true);
equal(index, -1, 'empty array with truthy `isSorted` returns -1');
});
test('indexOf with NaN', function() {
strictEqual(_.indexOf([1, 2, NaN, NaN], NaN), 2, 'Expected [1, 2, NaN] to contain NaN');
strictEqual(_.indexOf([1, 2, Infinity], NaN), -1, 'Expected [1, 2, NaN] to contain NaN');
(function() {
strictEqual(_.indexOf(arguments, NaN), 2, 'Expected arguments [1, 2, NaN] to contain NaN');
}(1, 2, NaN, NaN));
});
test('indexOf with +- 0', function() {
_.each([-0, +0], function(val) {
strictEqual(_.indexOf([1, 2, val, val], val), 2);
strictEqual(_.indexOf([1, 2, val, val], -val), 2);
});
}); });
test('lastIndexOf', function() { test('lastIndexOf', function() {
@@ -276,7 +367,14 @@
equal(_.lastIndexOf(numbers, 0), 8, 'lastIndexOf the other element'); equal(_.lastIndexOf(numbers, 0), 8, 'lastIndexOf the other element');
var result = (function(){ return _.lastIndexOf(arguments, 1); }(1, 0, 1, 0, 0, 1, 0, 0, 0)); var result = (function(){ return _.lastIndexOf(arguments, 1); }(1, 0, 1, 0, 0, 1, 0, 0, 0));
equal(result, 5, 'works on an arguments object'); equal(result, 5, 'works on an arguments object');
equal(_.lastIndexOf(null, 2), -1, 'handles nulls properly');
_.each([null, void 0, [], false], function(val) {
var msg = 'Handles: ' + (_.isArray(val) ? '[]' : val);
equal(_.lastIndexOf(val, 2), -1, msg);
equal(_.lastIndexOf(val, 2, -1), -1, msg);
equal(_.lastIndexOf(val, 2, -20), -1, msg);
equal(_.lastIndexOf(val, 2, 15), -1, msg);
});
numbers = [1, 2, 3, 1, 2, 3, 1, 2, 3]; numbers = [1, 2, 3, 1, 2, 3, 1, 2, 3];
var index = _.lastIndexOf(numbers, 2, 2); var index = _.lastIndexOf(numbers, 2, 2);
@@ -316,6 +414,109 @@
}), [0, -1, -1]); }), [0, -1, -1]);
}); });
test('lastIndexOf with NaN', function() {
strictEqual(_.lastIndexOf([1, 2, NaN, NaN], NaN), 3, 'Expected [1, 2, NaN] to contain NaN');
strictEqual(_.lastIndexOf([1, 2, Infinity], NaN), -1, 'Expected [1, 2, NaN] to contain NaN');
(function() {
strictEqual(_.lastIndexOf(arguments, NaN), 3, 'Expected arguments [1, 2, NaN] to contain NaN');
}(1, 2, NaN, NaN));
});
test('lastIndexOf with +- 0', function() {
_.each([-0, +0], function(val) {
strictEqual(_.lastIndexOf([1, 2, val, val], val), 3);
strictEqual(_.lastIndexOf([1, 2, val, val], -val), 3);
strictEqual(_.lastIndexOf([-1, 1, 2], -val), -1);
});
});
test('findIndex', function() {
var objects = [
{'a': 0, 'b': 0},
{'a': 1, 'b': 1},
{'a': 2, 'b': 2},
{'a': 0, 'b': 0}
];
equal(_.findIndex(objects, function(obj) {
return obj.a === 0;
}), 0);
equal(_.findIndex(objects, function(obj) {
return obj.b * obj.a === 4;
}), 2);
equal(_.findIndex(objects, 'a'), 1, 'Uses lookupIterator');
equal(_.findIndex(objects, function(obj) {
return obj.b * obj.a === 5;
}), -1);
equal(_.findIndex(null, _.noop), -1);
strictEqual(_.findIndex(objects, function(a) {
return a.foo === null;
}), -1);
_.findIndex([{a: 1}], function(a, key, obj) {
equal(key, 0);
deepEqual(obj, [{a: 1}]);
strictEqual(this, objects, 'called with context');
}, objects);
var sparse = [];
sparse[20] = {'a': 2, 'b': 2};
equal(_.findIndex(sparse, function(obj) {
return obj && obj.b * obj.a === 4;
}), 20, 'Works with sparse arrays');
var array = [1, 2, 3, 4];
array.match = 55;
strictEqual(_.findIndex(array, function(x) { return x === 55; }), -1, 'doesn\'t match array-likes keys');
});
test('findLastIndex', function() {
var objects = [
{'a': 0, 'b': 0},
{'a': 1, 'b': 1},
{'a': 2, 'b': 2},
{'a': 0, 'b': 0}
];
equal(_.findLastIndex(objects, function(obj) {
return obj.a === 0;
}), 3);
equal(_.findLastIndex(objects, function(obj) {
return obj.b * obj.a === 4;
}), 2);
equal(_.findLastIndex(objects, 'a'), 2, 'Uses lookupIterator');
equal(_.findLastIndex(objects, function(obj) {
return obj.b * obj.a === 5;
}), -1);
equal(_.findLastIndex(null, _.noop), -1);
strictEqual(_.findLastIndex(objects, function(a) {
return a.foo === null;
}), -1);
_.findLastIndex([{a: 1}], function(a, key, obj) {
equal(key, 0);
deepEqual(obj, [{a: 1}]);
strictEqual(this, objects, 'called with context');
}, objects);
var sparse = [];
sparse[20] = {'a': 2, 'b': 2};
equal(_.findLastIndex(sparse, function(obj) {
return obj && obj.b * obj.a === 4;
}), 20, 'Works with sparse arrays');
var array = [1, 2, 3, 4];
array.match = 55;
strictEqual(_.findLastIndex(array, function(x) { return x === 55; }), -1, 'doesn\'t match array-likes keys');
});
test('range', function() { test('range', function() {
deepEqual(_.range(0), [], 'range with 0 as a first argument generates an empty array'); deepEqual(_.range(0), [], 'range with 0 as a first argument generates an empty array');
deepEqual(_.range(4), [0, 1, 2, 3], 'range with a single positive argument generates an array of elements 0,1,2,...,n-1'); deepEqual(_.range(4), [0, 1, 2, 3], 'range with a single positive argument generates an array of elements 0,1,2,...,n-1');

View File

@@ -1,6 +1,7 @@
(function() { (function() {
var _ = typeof require == 'function' ? require('..') : window._;
module('Chaining'); QUnit.module('Chaining');
test('map/flatten/reduce', function() { test('map/flatten/reduce', function() {
var lyrics = [ var lyrics = [
@@ -57,10 +58,41 @@
deepEqual(numbers, [34, 10, 8, 6, 4, 2, 10, 10], 'can chain together array functions.'); deepEqual(numbers, [34, 10, 8, 6, 4, 2, 10, 10], 'can chain together array functions.');
}); });
test('splice', function() {
var instance = _([1, 2, 3, 4, 5]).chain();
deepEqual(instance.splice(1, 3).value(), [1, 5]);
deepEqual(instance.splice(1, 0).value(), [1, 5]);
deepEqual(instance.splice(1, 1).value(), [1]);
deepEqual(instance.splice(0, 1).value(), [], '#397 Can create empty array');
});
test('shift', function() {
var instance = _([1, 2, 3]).chain();
deepEqual(instance.shift().value(), [2, 3]);
deepEqual(instance.shift().value(), [3]);
deepEqual(instance.shift().value(), [], '#397 Can create empty array');
});
test('pop', function() {
var instance = _([1, 2, 3]).chain();
deepEqual(instance.pop().value(), [1, 2]);
deepEqual(instance.pop().value(), [1]);
deepEqual(instance.pop().value(), [], '#397 Can create empty array');
});
test('chaining works in small stages', function() { test('chaining works in small stages', function() {
var o = _([1, 2, 3, 4]).chain(); var o = _([1, 2, 3, 4]).chain();
deepEqual(o.filter(function(i) { return i < 3; }).value(), [1, 2]); deepEqual(o.filter(function(i) { return i < 3; }).value(), [1, 2]);
deepEqual(o.filter(function(i) { return i > 2; }).value(), [3, 4]); deepEqual(o.filter(function(i) { return i > 2; }).value(), [3, 4]);
}); });
test('#1562: Engine proxies for chained functions', function() {
var wrapped = _(512);
strictEqual(wrapped.toJSON(), 512);
strictEqual(wrapped.valueOf(), 512);
strictEqual(+wrapped, 512);
strictEqual(wrapped.toString(), '512');
strictEqual('' + wrapped, '512');
});
}()); }());

View File

@@ -1,6 +1,7 @@
(function() { (function() {
var _ = typeof require == 'function' ? require('..') : window._;
module('Collections'); QUnit.module('Collections');
test('each', function() { test('each', function() {
_.each([1, 2, 3], function(num, i) { _.each([1, 2, 3], function(num, i) {
@@ -35,12 +36,6 @@
var a = [1, 2, 3]; var a = [1, 2, 3];
strictEqual(_.each(a, function(){}), a); strictEqual(_.each(a, function(){}), a);
strictEqual(_.each(null, function(){}), null); strictEqual(_.each(null, function(){}), null);
var b = [1, 2, 3];
b.length = 100;
answers = 0;
_.each(b, function(){ ++answers; });
equal(answers, 100, 'enumerates [0, length)');
}); });
test('forEach', function() { test('forEach', function() {
@@ -55,6 +50,94 @@
}); });
}); });
test('Iterating objects with sketchy length properties', function() {
var functions = [
'each', 'map', 'filter', 'find',
'some', 'every', 'max', 'min',
'groupBy', 'countBy', 'partition', 'indexBy'
];
var reducers = ['reduce', 'reduceRight'];
var tricks = [
{length: '5'},
{
length: {
valueOf: _.constant(5)
}
},
{length: Math.pow(2, 53) + 1},
{length: Math.pow(2, 53)},
{length: null},
{length: -2},
{length: new Number(15)}
];
expect(tricks.length * (functions.length + reducers.length + 4));
_.each(tricks, function(trick) {
var length = trick.length;
strictEqual(_.size(trick), 1, 'size on obj with length: ' + length);
deepEqual(_.toArray(trick), [length], 'toArray on obj with length: ' + length);
deepEqual(_.shuffle(trick), [length], 'shuffle on obj with length: ' + length);
deepEqual(_.sample(trick), length, 'sample on obj with length: ' + length);
_.each(functions, function(method) {
_[method](trick, function(val, key) {
strictEqual(key, 'length', method + ': ran with length = ' + val);
});
});
_.each(reducers, function(method) {
strictEqual(_[method](trick), trick.length, method);
});
});
});
test('Resistant to collection length and properties changing while iterating', function() {
var collection = [
'each', 'map', 'filter', 'find',
'some', 'every', 'max', 'min', 'reject',
'groupBy', 'countBy', 'partition', 'indexBy',
'reduce', 'reduceRight'
];
var array = [
'findIndex', 'findLastIndex'
];
var object = [
'mapObject', 'findKey', 'pick', 'omit'
];
_.each(collection.concat(array), function(method) {
var sparseArray = [1, 2, 3];
sparseArray.length = 100;
var answers = 0;
_[method](sparseArray, function(){
++answers;
return method === 'every' ? true : null;
}, {});
equal(answers, 100, method + ' enumerates [0, length)');
var growingCollection = [1, 2, 3], count = 0;
_[method](growingCollection, function() {
if (count < 10) growingCollection.push(count++);
return method === 'every' ? true : null;
}, {});
equal(count, 3, method + ' is resistant to length changes');
});
_.each(collection.concat(object), function(method) {
var changingObject = {0: 0, 1: 1}, count = 0;
_[method](changingObject, function(val) {
if (count < 10) changingObject[++count] = val + 1;
return method === 'every' ? true : null;
}, {});
equal(count, 2, method + ' is resistant to property changes');
});
});
test('map', function() { test('map', function() {
var doubled = _.map([1, 2, 3], function(num){ return num * 2; }); var doubled = _.map([1, 2, 3], function(num){ return num * 2; });
deepEqual(doubled, [2, 4, 6], 'doubled numbers'); deepEqual(doubled, [2, 4, 6], 'doubled numbers');
@@ -65,12 +148,7 @@
doubled = _([1, 2, 3]).map(function(num){ return num * 2; }); doubled = _([1, 2, 3]).map(function(num){ return num * 2; });
deepEqual(doubled, [2, 4, 6], 'OO-style doubled numbers'); deepEqual(doubled, [2, 4, 6], 'OO-style doubled numbers');
if (document.querySelectorAll) { var ids = _.map({length: 2, 0: {id: '1'}, 1: {id: '2'}}, function(n){
var ids = _.map(document.querySelectorAll('#map-test *'), function(n){ return n.id; });
deepEqual(ids, ['id1', 'id2'], 'Can use collection methods on NodeLists.');
}
ids = _.map({length: 2, 0: {id: '1'}, 1: {id: '2'}}, function(n){
return n.id; return n.id;
}); });
deepEqual(ids, ['1', '2'], 'Can use collection methods on Array-likes.'); deepEqual(ids, ['1', '2'], 'Can use collection methods on Array-likes.');
@@ -113,9 +191,7 @@
ok(_.reduce(null, _.noop, 138) === 138, 'handles a null (with initial value) properly'); ok(_.reduce(null, _.noop, 138) === 138, 'handles a null (with initial value) properly');
equal(_.reduce([], _.noop, undefined), undefined, 'undefined can be passed as a special case'); equal(_.reduce([], _.noop, undefined), undefined, 'undefined can be passed as a special case');
equal(_.reduce([_], _.noop), _, 'collection of length one with no initial value returns the first item'); equal(_.reduce([_], _.noop), _, 'collection of length one with no initial value returns the first item');
equal(_.reduce([], _.noop), undefined, 'returns undefined when collection is empty and no initial value');
raises(function() { _.reduce([], _.noop); }, TypeError, 'throws an error for empty arrays with no initial value');
raises(function() {_.reduce(null, _.noop);}, TypeError, 'handles a null (without initial value) properly');
}); });
test('foldl', function() { test('foldl', function() {
@@ -136,9 +212,7 @@
equal(_.reduceRight([_], _.noop), _, 'collection of length one with no initial value returns the first item'); equal(_.reduceRight([_], _.noop), _, 'collection of length one with no initial value returns the first item');
equal(_.reduceRight([], _.noop, undefined), undefined, 'undefined can be passed as a special case'); equal(_.reduceRight([], _.noop, undefined), undefined, 'undefined can be passed as a special case');
equal(_.reduceRight([], _.noop), undefined, 'returns undefined when collection is empty and no initial value');
raises(function() { _.reduceRight([], _.noop); }, TypeError, 'throws an error for empty arrays with no initial value');
raises(function() {_.reduceRight(null, _.noop);}, TypeError, 'handles a null (without initial value) properly');
// Assert that the correct arguments are being passed. // Assert that the correct arguments are being passed.
@@ -183,6 +257,9 @@
strictEqual(_.find(array, function(n) { return n > 2; }), 3, 'should return first found `value`'); strictEqual(_.find(array, function(n) { return n > 2; }), 3, 'should return first found `value`');
strictEqual(_.find(array, function() { return false; }), void 0, 'should return `undefined` if `value` is not found'); strictEqual(_.find(array, function() { return false; }), void 0, 'should return `undefined` if `value` is not found');
array.dontmatch = 55;
strictEqual(_.find(array, function(x) { return x === 55; }), void 0, 'iterates array-likes correctly');
// Matching an object like _.findWhere. // Matching an object like _.findWhere.
var list = [{a: 1, b: 2}, {a: 2, b: 2}, {a: 1, b: 3}, {a: 1, b: 4}, {a: 2, b: 4}]; var list = [{a: 1, b: 2}, {a: 2, b: 2}, {a: 1, b: 3}, {a: 1, b: 4}, {a: 2, b: 4}];
deepEqual(_.find(list, {a: 1}), {a: 1, b: 2}, 'can be used as findWhere'); deepEqual(_.find(list, {a: 1}), {a: 1, b: 2}, 'can be used as findWhere');
@@ -192,6 +269,25 @@
var result = _.find([1, 2, 3], function(num){ return num * 2 === 4; }); var result = _.find([1, 2, 3], function(num){ return num * 2 === 4; });
equal(result, 2, 'found the first "2" and broke the loop'); equal(result, 2, 'found the first "2" and broke the loop');
var obj = {
a: {x: 1, z: 3},
b: {x: 2, z: 2},
c: {x: 3, z: 4},
d: {x: 4, z: 1}
};
deepEqual(_.find(obj, {x: 2}), {x: 2, z: 2}, 'works on objects');
deepEqual(_.find(obj, {x: 2, z: 1}), void 0);
deepEqual(_.find(obj, function(x) {
return x.x === 4;
}), {x: 4, z: 1});
_.findIndex([{a: 1}], function(a, key, obj) {
equal(key, 0);
deepEqual(obj, [{a: 1}]);
strictEqual(this, _, 'called with context');
}, _);
}); });
test('detect', function() { test('detect', function() {
@@ -303,22 +399,66 @@
strictEqual(_.any, _.some, 'alias for any'); strictEqual(_.any, _.some, 'alias for any');
}); });
test('contains', function() { test('includes', function() {
ok(_.contains([1, 2, 3], 2), 'two is in the array'); _.each([null, void 0, 0, 1, NaN, {}, []], function(val) {
ok(!_.contains([1, 3, 9], 2), 'two is not in the array'); strictEqual(_.includes(val, 'hasOwnProperty'), false);
ok(_.contains({moe: 1, larry: 3, curly: 9}, 3) === true, '_.contains on objects checks their values'); });
ok(_([1, 2, 3]).contains(2), 'OO-style contains'); strictEqual(_.includes([1, 2, 3], 2), true, 'two is in the array');
ok(!_.includes([1, 3, 9], 2), 'two is not in the array');
strictEqual(_.includes([5, 4, 3, 2, 1], 5, true), true, 'doesn\'t delegate to binary search');
ok(_.includes({moe: 1, larry: 3, curly: 9}, 3) === true, '_.includes on objects checks their values');
ok(_([1, 2, 3]).includes(2), 'OO-style includes');
}); });
test('include', function() { test('include', function() {
strictEqual(_.contains, _.include, 'alias for contains'); strictEqual(_.includes, _.include, 'alias for includes');
}); });
test('invoke', function() { test('contains', function() {
strictEqual(_.includes, _.contains, 'alias for includes');
var numbers = [1, 2, 3, 1, 2, 3, 1, 2, 3];
strictEqual(_.includes(numbers, 1, 1), true);
strictEqual(_.includes(numbers, 1, -1), false);
strictEqual(_.includes(numbers, 1, -2), false);
strictEqual(_.includes(numbers, 1, -3), true);
strictEqual(_.includes(numbers, 1, 6), true);
strictEqual(_.includes(numbers, 1, 7), false);
});
test('includes with NaN', function() {
strictEqual(_.includes([1, 2, NaN, NaN], NaN), true, 'Expected [1, 2, NaN] to contain NaN');
strictEqual(_.includes([1, 2, Infinity], NaN), false, 'Expected [1, 2, NaN] to contain NaN');
});
test('includes with +- 0', function() {
_.each([-0, +0], function(val) {
strictEqual(_.includes([1, 2, val, val], val), true);
strictEqual(_.includes([1, 2, val, val], -val), true);
strictEqual(_.includes([-1, 1, 2], -val), false);
});
});
test('invoke', 5, function() {
var list = [[5, 1, 7], [3, 2, 1]]; var list = [[5, 1, 7], [3, 2, 1]];
var result = _.invoke(list, 'sort'); var result = _.invoke(list, 'sort');
deepEqual(result[0], [1, 5, 7], 'first array sorted'); deepEqual(result[0], [1, 5, 7], 'first array sorted');
deepEqual(result[1], [1, 2, 3], 'second array sorted'); deepEqual(result[1], [1, 2, 3], 'second array sorted');
_.invoke([{
method: function() {
deepEqual(_.toArray(arguments), [1, 2, 3], 'called with arguments');
}
}], 'method', 1, 2, 3);
deepEqual(_.invoke([{a: null}, {}, {a: _.constant(1)}], 'a'), [null, void 0, 1], 'handles null & undefined');
throws(function() {
_.invoke([{a: 1}], 'a');
}, TypeError, 'throws for non-functions');
}); });
test('invoke w/ function reference', function() { test('invoke w/ function reference', function() {
@@ -326,6 +466,10 @@
var result = _.invoke(list, Array.prototype.sort); var result = _.invoke(list, Array.prototype.sort);
deepEqual(result[0], [1, 5, 7], 'first array sorted'); deepEqual(result[0], [1, 5, 7], 'first array sorted');
deepEqual(result[1], [1, 2, 3], 'second array sorted'); deepEqual(result[1], [1, 2, 3], 'second array sorted');
deepEqual(_.invoke([1, 2, 3], function(a) {
return a + this;
}, 5), [6, 7, 8], 'receives params from invoke');
}); });
// Relevant when using ClojureScript // Relevant when using ClojureScript
@@ -346,6 +490,7 @@
test('pluck', function() { test('pluck', function() {
var people = [{name: 'moe', age: 30}, {name: 'curly', age: 50}]; var people = [{name: 'moe', age: 30}, {name: 'curly', age: 50}];
deepEqual(_.pluck(people, 'name'), ['moe', 'curly'], 'pulls names out of objects'); deepEqual(_.pluck(people, 'name'), ['moe', 'curly'], 'pulls names out of objects');
deepEqual(_.pluck(people, 'address'), [undefined, undefined], 'missing properties are returned as undefined');
//compat: most flexible handling of edge cases //compat: most flexible handling of edge cases
deepEqual(_.pluck([{'[object Object]': 1}], {}), [1]); deepEqual(_.pluck([{'[object Object]': 1}], {}), [1]);
}); });
@@ -582,24 +727,6 @@
equal(grouped['3'], 1); equal(grouped['3'], 1);
}); });
test('sortedIndex', function() {
var numbers = [10, 20, 30, 40, 50], num = 35;
var indexForNum = _.sortedIndex(numbers, num);
equal(indexForNum, 3, '35 should be inserted at index 3');
var indexFor30 = _.sortedIndex(numbers, 30);
equal(indexFor30, 2, '30 should be inserted at index 2');
var objects = [{x: 10}, {x: 20}, {x: 30}, {x: 40}];
var iterator = function(obj){ return obj.x; };
strictEqual(_.sortedIndex(objects, {x: 25}, iterator), 2);
strictEqual(_.sortedIndex(objects, {x: 35}, 'x'), 3);
var context = {1: 2, 2: 3, 3: 4};
iterator = function(obj){ return this[obj]; };
strictEqual(_.sortedIndex([1, 3], 2, iterator, context), 1);
});
test('shuffle', function() { test('shuffle', function() {
var numbers = _.range(10); var numbers = _.range(10);
var shuffled = _.shuffle(numbers); var shuffled = _.shuffle(numbers);
@@ -637,12 +764,14 @@
var numbers = _.toArray({one : 1, two : 2, three : 3}); var numbers = _.toArray({one : 1, two : 2, three : 3});
deepEqual(numbers, [1, 2, 3], 'object flattened into array'); deepEqual(numbers, [1, 2, 3], 'object flattened into array');
// test in IE < 9 if (typeof document != 'undefined') {
try { // test in IE < 9
var actual = _.toArray(document.childNodes); var actual;
} catch(ex) { } try {
actual = _.toArray(document.childNodes);
ok(_.isArray(actual), 'should not throw converting a node list'); } catch(ex) { }
deepEqual(actual, _.map(document.childNodes, _.identity), 'works on NodeList');
}
}); });
test('size', function() { test('size', function() {
@@ -693,4 +822,26 @@
}, predicate); }, predicate);
}); });
if (typeof document != 'undefined') {
test('Can use various collection methods on NodeLists', function() {
var parent = document.createElement('div');
parent.innerHTML = '<span id=id1></span>textnode<span id=id2></span>';
var elementChildren = _.filter(parent.childNodes, _.isElement);
equal(elementChildren.length, 2);
deepEqual(_.map(elementChildren, 'id'), ['id1', 'id2']);
deepEqual(_.map(parent.childNodes, 'nodeType'), [1, 3, 1]);
ok(!_.every(parent.childNodes, _.isElement));
ok(_.some(parent.childNodes, _.isElement));
function compareNode(node) {
return _.isElement(node) ? node.id.charAt(2) : void 0;
}
equal(_.max(parent.childNodes, compareNode), _.last(parent.childNodes));
equal(_.min(parent.childNodes, compareNode), _.first(parent.childNodes));
});
}
}()); }());

View File

@@ -1,6 +1,8 @@
(function() { (function() {
var _ = typeof require == 'function' ? require('..') : window._;
module('Functions'); QUnit.module('Functions');
QUnit.config.asyncRetries = 3;
test('bind', function() { test('bind', function() {
var context = {name : 'moe'}; var context = {name : 'moe'};
@@ -12,7 +14,9 @@
equal(bound(), 'name: moe', 'can do OO-style binding'); equal(bound(), 'name: moe', 'can do OO-style binding');
bound = _.bind(func, null, 'curly'); bound = _.bind(func, null, 'curly');
equal(bound(), 'name: curly', 'can bind without specifying a context'); var result = bound();
// Work around a PhantomJS bug when applying a function with null|undefined.
ok(result === 'name: curly' || result === 'name: ' + window.name, 'can bind without specifying a context');
func = function(salutation, name) { return salutation + ': ' + name; }; func = function(salutation, name) { return salutation + ': ' + name; };
func = _.bind(func, this, 'hello'); func = _.bind(func, this, 'hello');
@@ -40,7 +44,7 @@
equal(boundf().hello, 'moe curly', "When called without the new operator, it's OK to be bound to the context"); equal(boundf().hello, 'moe curly', "When called without the new operator, it's OK to be bound to the context");
ok(newBoundf instanceof F, 'a bound instance is an instance of the original function'); ok(newBoundf instanceof F, 'a bound instance is an instance of the original function');
raises(function() { _.bind('notafunction'); }, TypeError, 'throws an error when binding to a non-function'); throws(function() { _.bind('notafunction'); }, TypeError, 'throws an error when binding to a non-function');
}); });
test('partial', function() { test('partial', function() {
@@ -59,6 +63,20 @@
func = _.partial(function() { return typeof arguments[2]; }, _, 'b', _, 'd'); func = _.partial(function() { return typeof arguments[2]; }, _, 'b', _, 'd');
equal(func('a'), 'undefined', 'unfilled placeholders are undefined'); equal(func('a'), 'undefined', 'unfilled placeholders are undefined');
// passes context
function MyWidget(name, options) {
this.name = name;
this.options = options;
}
MyWidget.prototype.get = function() {
return this.name;
};
var MyWidgetWithCoolOpts = _.partial(MyWidget, _, {a: 1});
var widget = new MyWidgetWithCoolOpts('foo');
ok(widget instanceof MyWidget, 'Can partially bind a constructor');
equal(widget.get(), 'foo', 'keeps prototype');
deepEqual(widget.options, {a: 1});
}); });
test('bindAll', function() { test('bindAll', function() {
@@ -81,9 +99,9 @@
sayLast : function() { return this.sayHi(_.last(arguments)); } sayLast : function() { return this.sayHi(_.last(arguments)); }
}; };
raises(function() { _.bindAll(moe); }, Error, 'throws an error for bindAll with no functions named'); throws(function() { _.bindAll(moe); }, Error, 'throws an error for bindAll with no functions named');
raises(function() { _.bindAll(moe, 'sayBye'); }, TypeError, 'throws an error for bindAll if the given key is undefined'); throws(function() { _.bindAll(moe, 'sayBye'); }, TypeError, 'throws an error for bindAll if the given key is undefined');
raises(function() { _.bindAll(moe, 'name'); }, TypeError, 'throws an error for bindAll if the given key is not a function'); throws(function() { _.bindAll(moe, 'name'); }, TypeError, 'throws an error for bindAll if the given key is not a function');
_.bindAll(moe, 'sayHi', 'sayLast'); _.bindAll(moe, 'sayHi', 'sayLast');
curly.sayHi = moe.sayHi; curly.sayHi = moe.sayHi;
@@ -548,6 +566,16 @@
test('iteratee', function() { test('iteratee', function() {
var identity = _.iteratee(); var identity = _.iteratee();
equal(identity, _.identity, '_.iteratee is exposed as an external function.'); equal(identity, _.identity, '_.iteratee is exposed as an external function.');
function fn() {
return arguments;
}
_.each([_.iteratee(fn), _.iteratee(fn, {})], function(cb) {
equal(cb().length, 0);
deepEqual(_.toArray(cb(1, 2, 3)), _.range(1, 4));
deepEqual(_.toArray(cb(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)), _.range(1, 11));
});
}); });
}()); }());

View File

@@ -1,7 +1,9 @@
(function() { (function() {
var _ = typeof require == 'function' ? require('..') : window._;
module('Objects'); QUnit.module('Objects');
/* global iObject, iElement, iArguments, iFunction, iArray, iString, iNumber, iBoolean, iDate, iRegExp, iNaN, iNull, iUndefined, ActiveXObject */
var testElement = typeof document === 'object' ? document.createElement('div') : void 0;
test('keys', function() { test('keys', function() {
deepEqual(_.keys({one : 1, two : 2}), ['one', 'two'], 'can extract the keys from an object'); deepEqual(_.keys({one : 1, two : 2}), ['one', 'two'], 'can extract the keys from an object');
@@ -13,6 +15,62 @@
deepEqual(_.keys(1), []); deepEqual(_.keys(1), []);
deepEqual(_.keys('a'), []); deepEqual(_.keys('a'), []);
deepEqual(_.keys(true), []); deepEqual(_.keys(true), []);
// keys that may be missed if the implementation isn't careful
var trouble = {
'constructor': Object,
'valueOf': _.noop,
'hasOwnProperty': null,
'toString': 5,
'toLocaleString': undefined,
'propertyIsEnumerable': /a/,
'isPrototypeOf': this,
'__defineGetter__': Boolean,
'__defineSetter__': {},
'__lookupSetter__': false,
'__lookupGetter__': []
};
var troubleKeys = ['constructor', 'valueOf', 'hasOwnProperty', 'toString', 'toLocaleString', 'propertyIsEnumerable',
'isPrototypeOf', '__defineGetter__', '__defineSetter__', '__lookupSetter__', '__lookupGetter__'].sort();
deepEqual(_.keys(trouble).sort(), troubleKeys, 'matches non-enumerable properties');
});
test('allKeys', function() {
deepEqual(_.allKeys({one : 1, two : 2}), ['one', 'two'], 'can extract the allKeys from an object');
// the test above is not safe because it relies on for-in enumeration order
var a = []; a[1] = 0;
deepEqual(_.allKeys(a), ['1'], 'is not fooled by sparse arrays; see issue #95');
a.a = a;
deepEqual(_.allKeys(a), ['1', 'a'], 'is not fooled by sparse arrays with additional properties');
_.each([null, void 0, 1, 'a', true, NaN, {}, [], new Number(5), new Date(0)], function(val) {
deepEqual(_.allKeys(val), []);
});
// allKeys that may be missed if the implementation isn't careful
var trouble = {
constructor: Object,
valueOf: _.noop,
hasOwnProperty: null,
toString: 5,
toLocaleString: undefined,
propertyIsEnumerable: /a/,
isPrototypeOf: this
};
var troubleKeys = ['constructor', 'valueOf', 'hasOwnProperty', 'toString', 'toLocaleString', 'propertyIsEnumerable',
'isPrototypeOf'].sort();
deepEqual(_.allKeys(trouble).sort(), troubleKeys, 'matches non-enumerable properties');
function A() {}
A.prototype.foo = 'foo';
var b = new A();
b.bar = 'bar';
deepEqual(_.allKeys(b).sort(), ['bar', 'foo'], 'should include inherited keys');
function y() {}
y.x = 'z';
deepEqual(_.allKeys(y), ['x'], 'should get keys from constructor');
}); });
test('values', function() { test('values', function() {
@@ -63,7 +121,9 @@
F.prototype = {a: 'b'}; F.prototype = {a: 'b'};
var subObj = new F(); var subObj = new F();
subObj.c = 'd'; subObj.c = 'd';
deepEqual(_.extend({}, subObj), {c: 'd'}, 'extend ignores any properties but own from source'); deepEqual(_.extend({}, subObj), {a: 'b', c: 'd'}, 'extend copies all properties from source');
_.extend(subObj, {});
ok(!subObj.hasOwnProperty('a'), "extend does not convert destination object's 'in' properties to 'own' properties");
try { try {
result = {}; result = {};
@@ -76,6 +136,36 @@
strictEqual(_.extend(undefined, {a: 1}), undefined, 'extending undefined results in undefined'); strictEqual(_.extend(undefined, {a: 1}), undefined, 'extending undefined results in undefined');
}); });
test('extendOwn', function() {
var result;
equal(_.extendOwn({}, {a: 'b'}).a, 'b', 'can assign an object with the attributes of another');
equal(_.extendOwn({a: 'x'}, {a: 'b'}).a, 'b', 'properties in source override destination');
equal(_.extendOwn({x: 'x'}, {a: 'b'}).x, 'x', "properties not in source don't get overriden");
result = _.extendOwn({x: 'x'}, {a: 'a'}, {b: 'b'});
deepEqual(result, {x: 'x', a: 'a', b: 'b'}, 'can assign from multiple source objects');
result = _.assign({x: 'x'}, {a: 'a', x: 2}, {a: 'b'});
deepEqual(result, {x: 2, a: 'b'}, 'assigning from multiple source objects last property trumps');
deepEqual(_.extendOwn({}, {a: void 0, b: null}), {a: void 0, b: null}, 'assign copies undefined values');
var F = function() {};
F.prototype = {a: 'b'};
var subObj = new F();
subObj.c = 'd';
deepEqual(_.extendOwn({}, subObj), {c: 'd'}, 'assign copies own properties from source');
result = {};
deepEqual(_.assign(result, null, undefined, {a: 1}), {a: 1}, 'should not error on `null` or `undefined` sources');
_.each(['a', 5, null, false], function(val) {
strictEqual(_.assign(val, {a: 1}), val, 'assigning non-objects results in returning the non-object value');
});
strictEqual(_.extendOwn(undefined, {a: 1}), undefined, 'assigning undefined results in undefined');
result = _.extendOwn({a: 1, 0: 2, 1: '5', length: 6}, {0: 1, 1: 2, length: 2});
deepEqual(result, {a: 1, 0: 1, 1: 2, length: 2}, 'assign should treat array-like objects like normal objects');
});
test('pick', function() { test('pick', function() {
var result; var result;
result = _.pick({a: 1, b: 2, c: 3}, 'a', 'c'); result = _.pick({a: 1, b: 2, c: 3}, 'a', 'c');
@@ -87,8 +177,10 @@
result = _.pick(['a', 'b'], 1); result = _.pick(['a', 'b'], 1);
deepEqual(result, {1: 'b'}, 'can pick numeric properties'); deepEqual(result, {1: 'b'}, 'can pick numeric properties');
deepEqual(_.pick(null, 'a', 'b'), {}, 'non objects return empty object'); _.each([null, void 0], function(val) {
deepEqual(_.pick(undefined, 'toString'), {}, 'null/undefined return empty object'); deepEqual(_.pick(val, 'hasOwnProperty'), {}, 'Called with null/undefined');
deepEqual(_.pick(val, _.constant(true)), {});
});
deepEqual(_.pick(5, 'toString', 'b'), {toString: Number.prototype.toString}, 'can iterate primitives'); deepEqual(_.pick(5, 'toString', 'b'), {toString: Number.prototype.toString}, 'can iterate primitives');
var data = {a: 1, b: 2, c: 3}; var data = {a: 1, b: 2, c: 3};
@@ -108,6 +200,11 @@
deepEqual(_.pick(data, function(val, key) { deepEqual(_.pick(data, function(val, key) {
return this[key] === 3 && this === instance; return this[key] === 3 && this === instance;
}, instance), {c: 3}, 'function is given context'); }, instance), {c: 3}, 'function is given context');
ok(!_.has(_.pick({}, 'foo'), 'foo'), 'does not set own property if property not in object');
_.pick(data, function(value, key, obj) {
equal(obj, data, 'passes same object as third parameter of iteratee');
});
}); });
test('omit', function() { test('omit', function() {
@@ -419,9 +516,6 @@
b = _({x: 1, y: 2}).chain(); b = _({x: 1, y: 2}).chain();
equal(_.isEqual(a.isEqual(b), _(true)), true, '`isEqual` can be chained'); equal(_.isEqual(a.isEqual(b), _(true)), true, '`isEqual` can be chained');
// Objects from another frame.
ok(_.isEqual({}, iObject));
// Objects without a `constructor` property // Objects without a `constructor` property
if (Object.create) { if (Object.create) {
a = Object.create(null, {x: {value: 1, enumerable: true}}); a = Object.create(null, {x: {value: 1, enumerable: true}});
@@ -454,37 +548,18 @@
var args = function(){ return arguments; }; var args = function(){ return arguments; };
ok(_.isEmpty(args()), 'empty arguments object is empty'); ok(_.isEmpty(args()), 'empty arguments object is empty');
ok(!_.isEmpty(args('')), 'non-empty arguments object is not empty'); ok(!_.isEmpty(args('')), 'non-empty arguments object is not empty');
// covers collecting non-enumerable properties in IE < 9
var nonEnumProp = {'toString': 5};
ok(!_.isEmpty(nonEnumProp), 'non-enumerable property is not empty');
}); });
// Setup remote variables for iFrame tests. if (typeof document === 'object') {
var iframe = document.createElement('iframe'); test('isElement', function() {
iframe.frameBorder = iframe.height = iframe.width = 0; ok(!_.isElement('div'), 'strings are not dom elements');
document.body.appendChild(iframe); ok(_.isElement(testElement), 'an element is a DOM element');
var iDoc = (iDoc = iframe.contentDocument || iframe.contentWindow).document || iDoc; });
iDoc.write( }
'<script>' +
' parent.iElement = document.createElement("div");' +
' parent.iArguments = (function(){ return arguments; })(1, 2, 3);' +
' parent.iArray = [1, 2, 3];' +
' parent.iString = new String("hello");' +
' parent.iNumber = new Number(100);' +
' parent.iFunction = (function(){});' +
' parent.iDate = new Date();' +
' parent.iRegExp = /hi/;' +
' parent.iNaN = NaN;' +
' parent.iNull = null;' +
' parent.iBoolean = new Boolean(false);' +
' parent.iUndefined = undefined;' +
' parent.iObject = {};' +
'</script>'
);
iDoc.close();
test('isElement', function() {
ok(!_.isElement('div'), 'strings are not dom elements');
ok(_.isElement(document.body), 'the body tag is a DOM element');
ok(_.isElement(iElement), 'even from another frame');
});
test('isArguments', function() { test('isArguments', function() {
var args = (function(){ return arguments; }(1, 2, 3)); var args = (function(){ return arguments; }(1, 2, 3));
@@ -493,16 +568,15 @@
ok(_.isArguments(args), 'but the arguments object is an arguments object'); ok(_.isArguments(args), 'but the arguments object is an arguments object');
ok(!_.isArguments(_.toArray(args)), 'but not when it\'s converted into an array'); ok(!_.isArguments(_.toArray(args)), 'but not when it\'s converted into an array');
ok(!_.isArguments([1, 2, 3]), 'and not vanilla arrays.'); ok(!_.isArguments([1, 2, 3]), 'and not vanilla arrays.');
ok(_.isArguments(iArguments), 'even from another frame');
}); });
test('isObject', function() { test('isObject', function() {
ok(_.isObject(arguments), 'the arguments object is object'); ok(_.isObject(arguments), 'the arguments object is object');
ok(_.isObject([1, 2, 3]), 'and arrays'); ok(_.isObject([1, 2, 3]), 'and arrays');
ok(_.isObject(document.body), 'and DOM element'); if (testElement) {
ok(_.isObject(iElement), 'even from another frame'); ok(_.isObject(testElement), 'and DOM element');
}
ok(_.isObject(function () {}), 'and functions'); ok(_.isObject(function () {}), 'and functions');
ok(_.isObject(iFunction), 'even from another frame');
ok(!_.isObject(null), 'but not null'); ok(!_.isObject(null), 'but not null');
ok(!_.isObject(undefined), 'and not undefined'); ok(!_.isObject(undefined), 'and not undefined');
ok(!_.isObject('string'), 'and not string'); ok(!_.isObject('string'), 'and not string');
@@ -515,16 +589,17 @@
ok(!_.isArray(undefined), 'undefined vars are not arrays'); ok(!_.isArray(undefined), 'undefined vars are not arrays');
ok(!_.isArray(arguments), 'the arguments object is not an array'); ok(!_.isArray(arguments), 'the arguments object is not an array');
ok(_.isArray([1, 2, 3]), 'but arrays are'); ok(_.isArray([1, 2, 3]), 'but arrays are');
ok(_.isArray(iArray), 'even from another frame');
}); });
test('isString', function() { test('isString', function() {
var obj = new String('I am a string object'); var obj = new String('I am a string object');
ok(!_.isString(document.body), 'the document body is not a string'); if (testElement) {
ok(!_.isString(testElement), 'an element is not a string');
}
ok(_.isString([1, 2, 3].join(', ')), 'but strings are'); ok(_.isString([1, 2, 3].join(', ')), 'but strings are');
ok(_.isString(iString), 'even from another frame'); strictEqual(_.isString('I am a string literal'), true, 'string literals are');
ok(_.isString('I am a string literal'), 'string literals are');
ok(_.isString(obj), 'so are String objects'); ok(_.isString(obj), 'so are String objects');
strictEqual(_.isString(1), false);
}); });
test('isNumber', function() { test('isNumber', function() {
@@ -534,7 +609,6 @@
ok(_.isNumber(3 * 4 - 7 / 10), 'but numbers are'); ok(_.isNumber(3 * 4 - 7 / 10), 'but numbers are');
ok(_.isNumber(NaN), 'NaN *is* a number'); ok(_.isNumber(NaN), 'NaN *is* a number');
ok(_.isNumber(Infinity), 'Infinity is a number'); ok(_.isNumber(Infinity), 'Infinity is a number');
ok(_.isNumber(iNumber), 'even from another frame');
ok(!_.isNumber('1'), 'numeric strings are not numbers'); ok(!_.isNumber('1'), 'numeric strings are not numbers');
}); });
@@ -549,7 +623,6 @@
ok(!_.isBoolean(null), 'null is not a boolean'); ok(!_.isBoolean(null), 'null is not a boolean');
ok(_.isBoolean(true), 'but true is'); ok(_.isBoolean(true), 'but true is');
ok(_.isBoolean(false), 'and so is false'); ok(_.isBoolean(false), 'and so is false');
ok(_.isBoolean(iBoolean), 'even from another frame');
}); });
test('isFunction', function() { test('isFunction', function() {
@@ -557,21 +630,35 @@
ok(!_.isFunction([1, 2, 3]), 'arrays are not functions'); ok(!_.isFunction([1, 2, 3]), 'arrays are not functions');
ok(!_.isFunction('moe'), 'strings are not functions'); ok(!_.isFunction('moe'), 'strings are not functions');
ok(_.isFunction(_.isFunction), 'but functions are'); ok(_.isFunction(_.isFunction), 'but functions are');
ok(_.isFunction(iFunction), 'even from another frame');
ok(_.isFunction(function(){}), 'even anonymous ones'); ok(_.isFunction(function(){}), 'even anonymous ones');
if (testElement) {
ok(!_.isFunction(testElement), 'elements are not functions');
}
}); });
if (typeof Int8Array !== 'undefined') {
test('#1929 Typed Array constructors are functions', function() {
_.chain(['Float32Array', 'Float64Array', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array'])
.map(_.propertyOf(typeof GLOBAL != 'undefined' ? GLOBAL : window))
.compact()
.each(function(TypedArray) {
// PhantomJS reports `typeof UInt8Array == 'object'` and doesn't report toString TypeArray
// as a function
strictEqual(_.isFunction(TypedArray), Object.prototype.toString.call(TypedArray) === '[object Function]');
});
});
}
test('isDate', function() { test('isDate', function() {
ok(!_.isDate(100), 'numbers are not dates'); ok(!_.isDate(100), 'numbers are not dates');
ok(!_.isDate({}), 'objects are not dates'); ok(!_.isDate({}), 'objects are not dates');
ok(_.isDate(new Date()), 'but dates are'); ok(_.isDate(new Date()), 'but dates are');
ok(_.isDate(iDate), 'even from another frame');
}); });
test('isRegExp', function() { test('isRegExp', function() {
ok(!_.isRegExp(_.identity), 'functions are not RegExps'); ok(!_.isRegExp(_.identity), 'functions are not RegExps');
ok(_.isRegExp(/identity/), 'but RegExps are'); ok(_.isRegExp(/identity/), 'but RegExps are');
ok(_.isRegExp(iRegExp), 'even from another frame');
}); });
test('isFinite', function() { test('isFinite', function() {
@@ -595,7 +682,6 @@
ok(!_.isNaN(null), 'null is not NaN'); ok(!_.isNaN(null), 'null is not NaN');
ok(!_.isNaN(0), '0 is not NaN'); ok(!_.isNaN(0), '0 is not NaN');
ok(_.isNaN(NaN), 'but NaN is'); ok(_.isNaN(NaN), 'but NaN is');
ok(_.isNaN(iNaN), 'even from another frame');
ok(_.isNaN(new Number(NaN)), 'wrapped NaN is still NaN'); ok(_.isNaN(new Number(NaN)), 'wrapped NaN is still NaN');
}); });
@@ -603,7 +689,6 @@
ok(!_.isNull(undefined), 'undefined is not null'); ok(!_.isNull(undefined), 'undefined is not null');
ok(!_.isNull(NaN), 'NaN is not null'); ok(!_.isNull(NaN), 'NaN is not null');
ok(_.isNull(null), 'but null is'); ok(_.isNull(null), 'but null is');
ok(_.isNull(iNull), 'even from another frame');
}); });
test('isUndefined', function() { test('isUndefined', function() {
@@ -613,20 +698,20 @@
ok(!_.isUndefined(NaN), 'NaN is defined'); ok(!_.isUndefined(NaN), 'NaN is defined');
ok(_.isUndefined(), 'nothing is undefined'); ok(_.isUndefined(), 'nothing is undefined');
ok(_.isUndefined(undefined), 'undefined is undefined'); ok(_.isUndefined(undefined), 'undefined is undefined');
ok(_.isUndefined(iUndefined), 'even from another frame');
}); });
if (window.ActiveXObject) { test('isError', function() {
test('IE host objects', function() { ok(!_.isError(1), 'numbers are not Errors');
var xml = new ActiveXObject('Msxml2.DOMDocument.3.0'); ok(!_.isError(null), 'null is not an Error');
ok(!_.isNumber(xml)); ok(!_.isError(Error), 'functions are not Errors');
ok(!_.isBoolean(xml)); ok(_.isError(new Error()), 'Errors are Errors');
ok(!_.isNaN(xml)); ok(_.isError(new EvalError()), 'EvalErrors are Errors');
ok(!_.isFunction(xml)); ok(_.isError(new RangeError()), 'RangeErrors are Errors');
ok(!_.isNull(xml)); ok(_.isError(new ReferenceError()), 'ReferenceErrors are Errors');
ok(!_.isUndefined(xml)); ok(_.isError(new SyntaxError()), 'SyntaxErrors are Errors');
}); ok(_.isError(new TypeError()), 'TypeErrors are Errors');
} ok(_.isError(new URIError()), 'URIErrors are Errors');
});
test('tap', function() { test('tap', function() {
var intercepted = null; var intercepted = null;
@@ -658,22 +743,62 @@
strictEqual(_.has(undefined, 'foo'), false, 'has() returns false for undefined'); strictEqual(_.has(undefined, 'foo'), false, 'has() returns false for undefined');
}); });
test('matches', function() { test('isMatch', function() {
var moe = {name: 'Moe Howard', hair: true};
var curly = {name: 'Curly Howard', hair: false};
equal(_.isMatch(moe, {hair: true}), true, 'Returns a boolean');
equal(_.isMatch(curly, {hair: true}), false, 'Returns a boolean');
equal(_.isMatch(5, {__x__: undefined}), false, 'can match undefined props on primitives');
equal(_.isMatch({__x__: undefined}, {__x__: undefined}), true, 'can match undefined props');
equal(_.isMatch(null, {}), true, 'Empty spec called with null object returns true');
equal(_.isMatch(null, {a: 1}), false, 'Non-empty spec called with null object returns false');
_.each([null, undefined], function(item) { strictEqual(_.isMatch(item, null), true, 'null matches null'); });
_.each([null, undefined], function(item) { strictEqual(_.isMatch(item, null), true, 'null matches {}'); });
strictEqual(_.isMatch({b: 1}, {a: undefined}), false, 'handles undefined values (1683)');
_.each([true, 5, NaN, null, undefined], function(item) {
strictEqual(_.isMatch({a: 1}, item), true, 'treats primitives as empty');
});
function Prototest() {}
Prototest.prototype.x = 1;
var specObj = new Prototest;
equal(_.isMatch({x: 2}, specObj), true, 'spec is restricted to own properties');
specObj.y = 5;
equal(_.isMatch({x: 1, y: 5}, specObj), true);
equal(_.isMatch({x: 1, y: 4}, specObj), false);
ok(_.isMatch(specObj, {x: 1, y: 5}), 'inherited and own properties are checked on the test object');
Prototest.x = 5;
ok(_.isMatch({x: 5, y: 1}, Prototest), 'spec can be a function');
//null edge cases
var oCon = {'constructor': Object};
deepEqual(_.map([null, undefined, 5, {}], _.partial(_.isMatch, _, oCon)), [false, false, false, true], 'doesnt falsey match constructor on undefined/null');
});
test('matcher', function() {
var moe = {name: 'Moe Howard', hair: true}; var moe = {name: 'Moe Howard', hair: true};
var curly = {name: 'Curly Howard', hair: false}; var curly = {name: 'Curly Howard', hair: false};
var stooges = [moe, curly]; var stooges = [moe, curly];
equal(_.matches({hair: true})(moe), true, 'Returns a boolean'); equal(_.matcher({hair: true})(moe), true, 'Returns a boolean');
equal(_.matches({hair: true})(curly), false, 'Returns a boolean'); equal(_.matcher({hair: true})(curly), false, 'Returns a boolean');
equal(_.matches({__x__: undefined})(5), false, 'can match undefined props on primitives'); equal(_.matcher({__x__: undefined})(5), false, 'can match undefined props on primitives');
equal(_.matches({__x__: undefined})({__x__: undefined}), true, 'can match undefined props'); equal(_.matcher({__x__: undefined})({__x__: undefined}), true, 'can match undefined props');
equal(_.matches({})(null), true, 'Empty spec called with null object returns true'); equal(_.matcher({})(null), true, 'Empty spec called with null object returns true');
equal(_.matches({a: 1})(null), false, 'Non-empty spec called with null object returns false'); equal(_.matcher({a: 1})(null), false, 'Non-empty spec called with null object returns false');
ok(_.find(stooges, _.matches({hair: false})) === curly, 'returns a predicate that can be used by finding functions.'); ok(_.find(stooges, _.matcher({hair: false})) === curly, 'returns a predicate that can be used by finding functions.');
ok(_.find(stooges, _.matches(moe)) === moe, 'can be used to locate an object exists in a collection.'); ok(_.find(stooges, _.matcher(moe)) === moe, 'can be used to locate an object exists in a collection.');
deepEqual(_.where([null, undefined], {a: 1}), [], 'Do not throw on null values.'); deepEqual(_.where([null, undefined], {a: 1}), [], 'Do not throw on null values.');
deepEqual(_.where([null, undefined], null), [null, undefined], 'null matches null'); deepEqual(_.where([null, undefined], null), [null, undefined], 'null matches null');
@@ -687,22 +812,22 @@
function Prototest() {} function Prototest() {}
Prototest.prototype.x = 1; Prototest.prototype.x = 1;
var specObj = new Prototest; var specObj = new Prototest;
var protospec = _.matches(specObj); var protospec = _.matcher(specObj);
equal(protospec({x: 2}), true, 'spec is restricted to own properties'); equal(protospec({x: 2}), true, 'spec is restricted to own properties');
specObj.y = 5; specObj.y = 5;
protospec = _.matches(specObj); protospec = _.matcher(specObj);
equal(protospec({x: 1, y: 5}), true); equal(protospec({x: 1, y: 5}), true);
equal(protospec({x: 1, y: 4}), false); equal(protospec({x: 1, y: 4}), false);
ok(_.matches({x: 1, y: 5})(specObj), 'inherited and own properties are checked on the test object'); ok(_.matcher({x: 1, y: 5})(specObj), 'inherited and own properties are checked on the test object');
Prototest.x = 5; Prototest.x = 5;
ok(_.matches(Prototest)({x: 5, y: 1}), 'spec can be a function'); ok(_.matcher(Prototest)({x: 5, y: 1}), 'spec can be a function');
// #1729 // #1729
var o = {'b': 1}; var o = {'b': 1};
var m = _.matches(o); var m = _.matcher(o);
equal(m({'b': 1}), true); equal(m({'b': 1}), true);
o.b = 2; o.b = 2;
@@ -711,8 +836,159 @@
//null edge cases //null edge cases
var oCon = _.matches({'constructor': Object}); var oCon = _.matcher({'constructor': Object});
deepEqual(_.map([null, undefined, 5, {}], oCon), [false, false, false, true], 'doesnt fasley match constructor on undefined/null'); deepEqual(_.map([null, undefined, 5, {}], oCon), [false, false, false, true], 'doesnt falsey match constructor on undefined/null');
}); });
test('matcher', function() {
var moe = {name: 'Moe Howard', hair: true};
var curly = {name: 'Curly Howard', hair: false};
var stooges = [moe, curly];
equal(_.matcher({hair: true})(moe), true, 'Returns a boolean');
equal(_.matcher({hair: true})(curly), false, 'Returns a boolean');
equal(_.matcher({__x__: undefined})(5), false, 'can match undefined props on primitives');
equal(_.matcher({__x__: undefined})({__x__: undefined}), true, 'can match undefined props');
equal(_.matcher({})(null), true, 'Empty spec called with null object returns true');
equal(_.matcher({a: 1})(null), false, 'Non-empty spec called with null object returns false');
ok(_.find(stooges, _.matcher({hair: false})) === curly, 'returns a predicate that can be used by finding functions.');
ok(_.find(stooges, _.matcher(moe)) === moe, 'can be used to locate an object exists in a collection.');
deepEqual(_.where([null, undefined], {a: 1}), [], 'Do not throw on null values.');
deepEqual(_.where([null, undefined], null), [null, undefined], 'null matches null');
deepEqual(_.where([null, undefined], {}), [null, undefined], 'null matches {}');
deepEqual(_.where([{b: 1}], {a: undefined}), [], 'handles undefined values (1683)');
_.each([true, 5, NaN, null, undefined], function(item) {
deepEqual(_.where([{a: 1}], item), [{a: 1}], 'treats primitives as empty');
});
function Prototest() {}
Prototest.prototype.x = 1;
var specObj = new Prototest;
var protospec = _.matcher(specObj);
equal(protospec({x: 2}), true, 'spec is restricted to own properties');
specObj.y = 5;
protospec = _.matcher(specObj);
equal(protospec({x: 1, y: 5}), true);
equal(protospec({x: 1, y: 4}), false);
ok(_.matcher({x: 1, y: 5})(specObj), 'inherited and own properties are checked on the test object');
Prototest.x = 5;
ok(_.matcher(Prototest)({x: 5, y: 1}), 'spec can be a function');
// #1729
var o = {'b': 1};
var m = _.matcher(o);
equal(m({'b': 1}), true);
o.b = 2;
o.a = 1;
equal(m({'b': 1}), true, 'changing spec object doesnt change matches result');
//null edge cases
var oCon = _.matcher({'constructor': Object});
deepEqual(_.map([null, undefined, 5, {}], oCon), [false, false, false, true], 'doesnt falsey match constructor on undefined/null');
});
test('findKey', function() {
var objects = {
a: {'a': 0, 'b': 0},
b: {'a': 1, 'b': 1},
c: {'a': 2, 'b': 2}
};
equal(_.findKey(objects, function(obj) {
return obj.a === 0;
}), 'a');
equal(_.findKey(objects, function(obj) {
return obj.b * obj.a === 4;
}), 'c');
equal(_.findKey(objects, 'a'), 'b', 'Uses lookupIterator');
equal(_.findKey(objects, function(obj) {
return obj.b * obj.a === 5;
}), undefined);
strictEqual(_.findKey([1, 2, 3, 4, 5, 6], function(obj) {
return obj === 3;
}), '2', 'Keys are strings');
strictEqual(_.findKey(objects, function(a) {
return a.foo === null;
}), undefined);
_.findKey({a: {a: 1}}, function(a, key, obj) {
equal(key, 'a');
deepEqual(obj, {a: {a: 1}});
strictEqual(this, objects, 'called with context');
}, objects);
var array = [1, 2, 3, 4];
array.match = 55;
strictEqual(_.findKey(array, function(x) { return x === 55; }), 'match', 'matches array-likes keys');
});
test('mapObject', function() {
var obj = {'a': 1, 'b': 2};
var objects = {
a: {'a': 0, 'b': 0},
b: {'a': 1, 'b': 1},
c: {'a': 2, 'b': 2}
};
deepEqual(_.mapObject(obj, function(val) {
return val * 2;
}), {'a': 2, 'b': 4}, 'simple objects');
deepEqual(_.mapObject(objects, function(val) {
return _.reduce(val, function(memo,v){
return memo + v;
},0);
}), {'a': 0, 'b': 2, 'c': 4}, 'nested objects');
deepEqual(_.mapObject(obj, function(val,key,obj) {
return obj[key] * 2;
}), {'a': 2, 'b': 4}, 'correct keys');
deepEqual(_.mapObject([1,2], function(val) {
return val * 2;
}), {'0': 2, '1': 4}, 'check behavior for arrays');
deepEqual(_.mapObject(obj, function(val) {
return val * this.multiplier;
}, {multiplier : 3}), {'a': 3, 'b': 6}, 'keep context');
deepEqual(_.mapObject({a: 1}, function() {
return this.length;
}, [1,2]), {'a': 2}, 'called with context');
var ids = _.mapObject({length: 2, 0: {id: '1'}, 1: {id: '2'}}, function(n){
return n.id;
});
deepEqual(ids, {'length': undefined, '0': '1', '1': '2'}, 'Check with array-like objects');
// Passing a property name like _.pluck.
var people = {'a': {name : 'moe', age : 30}, 'b': {name : 'curly', age : 50}};
deepEqual(_.mapObject(people, 'name'), {'a': 'moe', 'b': 'curly'}, 'predicate string map to object properties');
_.each([null, void 0, 1, 'abc', [], {}, undefined], function(val){
deepEqual(_.mapObject(val, _.identity), {}, 'mapValue identity');
});
var Proto = function(){this.a = 1;};
Proto.prototype.b = 1;
var protoObj = new Proto();
deepEqual(_.mapObject(protoObj, _.identity), {a: 1}, 'ignore inherited values from prototypes');
});
}()); }());

View File

@@ -1,8 +1,8 @@
(function() { (function() {
var _ = typeof require == 'function' ? require('..') : window._;
var templateSettings; var templateSettings;
module('Utility', { QUnit.module('Utility', {
setup: function() { setup: function() {
templateSettings = _.clone(_.templateSettings); templateSettings = _.clone(_.templateSettings);
@@ -21,13 +21,13 @@
}); });
test('identity', function() { test('identity', function() {
var moe = {name : 'moe'}; var stooge = {name : 'moe'};
equal(_.identity(moe), moe, 'moe is the same as his identity'); equal(_.identity(stooge), stooge, 'stooge is the same as his identity');
}); });
test('constant', function() { test('constant', function() {
var moe = {name : 'moe'}; var stooge = {name : 'moe'};
equal(_.constant(moe)(), moe, 'should create a function that returns moe'); equal(_.constant(stooge)(), stooge, 'should create a function that returns stooge');
}); });
test('noop', function() { test('noop', function() {
@@ -35,8 +35,28 @@
}); });
test('property', function() { test('property', function() {
var moe = {name : 'moe'}; var stooge = {name : 'moe'};
equal(_.property('name')(moe), 'moe', 'should return the property with the given name'); equal(_.property('name')(stooge), 'moe', 'should return the property with the given name');
equal(_.property('name')(null), undefined, 'should return undefined for null values');
equal(_.property('name')(undefined), undefined, 'should return undefined for undefined values');
});
test('propertyOf', function() {
var stoogeRanks = _.propertyOf({curly: 2, moe: 1, larry: 3});
equal(stoogeRanks('curly'), 2, 'should return the property with the given name');
equal(stoogeRanks(null), undefined, 'should return undefined for null values');
equal(stoogeRanks(undefined), undefined, 'should return undefined for undefined values');
function MoreStooges() { this.shemp = 87; }
MoreStooges.prototype = {curly: 2, moe: 1, larry: 3};
var moreStoogeRanks = _.propertyOf(new MoreStooges());
equal(moreStoogeRanks('curly'), 2, 'should return properties from further up the prototype chain');
var nullPropertyOf = _.propertyOf(null);
equal(nullPropertyOf('curly'), undefined, 'should return undefined when obj is null');
var undefPropertyOf = _.propertyOf(undefined);
equal(undefPropertyOf('curly'), undefined, 'should return undefined when obj is undefined');
}); });
test('random', function() { test('random', function() {
@@ -268,6 +288,41 @@
strictEqual(_.result(null, 'x'), undefined); strictEqual(_.result(null, 'x'), undefined);
}); });
test('result returns a default value if object is null or undefined', function() {
strictEqual(_.result(null, 'b', 'default'), 'default');
strictEqual(_.result(undefined, 'c', 'default'), 'default');
strictEqual(_.result(''.match('missing'), 1, 'default'), 'default');
});
test('result returns a default value if property of object is missing', function() {
strictEqual(_.result({d: null}, 'd', 'default'), null);
strictEqual(_.result({e: false}, 'e', 'default'), false);
});
test('result only returns the default value if the object does not have the property or is undefined', function() {
strictEqual(_.result({}, 'b', 'default'), 'default');
strictEqual(_.result({d: undefined}, 'd', 'default'), 'default');
});
test('result does not return the default if the property of an object is found in the prototype', function() {
var Foo = function(){};
Foo.prototype.bar = 1;
strictEqual(_.result(new Foo, 'bar', 2), 1);
});
test('result does use the fallback when the result of invoking the property is undefined', function() {
var obj = {a: function() {}};
strictEqual(_.result(obj, 'a', 'failed'), undefined);
});
test('result fallback can use a function', function() {
var obj = {a: [1, 2, 3]};
strictEqual(_.result(obj, 'b', _.constant(5)), 5);
strictEqual(_.result(obj, 'b', function() {
return this.a;
}), obj.a, 'called with context');
});
test('_.templateSettings.variable', function() { test('_.templateSettings.variable', function() {
var s = '<%=data.x%>'; var s = '<%=data.x%>';
var data = {x: 'x'}; var data = {x: 'x'};

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff