Add floating argument to _.random. [closes #354]

This commit is contained in:
John-David Dalton
2013-09-20 00:21:42 -07:00
parent fca3a14410
commit ca81f1b2e8
9 changed files with 149 additions and 63 deletions

39
dist/lodash.compat.js vendored
View File

@@ -969,7 +969,7 @@
*
* @private
* @param {*} value The value to clone.
* @param {boolean} [deep=false] A flag to indicate a deep clone.
* @param {boolean} [deep=false] Specify a deep clone.
* @param {Function} [callback] The function to customize cloning values.
* @param {Array} [stackA=[]] Tracks traversed source objects.
* @param {Array} [stackB=[]] Associates clones with source counterparts.
@@ -1955,7 +1955,7 @@
* @memberOf _
* @category Objects
* @param {*} value The value to clone.
* @param {boolean} [deep=false] A flag to indicate a deep clone.
* @param {boolean} [deep=false] Specify a deep clone.
* @param {Function} [callback] The function to customize cloning values.
* @param {*} [thisArg] The `this` binding of `callback`.
* @returns {*} Returns the cloned `value`.
@@ -5938,35 +5938,56 @@
/**
* Produces a random number between `min` and `max` (inclusive). If only one
* argument is provided a number between `0` and the given number will be
* returned.
* returned. If `floating` is truey or either `min` or `max` are floats a
* floating-point number will be returned instead of an integer.
*
* @static
* @memberOf _
* @category Utilities
* @param {number} [min=0] The minimum possible value.
* @param {number} [max=1] The maximum possible value.
* @param {boolean} [floating=false] Specify returning a floating-point number.
* @returns {number} Returns a random number.
* @example
*
* _.random(0, 5);
* // => a number between 0 and 5
* // => an integer between 0 and 5
*
* _.random(5);
* // => also a number between 0 and 5
* // => also an integer between 0 and 5
*
* _.random(5, true);
* // => a floating-point number between 0 and 5
*
* _.random(1.2, 5.2);
* // => a floating-point number between 1.2 and 5.2
*/
function random(min, max) {
if (min == null && max == null) {
function random(min, max, floating) {
var noMin = min == null,
noMax = max == null;
if (floating == null) {
if (typeof min == 'boolean' && noMax) {
floating = min;
min = 1;
}
else if (!noMax && typeof max == 'boolean') {
floating = max;
noMax = true;
}
}
if (noMin && noMax) {
max = 1;
}
min = +min || 0;
if (max == null) {
if (noMax) {
max = min;
min = 0;
} else {
max = +max || 0;
}
var rand = nativeRandom();
return (min % 1 || max % 1)
return (floating || min % 1 || max % 1)
? min + nativeMin(rand * (max - min + parseFloat('1e-' + ((rand +'').length - 1))), max)
: min + floor(rand * (max - min + 1));
}

View File

@@ -25,7 +25,7 @@ return Ct(n,function(n){var e=Mt(++t);r[t]=r[e],r[e]=n}),r}function Bt(n,t,e){va
}else if(r=t,null==r||e)return n?n[0]:v;return g(n,0,Ne(Ie(0,r),u))}function Rt(t,e,r){if(typeof r=="number"){var u=t?t.length:0;r=0>r?Ie(0,u+r):r||0}else if(r)return r=$t(t,e),t[r]===e?r:-1;return n(t,e,r)}function Ft(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0;for(t=y.createCallback(t,e,3);++u<o&&t(n[u],u,n);)r++}else r=null==t||e?1:Ie(0,t);return g(n,r)}function $t(n,t,e,r){var u=0,o=n?n.length:u;for(e=e?y.createCallback(e,r,1):Gt,t=e(t);u<o;)r=u+o>>>1,e(n[r])<t?u=r+1:o=r;
return u}function zt(n,t,e,r){return typeof t!="boolean"&&null!=t&&(e=(r=e)&&r[t]===n?null:t,t=!1),null!=e&&(e=y.createCallback(e,r,3)),rt(n,t,e)}function Lt(){for(var n=1<arguments.length?arguments:arguments[0],t=-1,e=n?St(ar(n,"length")):0,r=Ut(0>e?0:e);++t<e;)r[t]=ar(n,t);return r}function Tt(n,t){for(var e=-1,r=n?n.length:0,u={};++e<r;){var o=n[e];t?u[o]=t[e]:o&&(u[o[0]]=o[1])}return u}function qt(n,t){return 2<arguments.length?ot(n,17,Pe.call(arguments,2),null,t):ot(n,1,null,null,t)}function Kt(n,t,e){function r(){c&&pe(c),a=c=p=v,(h||g!==t)&&(s=+new Qt,i=n.apply(f,o))
}function u(){var e=t-(new Qt-l);0<e?c=be(u,e):(a&&pe(a),e=p,a=c=p=v,e&&(s=+new Qt,i=n.apply(f,o)))}var o,a,i,l,f,c,p,s=0,g=!1,h=!0;if(!yt(n))throw new re;if(t=Ie(0,t)||0,true===e)var y=!0,h=!1;else mt(e)&&(y=e.leading,g="maxWait"in e&&(Ie(t,e.maxWait)||0),h="trailing"in e?e.trailing:h);return function(){if(o=arguments,l=+new Qt,f=this,p=h&&(c||!y),false===g)var e=y&&!c;else{a||y||(s=l);var v=g-(l-s);0<v?a||(a=be(r,v)):(a&&(a=pe(a)),s=l,i=n.apply(f,o))}return c||t===g||(c=be(u,t)),e&&(i=n.apply(f,o)),i
}}function Wt(n){if(!yt(n))throw new re;var t=Pe.call(arguments,1);return be(function(){n.apply(v,t)},1)}function Gt(n){return n}function Jt(n,t){var e=n,r=!t||yt(e);t||(e=m,t=n,n=y),Ct(ht(t),function(u){var o=n[u]=t[u];r&&(e.prototype[u]=function(){var t=this.__wrapped__,r=[t];return ye.apply(r,arguments),r=o.apply(n,r),t&&typeof t=="object"&&t===r?this:new e(r)})})}function Mt(n,t){null==n&&null==t&&(t=1),n=+n||0,null==t?(t=n,n=0):t=+t||0;var e=De();return n%1||t%1?n+Ne(e*(t-n+parseFloat("1e-"+((e+"").length-1))),t):n+se(e*(t-n+1))
}}function Wt(n){if(!yt(n))throw new re;var t=Pe.call(arguments,1);return be(function(){n.apply(v,t)},1)}function Gt(n){return n}function Jt(n,t){var e=n,r=!t||yt(e);t||(e=m,t=n,n=y),Ct(ht(t),function(u){var o=n[u]=t[u];r&&(e.prototype[u]=function(){var t=this.__wrapped__,r=[t];return ye.apply(r,arguments),r=o.apply(n,r),t&&typeof t=="object"&&t===r?this:new e(r)})})}function Mt(n,t,e){var r=null==n,u=null==t;return null==e&&(typeof n=="boolean"&&u?(e=n,n=1):u||typeof t!="boolean"||(e=t,u=!0)),r&&u&&(t=1),n=+n||0,u?(t=n,n=0):t=+t||0,r=De(),e||n%1||t%1?n+Ne(r*(t-n+parseFloat("1e-"+((r+"").length-1))),t):n+se(r*(t-n+1))
}function Ht(){return this.__wrapped__}e=e?tt.defaults(X.Object(),e,tt.pick(X,F)):X;var Ut=e.Array,Vt=e.Boolean,Qt=e.Date,Xt=e.Function,Yt=e.Math,Zt=e.Number,ne=e.Object,te=e.RegExp,ee=e.String,re=e.TypeError,ue=[],oe=e.Error.prototype,ae=ne.prototype,ie=ee.prototype,le=e._,fe=te("^"+ee(ae.valueOf).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),ce=Yt.ceil,pe=e.clearTimeout,se=Yt.floor,ge=Xt.prototype.toString,he=fe.test(he=ne.getPrototypeOf)&&he,ve=ae.hasOwnProperty,ye=ue.push,me=ae.propertyIsEnumerable,de=e.setImmediate,be=e.setTimeout,_e=ue.splice,we=ae.toString,je=ue.unshift,ke=function(){try{var n={},t=fe.test(t=ne.defineProperty)&&t,e=t(n,n,n)&&t
}catch(r){}return e}(),xe=fe.test(xe=we.bind)&&xe,Ce=fe.test(Ce=ne.create)&&Ce,Ee=fe.test(Ee=Ut.isArray)&&Ee,Oe=e.isFinite,Se=e.isNaN,Ae=fe.test(Ae=ne.keys)&&Ae,Ie=Yt.max,Ne=Yt.min,Be=e.parseInt,De=Yt.random,Pe=ue.slice,Re=fe.test(e.attachEvent),Fe=xe&&!/\n|true/.test(xe+Re),$e={};$e[L]=Ut,$e[T]=Vt,$e[q]=Qt,$e[W]=Xt,$e[J]=ne,$e[G]=Zt,$e[M]=te,$e[H]=ee;var ze={};ze[L]=ze[q]=ze[G]={constructor:!0,toLocaleString:!0,toString:!0,valueOf:!0},ze[T]=ze[H]={constructor:!0,toString:!0,valueOf:!0},ze[K]=ze[W]=ze[M]={constructor:!0,toString:!0},ze[J]={constructor:!0},function(){for(var n=$.length;n--;){var t,e=$[n];
for(t in ze)ve.call(ze,t)&&!ve.call(ze[t],e)&&(ze[t][e]=!1)}}(),m.prototype=y.prototype;var Le=y.support={};!function(){function n(){this.x=1}var t={0:1,length:1},r=[];n.prototype={valueOf:1};for(var u in new n)r.push(u);for(u in arguments);Le.argsClass=we.call(arguments)==z,Le.argsObject=arguments.constructor==ne&&!(arguments instanceof Ut),Le.enumErrorProps=me.call(oe,"message")||me.call(oe,"name"),Le.enumPrototypes=me.call(n,"prototype"),Le.fastBind=xe&&!Fe,Le.funcDecomp=!fe.test(e.o)&&P.test(h),Le.funcNames=typeof Xt.name=="string",Le.ownLast="x"!=r[0],Le.nonEnumArgs=0!=u,Le.nonEnumShadows=!/valueOf/.test(r),Le.spliceObjects=(ue.splice.call(t,0,1),!t[0]),Le.unindexedChars="xx"!="x"[0]+ne("x")[0];

39
dist/lodash.js vendored
View File

@@ -700,7 +700,7 @@
*
* @private
* @param {*} value The value to clone.
* @param {boolean} [deep=false] A flag to indicate a deep clone.
* @param {boolean} [deep=false] Specify a deep clone.
* @param {Function} [callback] The function to customize cloning values.
* @param {Array} [stackA=[]] Tracks traversed source objects.
* @param {Array} [stackB=[]] Associates clones with source counterparts.
@@ -1573,7 +1573,7 @@
* @memberOf _
* @category Objects
* @param {*} value The value to clone.
* @param {boolean} [deep=false] A flag to indicate a deep clone.
* @param {boolean} [deep=false] Specify a deep clone.
* @param {Function} [callback] The function to customize cloning values.
* @param {*} [thisArg] The `this` binding of `callback`.
* @returns {*} Returns the cloned `value`.
@@ -5591,35 +5591,56 @@
/**
* Produces a random number between `min` and `max` (inclusive). If only one
* argument is provided a number between `0` and the given number will be
* returned.
* returned. If `floating` is truey or either `min` or `max` are floats a
* floating-point number will be returned instead of an integer.
*
* @static
* @memberOf _
* @category Utilities
* @param {number} [min=0] The minimum possible value.
* @param {number} [max=1] The maximum possible value.
* @param {boolean} [floating=false] Specify returning a floating-point number.
* @returns {number} Returns a random number.
* @example
*
* _.random(0, 5);
* // => a number between 0 and 5
* // => an integer between 0 and 5
*
* _.random(5);
* // => also a number between 0 and 5
* // => also an integer between 0 and 5
*
* _.random(5, true);
* // => a floating-point number between 0 and 5
*
* _.random(1.2, 5.2);
* // => a floating-point number between 1.2 and 5.2
*/
function random(min, max) {
if (min == null && max == null) {
function random(min, max, floating) {
var noMin = min == null,
noMax = max == null;
if (floating == null) {
if (typeof min == 'boolean' && noMax) {
floating = min;
min = 1;
}
else if (!noMax && typeof max == 'boolean') {
floating = max;
noMax = true;
}
}
if (noMin && noMax) {
max = 1;
}
min = +min || 0;
if (max == null) {
if (noMax) {
max = min;
min = 0;
} else {
max = +max || 0;
}
var rand = nativeRandom();
return (min % 1 || max % 1)
return (floating || min % 1 || max % 1)
? min + nativeMin(rand * (max - min + parseFloat('1e-' + ((rand +'').length - 1))), max)
: min + floor(rand * (max - min + 1));
}

2
dist/lodash.min.js vendored
View File

@@ -25,7 +25,7 @@ if(l){var c=o(i);c?(u=t,i=c):l=!1}for(;++r<a;)c=e[r],0>u(i,c)&&f.push(c);return
for(t=X.createCallback(t,e,3);++u<o&&t(n[u],u,n);)r++}else r=null==t||e?1:Ee(0,t);return s(n,r)}function Tt(n,t,e,r){var u=0,o=n?n.length:u;for(e=e?X.createCallback(e,r,1):Mt,t=e(t);u<o;)r=u+o>>>1,e(n[r])<t?u=r+1:o=r;return u}function zt(n,t,e,r){return typeof t!="boolean"&&null!=t&&(e=(r=e)&&r[t]===n?null:t,t=!1),null!=e&&(e=X.createCallback(e,r,3)),ut(n,t,e)}function Wt(){for(var n=1<arguments.length?arguments:arguments[0],t=-1,e=n?Nt(Et(n,"length")):0,r=Ht(0>e?0:e);++t<e;)r[t]=Et(n,t);return r}function qt(n,t){for(var e=-1,r=n?n.length:0,u={};++e<r;){var o=n[e];
t?u[o]=t[e]:o&&(u[o[0]]=o[1])}return u}function Pt(n,t){return 2<arguments.length?at(n,17,Ae.call(arguments,2),null,t):at(n,1,null,null,t)}function Kt(n,t,e){function r(){c&&le(c),a=c=p=h,(g||v!==t)&&(s=he(),i=n.apply(l,o))}function u(){var e=t-(he()-f);0<e?c=me(u,e):(a&&le(a),e=p,a=c=p=h,e&&(s=he(),i=n.apply(l,o)))}var o,a,i,f,l,c,p,s=0,v=!1,g=!0;if(!gt(n))throw new re;if(t=Ee(0,t)||0,true===e)var y=!0,g=!1;else yt(e)&&(y=e.leading,v="maxWait"in e&&(Ee(t,e.maxWait)||0),g="trailing"in e?e.trailing:g);
return function(){if(o=arguments,f=he(),l=this,p=g&&(c||!y),false===v)var e=y&&!c;else{a||y||(s=f);var h=v-(f-s);0<h?a||(a=me(r,h)):(a&&(a=le(a)),s=f,i=n.apply(l,o))}return c||t===v||(c=me(u,t)),e&&(i=n.apply(l,o)),i}}function Lt(n){if(!gt(n))throw new re;var t=Ae.call(arguments,1);return me(function(){n.apply(h,t)},1)}function Mt(n){return n}function Ut(n,t){var e=n,r=!t||gt(e);t||(e=Y,t=n,n=X),xt(vt(t),function(u){var o=n[u]=t[u];r&&(e.prototype[u]=function(){var t=this.__wrapped__,r=[t];return ge.apply(r,arguments),r=o.apply(n,r),t&&typeof t=="object"&&t===r?this:new e(r)
})})}function Vt(n,t){null==n&&null==t&&(t=1),n=+n||0,null==t?(t=n,n=0):t=+t||0;var e=Re();return n%1||t%1?n+Ie(e*(t-n+parseFloat("1e-"+((e+"").length-1))),t):n+ce(e*(t-n+1))}function Gt(){return this.__wrapped__}e=e?Q.defaults(V.Object(),e,Q.pick(V,D)):V;var Ht=e.Array,Jt=e.Boolean,Qt=e.Date,Xt=e.Function,Yt=e.Math,Zt=e.Number,ne=e.Object,te=e.RegExp,ee=e.String,re=e.TypeError,ue=[],oe=ne.prototype,ae=e._,ie=te("^"+ee(oe.valueOf).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),fe=Yt.ceil,le=e.clearTimeout,ce=Yt.floor,pe=Xt.prototype.toString,se=ie.test(se=ne.getPrototypeOf)&&se,ve=oe.hasOwnProperty,he=ie.test(he=Qt.now)&&he||function(){return+new Qt
})})}function Vt(n,t,e){var r=null==n,u=null==t;return null==e&&(typeof n=="boolean"&&u?(e=n,n=1):u||typeof t!="boolean"||(e=t,u=!0)),r&&u&&(t=1),n=+n||0,u?(t=n,n=0):t=+t||0,r=Re(),e||n%1||t%1?n+Ie(r*(t-n+parseFloat("1e-"+((r+"").length-1))),t):n+ce(r*(t-n+1))}function Gt(){return this.__wrapped__}e=e?Q.defaults(V.Object(),e,Q.pick(V,D)):V;var Ht=e.Array,Jt=e.Boolean,Qt=e.Date,Xt=e.Function,Yt=e.Math,Zt=e.Number,ne=e.Object,te=e.RegExp,ee=e.String,re=e.TypeError,ue=[],oe=ne.prototype,ae=e._,ie=te("^"+ee(oe.valueOf).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),fe=Yt.ceil,le=e.clearTimeout,ce=Yt.floor,pe=Xt.prototype.toString,se=ie.test(se=ne.getPrototypeOf)&&se,ve=oe.hasOwnProperty,he=ie.test(he=Qt.now)&&he||function(){return+new Qt
},ge=ue.push,ye=e.setImmediate,me=e.setTimeout,be=ue.splice,_e=oe.toString,de=ue.unshift,we=function(){try{var n={},t=ie.test(t=ne.defineProperty)&&t,e=t(n,n,n)&&t}catch(r){}return e}(),je=ie.test(je=_e.bind)&&je,ke=ie.test(ke=ne.create)&&ke,xe=ie.test(xe=Ht.isArray)&&xe,Ce=e.isFinite,Oe=e.isNaN,Ne=ie.test(Ne=ne.keys)&&Ne,Ee=Yt.max,Ie=Yt.min,Se=e.parseInt,Re=Yt.random,Ae=ue.slice,De=ie.test(e.attachEvent),Be=je&&!/\n|true/.test(je+De),$e={};$e[$]=Ht,$e[F]=Jt,$e[T]=Qt,$e[z]=Xt,$e[q]=ne,$e[W]=Zt,$e[P]=te,$e[K]=ee,Y.prototype=X.prototype;
var Fe=X.support={};Fe.fastBind=je&&!Be,Fe.funcDecomp=!ie.test(e.a)&&R.test(v),Fe.funcNames=typeof Xt.name=="string",X.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:E,variable:"",imports:{_:X}};var Te=we?function(n,t){var e=f();e.value=t,we(n,"__bindData__",e),p(e)}:l,ze=xe||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&_e.call(n)==$||!1},We=Ne?function(n){return yt(n)?Ne(n):[]}:J,qe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Pe=ht(qe),Ke=te("("+We(Pe).join("|")+")","g"),Le=te("["+We(qe).join("")+"]","g"),Me=ot(function(n,t,e){ve.call(n,e)?n[e]++:n[e]=1
}),Ue=ot(function(n,t,e){(ve.call(n,e)?n[e]:n[e]=[]).push(t)}),Ve=ot(function(n,t,e){n[e]=t});Be&&H&&typeof ye=="function"&&(Lt=function(n){if(!gt(n))throw new re;return ye.apply(e,arguments)});var Ge=8==Se(w+"08")?Se:function(n,t){return Se(bt(n)?n.replace(I,""):n,t||0)};return X.after=function(n,t){if(!gt(t))throw new re;return function(){return 1>--n?t.apply(this,arguments):void 0}},X.assign=G,X.at=function(n){for(var t=arguments,e=-1,r=tt(t,!0,!1,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=Ht(t);++e<t;)u[e]=n[r[e]];

View File

@@ -952,7 +952,7 @@
* @memberOf _
* @category Objects
* @param {*} value The value to clone.
* @param {boolean} [deep=false] A flag to indicate a deep clone.
* @param {boolean} [deep=false] Specify a deep clone.
* @param {Function} [callback] The function to customize cloning values.
* @param {*} [thisArg] The `this` binding of `callback`.
* @returns {*} Returns the cloned `value`.
@@ -4183,21 +4183,29 @@
/**
* Produces a random number between `min` and `max` (inclusive). If only one
* argument is provided a number between `0` and the given number will be
* returned.
* returned. If `floating` is truey or either `min` or `max` are floats a
* floating-point number will be returned instead of an integer.
*
* @static
* @memberOf _
* @category Utilities
* @param {number} [min=0] The minimum possible value.
* @param {number} [max=1] The maximum possible value.
* @param {boolean} [floating=false] Specify returning a floating-point number.
* @returns {number} Returns a random number.
* @example
*
* _.random(0, 5);
* // => a number between 0 and 5
* // => an integer between 0 and 5
*
* _.random(5);
* // => also a number between 0 and 5
* // => also an integer between 0 and 5
*
* _.random(5, true);
* // => a floating-point number between 0 and 5
*
* _.random(1.2, 5.2);
* // => a floating-point number between 1.2 and 5.2
*/
function random(min, max) {
if (min == null && max == null) {
@@ -4210,10 +4218,7 @@
} else {
max = +max || 0;
}
var rand = nativeRandom();
return (min % 1 || max % 1)
? min + nativeMin(rand * (max - min + parseFloat('1e-' + ((rand +'').length - 1))), max)
: min + floor(rand * (max - min + 1));
return min + floor(nativeRandom() * (max - min + 1));
}
/**

View File

@@ -12,25 +12,25 @@ if(typeof o=="number")for(;++e<o;){var i=r[e];n(u,i,t(i,e,r),r)}else Xr(r,functi
if(e)for(var u in e)"undefined"==typeof n[u]&&(n[u]=e[u])}return n}function d(n){var r=[];return Qr(n,function(n,t){j(n)&&r.push(t)}),r.sort()}function b(n){for(var r=-1,t=Gr(n),e=t.length,u={};++r<e;){var o=t[r];u[n[o]]=o}return u}function w(n){if(!n)return!0;if(Ur(n)||T(n))return!n.length;for(var r in n)if(Ar.call(n,r))return!1;return!0}function j(n){return typeof n=="function"}function x(n){return!(!n||!vr[typeof n])}function E(n){return typeof n=="number"||Rr.call(n)==cr}function T(n){return typeof n=="string"||Rr.call(n)==hr
}function A(n){for(var r=-1,t=Gr(n),e=t.length,u=Array(e);++r<e;)u[r]=n[t[r]];return u}function O(n,r){var t=v(),e=n?n.length:0,u=!1;return e&&typeof e=="number"?u=-1<t(n,r):Xr(n,function(n){return(u=n===r)&&rr}),u}function R(n,r,t){var e=!0;r=K(r,t,3),t=-1;var u=n?n.length:0;if(typeof u=="number")for(;++t<u&&(e=!!r(n[t],t,n)););else Xr(n,function(n,t,u){return!(e=!!r(n,t,u))&&rr});return e}function S(n,r,t){var e=[];r=K(r,t,3),t=-1;var u=n?n.length:0;if(typeof u=="number")for(;++t<u;){var o=n[t];
r(o,t,n)&&e.push(o)}else Xr(n,function(n,t,u){r(n,t,u)&&e.push(n)});return e}function B(n,r,t){r=K(r,t,3),t=-1;var e=n?n.length:0;if(typeof e!="number"){var u;return Xr(n,function(n,t,e){return r(n,t,e)?(u=n,rr):void 0}),u}for(;++t<e;){var o=n[t];if(r(o,t,n))return o}}function D(n,r,t){var e=-1,u=n?n.length:0;if(r=r&&typeof t=="undefined"?r:i(r,t,3),typeof u=="number")for(;++e<u&&r(n[e],e,n)!==rr;);else Xr(n,r)}function N(n,r){var t=n?n.length:0;if(typeof t=="number")for(;t--&&false!==r(n[t],t,n););else{var e=Gr(n),t=e.length;
Xr(n,function(n,u,o){return u=e?e[--t]:--t,false===r(o[u],u,o)&&rr})}}function F(n,r,t){var e=-1,u=n?n.length:0;if(r=K(r,t,3),typeof u=="number")for(var o=Array(u);++e<u;)o[e]=r(n[e],e,n);else o=[],Xr(n,function(n,t,u){o[++e]=r(n,t,u)});return o}function k(n,r,t){var e=-1/0,u=e,o=-1,i=n?n.length:0;if(r||typeof i!="number")r=K(r,t,3),D(n,function(n,t,o){t=r(n,t,o),t>e&&(e=t,u=n)});else for(;++o<i;)t=n[o],t>u&&(u=t);return u}function q(n,r){var t=-1,e=n?n.length:0;if(typeof e=="number")for(var u=Array(e);++t<e;)u[t]=n[t][r];
return u||F(n,r)}function M(n,r,t,e){if(!n)return t;var u=3>arguments.length;r=i(r,e,4);var o=-1,f=n.length;if(typeof f=="number")for(u&&(t=n[++o]);++o<f;)t=r(t,n[o],o,n);else Xr(n,function(n,e,o){t=u?(u=!1,n):r(t,n,e,o)});return t}function W(n,r,t,e){var u=3>arguments.length;return r=i(r,e,4),N(n,function(n,e,o){t=u?(u=!1,n):r(t,n,e,o)}),t}function $(n){var r=-1,t=n?n.length:0,e=Array(typeof t=="number"?t:0);return D(n,function(n){var t=Y(++r);e[r]=e[t],e[t]=n}),e}function I(n,r,t){var e;r=K(r,t,3),t=-1;
Xr(n,function(n,u,o){return u=e?e[--t]:--t,false===r(o[u],u,o)&&rr})}}function k(n,r,t){var e=-1,u=n?n.length:0;if(r=K(r,t,3),typeof u=="number")for(var o=Array(u);++e<u;)o[e]=r(n[e],e,n);else o=[],Xr(n,function(n,t,u){o[++e]=r(n,t,u)});return o}function F(n,r,t){var e=-1/0,u=e,o=-1,i=n?n.length:0;if(r||typeof i!="number")r=K(r,t,3),D(n,function(n,t,o){t=r(n,t,o),t>e&&(e=t,u=n)});else for(;++o<i;)t=n[o],t>u&&(u=t);return u}function q(n,r){var t=-1,e=n?n.length:0;if(typeof e=="number")for(var u=Array(e);++t<e;)u[t]=n[t][r];
return u||k(n,r)}function M(n,r,t,e){if(!n)return t;var u=3>arguments.length;r=i(r,e,4);var o=-1,f=n.length;if(typeof f=="number")for(u&&(t=n[++o]);++o<f;)t=r(t,n[o],o,n);else Xr(n,function(n,e,o){t=u?(u=!1,n):r(t,n,e,o)});return t}function W(n,r,t,e){var u=3>arguments.length;return r=i(r,e,4),N(n,function(n,e,o){t=u?(u=!1,n):r(t,n,e,o)}),t}function $(n){var r=-1,t=n?n.length:0,e=Array(typeof t=="number"?t:0);return D(n,function(n){var t=Y(++r);e[r]=e[t],e[t]=n}),e}function I(n,r,t){var e;r=K(r,t,3),t=-1;
var u=n?n.length:0;if(typeof u=="number")for(;++t<u&&!(e=r(n[t],t,n)););else Xr(n,function(n,t,u){return(e=r(n,t,u))&&rr});return!!e}function z(n,r,t){return t&&w(r)?Z:(t?B:S)(n,r)}function C(n){for(var r=-1,t=v(),e=n.length,u=f(arguments,!0,!0,1),o=[];++r<e;){var i=n[r];0>t(u,i)&&o.push(i)}return o}function P(n,r,t){var e=0,u=n?n.length:0;if(typeof r!="number"&&null!=r){var o=-1;for(r=K(r,t,3);++o<u&&r(n[o],o,n);)e++}else if(e=r,null==e||t)return n?n[0]:Z;return Ir.call(n,0,Wr(Mr(0,e),u))}function U(r,t,e){if(typeof e=="number"){var u=r?r.length:0;
e=0>e?Mr(0,u+e):e||0}else if(e)return e=G(r,t),r[e]===t?e:-1;return n(r,t,e)}function V(n,r,t){if(typeof r!="number"&&null!=r){var e=0,u=-1,o=n?n.length:0;for(r=K(r,t,3);++u<o&&r(n[u],u,n);)e++}else e=null==r||t?1:Mr(0,r);return Ir.call(n,e)}function G(n,r,t,e){var u=0,o=n?n.length:u;for(t=t?K(t,e,1):Q,r=t(r);u<o;)e=u+o>>>1,t(n[e])<r?u=e+1:o=e;return u}function H(n,r,t,e){return typeof r!="boolean"&&null!=r&&(t=(e=t)&&e[r]===n?null:r,r=!1),null!=t&&(t=K(t,e,3)),l(n,r,t)}function J(n,r){return 2<arguments.length?p(n,17,Ir.call(arguments,2),null,r):p(n,1,null,null,r)
}function K(n,r,t){var e=typeof n;if(null==n||"function"==e)return i(n,r,t);if("object"!=e)return function(r){return r[n]};var u=Gr(n);return function(r){for(var t=u.length,e=!1;t--&&(e=r[u[t]]===n[u[t]]););return e}}function L(n,r,t){var e,u,o,i,f,a,l,c=0,p=!1,s=!0;if(!j(n))throw new TypeError;if(r=Mr(0,r)||0,true===t)var h=!0,s=!1;else x(t)&&(h=t.leading,p="maxWait"in t&&(Mr(r,t.maxWait)||0),s="trailing"in t?t.trailing:s);var v=function(){var t=r-(new Date-i);0<t?a=setTimeout(v,t):(u&&clearTimeout(u),t=l,u=a=l=Z,t&&(c=+new Date,o=n.apply(f,e)))
},g=function(){a&&clearTimeout(a),u=a=l=Z,(s||p!==r)&&(c=+new Date,o=n.apply(f,e))};return function(){if(e=arguments,i=+new Date,f=this,l=s&&(a||!h),false===p)var t=h&&!a;else{u||h||(c=i);var y=p-(i-c);0<y?u||(u=setTimeout(g,y)):(u&&(u=clearTimeout(u)),c=i,o=n.apply(f,e))}return a||r===p||(a=setTimeout(v,r)),t&&(o=n.apply(f,e)),o}}function Q(n){return n}function X(n){D(d(n),function(r){var t=u[r]=n[r];u.prototype[r]=function(){var n=[this.__wrapped__];return Or.apply(n,arguments),n=t.apply(u,n),this.__chain__&&(n=new o(n),n.__chain__=!0),n
}})}function Y(n,r){null==n&&null==r&&(r=1),n=+n||0,null==r?(r=n,n=0):r=+r||0;var t=$r();return n%1||r%1?n+Wr(t*(r-n+parseFloat("1e-"+((t+"").length-1))),r):n+Tr(t*(r-n+1))}var Z,nr=0,rr={},tr=+new Date+"",er=/($^)/,ur=/\bthis\b/,or=/['\n\r\t\u2028\u2029\\]/g,ir="[object Arguments]",fr="[object Array]",ar="[object Boolean]",lr="[object Date]",cr="[object Number]",pr="[object Object]",sr="[object RegExp]",hr="[object String]",vr={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},gr={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},yr=vr[typeof window]&&window||this,mr=vr[typeof exports]&&exports,_r=vr[typeof module]&&module&&module.exports==mr&&module,dr=vr[typeof global]&&global;
!dr||dr.global!==dr&&dr.window!==dr||(yr=dr);var br=[],wr=Object.prototype,jr=yr._,xr=RegExp("^"+(wr.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),Er=Math.ceil,Tr=Math.floor,Ar=wr.hasOwnProperty,Or=br.push,Rr=wr.toString,Sr=br.unshift,Br=xr.test(Br=Rr.bind)&&Br,Dr=xr.test(Dr=Object.create)&&Dr,Nr=xr.test(Nr=Array.isArray)&&Nr,Fr=yr.isFinite,kr=yr.isNaN,qr=xr.test(qr=Object.keys)&&qr,Mr=Math.max,Wr=Math.min,$r=Math.random,Ir=br.slice,zr=xr.test(yr.attachEvent),Cr=Br&&!/\n|true/.test(Br+zr);
}})}function Y(n,r){return null==n&&null==r&&(r=1),n=+n||0,null==r?(r=n,n=0):r=+r||0,n+Tr($r()*(r-n+1))}var Z,nr=0,rr={},tr=+new Date+"",er=/($^)/,ur=/\bthis\b/,or=/['\n\r\t\u2028\u2029\\]/g,ir="[object Arguments]",fr="[object Array]",ar="[object Boolean]",lr="[object Date]",cr="[object Number]",pr="[object Object]",sr="[object RegExp]",hr="[object String]",vr={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},gr={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},yr=vr[typeof window]&&window||this,mr=vr[typeof exports]&&exports,_r=vr[typeof module]&&module&&module.exports==mr&&module,dr=vr[typeof global]&&global;
!dr||dr.global!==dr&&dr.window!==dr||(yr=dr);var br=[],wr=Object.prototype,jr=yr._,xr=RegExp("^"+(wr.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),Er=Math.ceil,Tr=Math.floor,Ar=wr.hasOwnProperty,Or=br.push,Rr=wr.toString,Sr=br.unshift,Br=xr.test(Br=Rr.bind)&&Br,Dr=xr.test(Dr=Object.create)&&Dr,Nr=xr.test(Nr=Array.isArray)&&Nr,kr=yr.isFinite,Fr=yr.isNaN,qr=xr.test(qr=Object.keys)&&qr,Mr=Math.max,Wr=Math.min,$r=Math.random,Ir=br.slice,zr=xr.test(yr.attachEvent),Cr=Br&&!/\n|true/.test(Br+zr);
o.prototype=u.prototype;var Pr={};!function(){var n={0:1,length:1};Pr.fastBind=Br&&!Cr,Pr.funcDecomp=!xr.test(yr.WinRTError)&&ur.test(function(){return this}),Pr.spliceObjects=(br.splice.call(n,0,1),!n[0])}(1),u.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},Dr||(s=function(n){if(x(n)){e.prototype=n;var r=new e;e.prototype=null}return r||{}}),y(arguments)||(y=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Ar.call(n,"callee")||!1
});var Ur=Nr||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Rr.call(n)==fr||!1},Vr=function(n){var r,t=[];if(!n||!vr[typeof n])return t;for(r in n)Ar.call(n,r)&&t.push(r);return t},Gr=qr?function(n){return x(n)?qr(n):[]}:Vr,Hr={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},Jr=b(Hr),Kr=RegExp("("+Gr(Jr).join("|")+")","g"),Lr=RegExp("["+Gr(Hr).join("")+"]","g"),Qr=function(n,r){var t;if(!n||!vr[typeof n])return n;for(t in n)if(r(n[t],t,n)===rr)break;return n},Xr=function(n,r){var t;
if(!n||!vr[typeof n])return n;for(t in n)if(Ar.call(n,t)&&r(n[t],t,n)===rr)break;return n};j(/x/)&&(j=function(n){return typeof n=="function"&&"[object Function]"==Rr.call(n)});var Yr=c(function(n,r,t){Ar.call(n,t)?n[t]++:n[t]=1}),Zr=c(function(n,r,t){(Ar.call(n,t)?n[t]:n[t]=[]).push(r)}),nt=c(function(n,r,t){n[t]=r});u.after=function(n,r){if(!j(r))throw new TypeError;return function(){return 1>--n?r.apply(this,arguments):void 0}},u.bind=J,u.bindAll=function(n){for(var r=1<arguments.length?f(arguments,!0,!1,1):d(n),t=-1,e=r.length;++t<e;){var u=r[t];
n[u]=p(n[u],1,null,null,n)}return n},u.chain=function(n){return n=new o(n),n.__chain__=!0,n},u.compact=function(n){for(var r=-1,t=n?n.length:0,e=[];++r<t;){var u=n[r];u&&e.push(u)}return e},u.compose=function(){for(var n=arguments,r=n.length;r--;)if(!j(n[r]))throw new TypeError;return function(){for(var r=arguments,t=n.length;t--;)r=[n[t].apply(this,r)];return r[0]}},u.countBy=Yr,u.debounce=L,u.defaults=_,u.defer=function(n){if(!j(n))throw new TypeError;var r=Ir.call(arguments,1);return setTimeout(function(){n.apply(Z,r)
},1)},u.delay=function(n,r){if(!j(n))throw new TypeError;var t=Ir.call(arguments,2);return setTimeout(function(){n.apply(Z,t)},r)},u.difference=C,u.filter=S,u.flatten=function(n,r){return f(n,r)},u.forEach=D,u.functions=d,u.groupBy=Zr,u.indexBy=nt,u.initial=function(n,r,t){var e=0,u=n?n.length:0;if(typeof r!="number"&&null!=r){var o=u;for(r=K(r,t,3);o--&&r(n[o],o,n);)e++}else e=null==r||t?1:r||e;return Ir.call(n,0,Wr(Mr(0,u-e),u))},u.intersection=function(n){var r=arguments,t=r.length,e=-1,u=v(),o=n?n.length:0,i=[];
n:for(;++e<o;){var f=n[e];if(0>u(i,f)){for(var a=t;--a;)if(0>u(r[a],f))continue n;i.push(f)}}return i},u.invert=b,u.invoke=function(n,r){var t=Ir.call(arguments,2),e=-1,u=typeof r=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return D(n,function(n){i[++e]=(u?r:n[r]).apply(n,t)}),i},u.keys=Gr,u.map=F,u.max=k,u.memoize=function(n,r){var t={};return function(){var e=r?r.apply(this,arguments):tr+arguments[0];return Ar.call(t,e)?t[e]:t[e]=n.apply(this,arguments)}},u.min=function(n,r,t){var e=1/0,u=e,o=-1,i=n?n.length:0;
n:for(;++e<o;){var f=n[e];if(0>u(i,f)){for(var a=t;--a;)if(0>u(r[a],f))continue n;i.push(f)}}return i},u.invert=b,u.invoke=function(n,r){var t=Ir.call(arguments,2),e=-1,u=typeof r=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return D(n,function(n){i[++e]=(u?r:n[r]).apply(n,t)}),i},u.keys=Gr,u.map=k,u.max=F,u.memoize=function(n,r){var t={};return function(){var e=r?r.apply(this,arguments):tr+arguments[0];return Ar.call(t,e)?t[e]:t[e]=n.apply(this,arguments)}},u.min=function(n,r,t){var e=1/0,u=e,o=-1,i=n?n.length:0;
if(r||typeof i!="number")r=K(r,t,3),D(n,function(n,t,o){t=r(n,t,o),t<e&&(e=t,u=n)});else for(;++o<i;)t=n[o],t<u&&(u=t);return u},u.omit=function(n){var r=v(),t=f(arguments,!0,!1,1),e={};return Qr(n,function(n,u){0>r(t,u)&&(e[u]=n)}),e},u.once=function(n){var r,t;if(!j(n))throw new TypeError;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},u.pairs=function(n){for(var r=-1,t=Gr(n),e=t.length,u=Array(e);++r<e;){var o=t[r];u[r]=[o,n[o]]}return u},u.partial=function(n){return p(n,16,Ir.call(arguments,1))
},u.pick=function(n){for(var r=-1,t=f(arguments,!0,!1,1),e=t.length,u={};++r<e;){var o=t[r];o in n&&(u[o]=n[o])}return u},u.pluck=q,u.range=function(n,r,t){n=+n||0,t=+t||1,null==r&&(r=n,n=0);var e=-1;r=Mr(0,Er((r-n)/t));for(var u=Array(r);++e<r;)u[e]=n,n+=t;return u},u.reject=function(n,r,t){return r=K(r,t,3),S(n,function(n,t,e){return!r(n,t,e)})},u.rest=V,u.shuffle=$,u.sortBy=function(n,t,e){var u=-1,o=n?n.length:0,i=Array(typeof o=="number"?o:0);for(t=K(t,e,3),D(n,function(n,r,e){i[++u]={l:t(n,r,e),m:u,n:n}
}),o=i.length,i.sort(r);o--;)i[o]=i[o].n;return i},u.tap=function(n,r){return r(n),n},u.throttle=function(n,r,t){var e=!0,u=!0;if(!j(n))throw new TypeError;return false===t?e=!1:x(t)&&(e="leading"in t?t.leading:e,u="trailing"in t?t.trailing:u),t={},t.leading=e,t.maxWait=r,t.trailing=u,L(n,r,t)},u.times=function(n,r,t){n=-1<(n=+n)?n:0;var e=-1,u=Array(n);for(r=i(r,t,1);++e<n;)u[e]=r(e);return u},u.toArray=function(n){return Ur(n)?Ir.call(n):n&&typeof n.length=="number"?F(n):A(n)},u.union=function(){return l(f(arguments,!0,!0))
},u.uniq=H,u.values=A,u.where=z,u.without=function(n){return C(n,Ir.call(arguments,1))},u.wrap=function(n,r){if(!j(r))throw new TypeError;return function(){var t=[n];return Or.apply(t,arguments),r.apply(this,t)}},u.zip=function(){for(var n=-1,r=k(q(arguments,"length")),t=Array(0>r?0:r);++n<r;)t[n]=q(arguments,n);return t},u.collect=F,u.drop=V,u.each=D,u.extend=m,u.methods=d,u.object=function(n,r){for(var t=-1,e=n?n.length:0,u={};++t<e;){var o=n[t];r?u[o]=r[t]:o&&(u[o[0]]=o[1])}return u},u.select=S,u.tail=V,u.unique=H,u.clone=function(n){return x(n)?Ur(n)?Ir.call(n):m({},n):n
},u.contains=O,u.escape=function(n){return null==n?"":(n+"").replace(Lr,h)},u.every=R,u.find=B,u.has=function(n,r){return n?Ar.call(n,r):!1},u.identity=Q,u.indexOf=U,u.isArguments=y,u.isArray=Ur,u.isBoolean=function(n){return true===n||false===n||Rr.call(n)==ar},u.isDate=function(n){return n?typeof n=="object"&&Rr.call(n)==lr:!1},u.isElement=function(n){return n?1===n.nodeType:!1},u.isEmpty=w,u.isEqual=function(n,r){return a(n,r)},u.isFinite=function(n){return Fr(n)&&!kr(parseFloat(n))},u.isFunction=j,u.isNaN=function(n){return E(n)&&n!=+n
}),o=i.length,i.sort(r);o--;)i[o]=i[o].n;return i},u.tap=function(n,r){return r(n),n},u.throttle=function(n,r,t){var e=!0,u=!0;if(!j(n))throw new TypeError;return false===t?e=!1:x(t)&&(e="leading"in t?t.leading:e,u="trailing"in t?t.trailing:u),t={},t.leading=e,t.maxWait=r,t.trailing=u,L(n,r,t)},u.times=function(n,r,t){n=-1<(n=+n)?n:0;var e=-1,u=Array(n);for(r=i(r,t,1);++e<n;)u[e]=r(e);return u},u.toArray=function(n){return Ur(n)?Ir.call(n):n&&typeof n.length=="number"?k(n):A(n)},u.union=function(){return l(f(arguments,!0,!0))
},u.uniq=H,u.values=A,u.where=z,u.without=function(n){return C(n,Ir.call(arguments,1))},u.wrap=function(n,r){if(!j(r))throw new TypeError;return function(){var t=[n];return Or.apply(t,arguments),r.apply(this,t)}},u.zip=function(){for(var n=-1,r=F(q(arguments,"length")),t=Array(0>r?0:r);++n<r;)t[n]=q(arguments,n);return t},u.collect=k,u.drop=V,u.each=D,u.extend=m,u.methods=d,u.object=function(n,r){for(var t=-1,e=n?n.length:0,u={};++t<e;){var o=n[t];r?u[o]=r[t]:o&&(u[o[0]]=o[1])}return u},u.select=S,u.tail=V,u.unique=H,u.clone=function(n){return x(n)?Ur(n)?Ir.call(n):m({},n):n
},u.contains=O,u.escape=function(n){return null==n?"":(n+"").replace(Lr,h)},u.every=R,u.find=B,u.has=function(n,r){return n?Ar.call(n,r):!1},u.identity=Q,u.indexOf=U,u.isArguments=y,u.isArray=Ur,u.isBoolean=function(n){return true===n||false===n||Rr.call(n)==ar},u.isDate=function(n){return n?typeof n=="object"&&Rr.call(n)==lr:!1},u.isElement=function(n){return n?1===n.nodeType:!1},u.isEmpty=w,u.isEqual=function(n,r){return a(n,r)},u.isFinite=function(n){return kr(n)&&!Fr(parseFloat(n))},u.isFunction=j,u.isNaN=function(n){return E(n)&&n!=+n
},u.isNull=function(n){return null===n},u.isNumber=E,u.isObject=x,u.isRegExp=function(n){return n&&vr[typeof n]?Rr.call(n)==sr:!1},u.isString=T,u.isUndefined=function(n){return typeof n=="undefined"},u.lastIndexOf=function(n,r,t){var e=n?n.length:0;for(typeof t=="number"&&(e=(0>t?Mr(0,e+t):Wr(t,e-1))+1);e--;)if(n[e]===r)return e;return-1},u.mixin=X,u.noConflict=function(){return yr._=jr,this},u.random=Y,u.reduce=M,u.reduceRight=W,u.result=function(n,r){if(n){var t=n[r];return j(t)?n[r]():t}},u.size=function(n){var r=n?n.length:0;
return typeof r=="number"?r:Gr(n).length},u.some=I,u.sortedIndex=G,u.template=function(n,r,e){var o=u,i=o.templateSettings;n||(n=""),e=_({},e,i);var f=0,a="__p+='",i=e.variable;n.replace(RegExp((e.escape||er).source+"|"+(e.interpolate||er).source+"|"+(e.evaluate||er).source+"|$","g"),function(r,e,u,o,i){return a+=n.slice(f,i).replace(or,t),e&&(a+="'+_.escape("+e+")+'"),o&&(a+="';"+o+";__p+='"),u&&(a+="'+((__t=("+u+"))==null?'':__t)+'"),f=i+r.length,r}),a+="';\n",i||(i="obj",a="with("+i+"||{}){"+a+"}"),a="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+a+"return __p}";
try{var l=Function("_","return "+a)(o)}catch(c){throw c.source=a,c}return r?l(r):(l.source=a,l)},u.unescape=function(n){return null==n?"":(n+"").replace(Kr,g)},u.uniqueId=function(n){var r=++nr+"";return n?n+r:r},u.all=R,u.any=I,u.detect=B,u.findWhere=function(n,r){return z(n,r,!0)},u.foldl=M,u.foldr=W,u.include=O,u.inject=M,u.first=P,u.last=function(n,r,t){var e=0,u=n?n.length:0;if(typeof r!="number"&&null!=r){var o=u;for(r=K(r,t,3);o--&&r(n[o],o,n);)e++}else if(e=r,null==e||t)return n?n[u-1]:Z;

View File

@@ -174,7 +174,7 @@
* [`_.mixin`](#_mixinobject-object)
* [`_.noConflict`](#_noconflict)
* [`_.parseInt`](#_parseintvalue--radix)
* [`_.random`](#_randommin0--max1)
* [`_.random`](#_randommin0--max1--floatingfalse)
* [`_.result`](#_resultobject-property)
* [`_.runInContext`](#_runincontextcontextroot)
* [`_.template`](#_templatetext-data--options--optionsescape--optionsevaluate--optionsimports--optionsinterpolate--sourceurl--variable)
@@ -1064,7 +1064,7 @@ _.isArray(squares.value());
<!-- div -->
### <a id="_chainvalue"></a>`_.chain(value)`
<a href="#_chainvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6312 "View in source") [&#x24C9;][1]
<a href="#_chainvalue">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6333 "View in source") [&#x24C9;][1]
Creates a `lodash` object that wraps the given value.
@@ -1097,7 +1097,7 @@ var youngest = _.chain(stooges)
<!-- div -->
### <a id="_tapvalue-interceptor"></a>`_.tap(value, interceptor)`
<a href="#_tapvalue-interceptor">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6340 "View in source") [&#x24C9;][1]
<a href="#_tapvalue-interceptor">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6361 "View in source") [&#x24C9;][1]
Invokes `interceptor` with the `value` as the first argument and then returns `value`. The purpose of this method is to "tap into" a method chain in order to perform operations on intermediate results within the chain.
@@ -1127,7 +1127,7 @@ _([1, 2, 3, 4])
<!-- div -->
### <a id="_prototypechain"></a>`_.prototype.chain()`
<a href="#_prototypechain">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6360 "View in source") [&#x24C9;][1]
<a href="#_prototypechain">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6381 "View in source") [&#x24C9;][1]
Enables method chaining on the wrapper object.
@@ -1151,7 +1151,7 @@ var sum = _([1, 2, 3])
<!-- div -->
### <a id="_prototypetostring"></a>`_.prototype.toString()`
<a href="#_prototypetostring">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6377 "View in source") [&#x24C9;][1]
<a href="#_prototypetostring">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6398 "View in source") [&#x24C9;][1]
Produces the `toString` result of the wrapped value.
@@ -1172,7 +1172,7 @@ _([1, 2, 3]).toString();
<!-- div -->
### <a id="_prototypevalueof"></a>`_.prototype.valueOf()`
<a href="#_prototypevalueof">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6394 "View in source") [&#x24C9;][1]
<a href="#_prototypevalueof">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6415 "View in source") [&#x24C9;][1]
Extracts the wrapped value.
@@ -2732,7 +2732,7 @@ Creates a clone of `value`. If `deep` is `true` nested objects will also be clon
#### Arguments
1. `value` *(\*)*: The value to clone.
2. `[deep=false]` *(boolean)*: A flag to indicate a deep clone.
2. `[deep=false]` *(boolean)*: Specify a deep clone.
3. `[callback]` *(Function)*: The function to customize cloning values.
4. `[thisArg]` *(\*)*: The `this` binding of `callback`.
@@ -3953,14 +3953,15 @@ _.parseInt('08');
<!-- div -->
### <a id="_randommin0--max1"></a>`_.random([min=0], [max=1])`
<a href="#_randommin0--max1">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5976 "View in source") [&#x24C9;][1]
### <a id="_randommin0--max1--floatingfalse"></a>`_.random([min=0], [max=1], [floating=false])`
<a href="#_randommin0--max1--floatingfalse">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5984 "View in source") [&#x24C9;][1]
Produces a random number between `min` and `max` *(inclusive)*. If only one argument is provided a number between `0` and the given number will be returned.
Produces a random number between `min` and `max` *(inclusive)*. If only one argument is provided a number between `0` and the given number will be returned. If `floating` is truey or either `min` or `max` are floats a floating-point number will be returned instead of an integer.
#### Arguments
1. `[min=0]` *(number)*: The minimum possible value.
2. `[max=1]` *(number)*: The maximum possible value.
3. `[floating=false]` *(boolean)*: Specify returning a floating-point number.
#### Returns
*(number)*: Returns a random number.
@@ -3968,10 +3969,16 @@ Produces a random number between `min` and `max` *(inclusive)*. If only one argu
#### Example
```js
_.random(0, 5);
// => a number between 0 and 5
// => an integer between 0 and 5
_.random(5);
// => also a number between 0 and 5
// => also an integer between 0 and 5
_.random(5, true);
// => a floating-point number between 0 and 5
_.random(1.2, 5.2);
// => a floating-point number between 1.2 and 5.2
```
* * *
@@ -3982,7 +3989,7 @@ _.random(5);
<!-- div -->
### <a id="_resultobject-property"></a>`_.result(object, property)`
<a href="#_resultobject-property">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6020 "View in source") [&#x24C9;][1]
<a href="#_resultobject-property">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6041 "View in source") [&#x24C9;][1]
Resolves the value of `property` on `object`. If `property` is a function it will be invoked with the `this` binding of `object` and its result returned, else the property value is returned. If `object` is falsey then `undefined` is returned.
@@ -4035,7 +4042,7 @@ Create a new `lodash` function using the given context object.
<!-- div -->
### <a id="_templatetext-data--options--optionsescape--optionsevaluate--optionsimports--optionsinterpolate--sourceurl--variable"></a>`_.template(text, data, [options], [options.escape], [options.evaluate], [options.imports], [options.interpolate], [sourceURL], [variable])`
<a href="#_templatetext-data--options--optionsescape--optionsevaluate--optionsimports--optionsinterpolate--sourceurl--variable">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6113 "View in source") [&#x24C9;][1]
<a href="#_templatetext-data--options--optionsescape--optionsevaluate--optionsimports--optionsinterpolate--sourceurl--variable">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6134 "View in source") [&#x24C9;][1]
A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code.
@@ -4129,7 +4136,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\
<!-- div -->
### <a id="_timesn-callback--thisarg"></a>`_.times(n, callback, [thisArg])`
<a href="#_timesn-callback--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6236 "View in source") [&#x24C9;][1]
<a href="#_timesn-callback--thisarg">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6257 "View in source") [&#x24C9;][1]
Executes the callback `n` times, returning an array of the results of each callback execution. The callback is bound to `thisArg` and invoked with one argument; *(index)*.
@@ -4161,7 +4168,7 @@ _.times(3, function(n) { this.cast(n); }, mage);
<!-- div -->
### <a id="_unescapestring"></a>`_.unescape(string)`
<a href="#_unescapestring">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6263 "View in source") [&#x24C9;][1]
<a href="#_unescapestring">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6284 "View in source") [&#x24C9;][1]
The inverse of `_.escape` this method converts the HTML entities `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to their corresponding characters.
@@ -4185,7 +4192,7 @@ _.unescape('Moe, Larry &amp; Curly');
<!-- div -->
### <a id="_uniqueidprefix"></a>`_.uniqueId([prefix])`
<a href="#_uniqueidprefix">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6283 "View in source") [&#x24C9;][1]
<a href="#_uniqueidprefix">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6304 "View in source") [&#x24C9;][1]
Generates a unique ID. If `prefix` is provided the ID will be appended to it.
@@ -4238,7 +4245,7 @@ A reference to the `lodash` function.
<!-- div -->
### <a id="_version"></a>`_.VERSION`
<a href="#_version">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6592 "View in source") [&#x24C9;][1]
<a href="#_version">#</a> [&#x24C8;](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6613 "View in source") [&#x24C9;][1]
*(string)*: The semantic version number.

View File

@@ -987,7 +987,7 @@
*
* @private
* @param {*} value The value to clone.
* @param {boolean} [deep=false] A flag to indicate a deep clone.
* @param {boolean} [deep=false] Specify a deep clone.
* @param {Function} [callback] The function to customize cloning values.
* @param {Array} [stackA=[]] Tracks traversed source objects.
* @param {Array} [stackB=[]] Associates clones with source counterparts.
@@ -1974,7 +1974,7 @@
* @memberOf _
* @category Objects
* @param {*} value The value to clone.
* @param {boolean} [deep=false] A flag to indicate a deep clone.
* @param {boolean} [deep=false] Specify a deep clone.
* @param {Function} [callback] The function to customize cloning values.
* @param {*} [thisArg] The `this` binding of `callback`.
* @returns {*} Returns the cloned `value`.
@@ -5957,35 +5957,56 @@
/**
* Produces a random number between `min` and `max` (inclusive). If only one
* argument is provided a number between `0` and the given number will be
* returned.
* returned. If `floating` is truey or either `min` or `max` are floats a
* floating-point number will be returned instead of an integer.
*
* @static
* @memberOf _
* @category Utilities
* @param {number} [min=0] The minimum possible value.
* @param {number} [max=1] The maximum possible value.
* @param {boolean} [floating=false] Specify returning a floating-point number.
* @returns {number} Returns a random number.
* @example
*
* _.random(0, 5);
* // => a number between 0 and 5
* // => an integer between 0 and 5
*
* _.random(5);
* // => also a number between 0 and 5
* // => also an integer between 0 and 5
*
* _.random(5, true);
* // => a floating-point number between 0 and 5
*
* _.random(1.2, 5.2);
* // => a floating-point number between 1.2 and 5.2
*/
function random(min, max) {
if (min == null && max == null) {
function random(min, max, floating) {
var noMin = min == null,
noMax = max == null;
if (floating == null) {
if (typeof min == 'boolean' && noMax) {
floating = min;
min = 1;
}
else if (!noMax && typeof max == 'boolean') {
floating = max;
noMax = true;
}
}
if (noMin && noMax) {
max = 1;
}
min = +min || 0;
if (max == null) {
if (noMax) {
max = min;
min = 0;
} else {
max = +max || 0;
}
var rand = nativeRandom();
return (min % 1 || max % 1)
return (floating || min % 1 || max % 1)
? min + nativeMin(rand * (max - min + parseFloat('1e-' + ((rand +'').length - 1))), max)
: min + floor(rand * (max - min + 1));
}

View File

@@ -3065,6 +3065,17 @@
ok(actual % 1);
ok(actual >= min && actual <= max);
});
test('supports passing a `floating` argument', function() {
var actual = _.random(true);
ok(actual % 1 && actual >= 0 && actual <= 1);
actual = _.random(2, true);
ok(actual % 1 && actual >= 0 && actual <= 2);
actual = _.random(2, 4, true);
ok(actual % 1 && actual >= 2 && actual <= 4);
});
}());
/*--------------------------------------------------------------------------*/