From 999aae0a33881f9064bfa291e6be659e8369a9b5 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 27 Feb 2013 08:03:08 -0800 Subject: [PATCH] Add `_.parseInt`. Former-commit-id: 0c0f10af3dc50a4d1b684523f19d02e423d738f5 --- build.js | 5 + build/pre-compile.js | 1 + dist/lodash.compat.js | 37 ++++-- dist/lodash.compat.min.js | 75 ++++++------ dist/lodash.js | 37 ++++-- dist/lodash.min.js | 69 +++++------ dist/lodash.underscore.js | 14 +-- doc/README.md | 243 +++++++++++++++++++++----------------- lodash.js | 38 ++++-- test/test-build.js | 2 + test/test.js | 16 +++ 11 files changed, 328 insertions(+), 209 deletions(-) diff --git a/build.js b/build.js index ef4a6cce2..25e7cd48e 100755 --- a/build.js +++ b/build.js @@ -140,6 +140,7 @@ 'omit': ['forIn', 'indexOf'], 'once': [], 'pairs': ['keys'], + 'parseInt': ['isString'], 'partial': ['isFunction', 'isObject'], 'partialRight': ['isFunction', 'isObject'], 'pick': ['forIn', 'isObject'], @@ -260,6 +261,7 @@ 'forOwn', 'isPlainObject', 'merge', + 'parseInt', 'partialRight', 'runInContext' ])); @@ -2493,6 +2495,9 @@ if (isRemoved(source, 'keys')) { source = removeFunction(source, 'shimKeys'); } + if (isRemoved(source, 'parseInt')) { + source = removeVar(source, 'nativeParseInt'); + } if (isRemoved(source, 'template')) { // remove `templateSettings` assignment source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *lodash\.templateSettings[\s\S]+?};\n/, ''); diff --git a/build/pre-compile.js b/build/pre-compile.js index cb3613a44..44bf04bb5 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -159,6 +159,7 @@ 'once', 'Number', 'pairs', + 'parseInt', 'partial', 'partialRight', 'pick', diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index e090040c7..132a5d1ca 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -170,6 +170,7 @@ nativeKeys = reNative.test(nativeKeys = Object.keys) && nativeKeys, nativeMax = Math.max, nativeMin = Math.min, + nativeParseInt = context.parseInt, nativeRandom = Math.random; /** Detect various environments */ @@ -289,13 +290,13 @@ * `union`, `uniq`, `unshift`, `values`, `where`, `without`, `wrap`, and `zip` * * The non-chainable wrapper functions are: - * `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`, - * `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, - * `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, - * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, - * `lastIndexOf`, `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, - * `result`, `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`, - * `uniqueId`, and `value` + * `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, + * `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, + * `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, + * `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, + * `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `parseInt`, + * `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`, + * `sortedIndex`, `runInContext`, `template`, `unescape`, `uniqueId`, and `value` * * The wrapper functions `first` and `last` return wrapped values when `n` is * passed, otherwise they return unwrapped values. @@ -2108,6 +2109,27 @@ return result; } + /** + * Parses the given `value` into an integer of the specified `radix`. + * + * Note: This method avoids differences in ES3 and ES5 `parseInt` + * implementations. See http://es5.github.com/#E. + * + * @static + * @memberOf _ + * @category Objects + * @param {Mixed} value The value to parse. + * @returns {Number} Returns the new integer value. + * @example + * + * _.parseInt('08'); + * // => 8 + */ + var parseInt = nativeParseInt('08') == 8 ? nativeParseInt : function(value, radix) { + // Firefox and Opera have not changed to the ES5 specified implementation of `parseInt` + return nativeParseInt(isString(value) ? value.replace(/^0+(?=.$)/, '') : value, radix || 0); + }; + /** * Creates a shallow clone of `object` composed of the specified properties. * Property names may be specified as individual arguments or as arrays of property @@ -5056,6 +5078,7 @@ lodash.lastIndexOf = lastIndexOf; lodash.mixin = mixin; lodash.noConflict = noConflict; + lodash.parseInt = parseInt; lodash.random = random; lodash.reduce = reduce; lodash.reduceRight = reduceRight; diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 387b8e8f0..56f29ae49 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -4,41 +4,40 @@ * Build: `lodash -o ./dist/lodash.compat.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ -;(function(n){function t(e){function o(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof o?(this.__wrapped__=n,void 0):new o(n)}function B(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||a);if(u){var o={};for(r=t-1;++rt||typeof n=="undefined")return 1; -if(nu;u++)e+="j='"+t.k[u]+"';if(","constructor"==t.k[u]&&(e+="!(g&&g.prototype===n)&&"),e+="i.call(n,j)){"+t.h+"}"}return(t.b||t.i)&&(e+="}"),e+=t.c+";return u",r("f,i,k,l,m,r,p","return function("+n+"){"+e+"}")(D,Ht,G,Sr,rt,N,rr)}function C(n){return M.prototype=n,n=new M,M.prototype=null,n}function T(n){return"\\"+$[n]}function K(n){return Er[n]}function L(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function M(){}function U(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0); -var e=-1;r=r-t||0;for(var u=It(0>r?0:r);++er?er(0,u+r):r)||0,typeof u=="number"?o=-1<(rt(n)?n.indexOf(t,r):mt(n,t,r)):wr(n,function(n){return++eu&&(u=i)}}else t=!t&&rt(n)?F:D(t,r),wr(n,function(n,r,o){r=t(n,r,o),r>e&&(e=r,u=n)});return u}function st(n,t,r,e){var u=3>arguments.length;if(t=D(t,e,4),Sr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var f=kr(n),o=f.length;else hr&&rt(n)&&(u=n.split(""));return t=D(t,e,4),ct(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=!1,u[e]):t(r,u[e],e,a) -}),r}function gt(n,t,r){var e;if(t=D(t,r),Sr(n)){r=-1;for(var u=n.length;++rr?er(0,u+r):r||0)-1;else if(r)return e=_t(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])mt(f,l))&&((r||a)&&f.push(l),i.push(e))}return i}function jt(n,t){return cr||Yt&&2/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:h,variable:"",imports:{_:o}}; -var _r={a:"q,w,h",l:"var a=arguments,b=0,c=typeof h=='number'?2:a.length;while(++b":">",'"':""","'":"'"},Ar=X(Er),Ir=z(_r,{l:_r.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=f(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[j]=d?d(u[j],n[j]):n[j]"}),Nr=z(_r);Z(/x/)&&(Z=function(n){return n instanceof qt||Xt.call(n)==O});var $r=Gt?function(n){if(!n||typeof n!="object")return!1;var t=n.valueOf,r=typeof t=="function"&&(r=Gt(t))&&Gt(r);return r?n==r||Gt(n)==r&&!G(n):H(n)}:H,qr=lt,Br=ft;return ar&&u&&typeof Qt=="function"&&(wt=jt(Qt,e)),o.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 -}},o.assign=Ir,o.at=function(n){var t=-1,r=Ut.apply(zt,U(arguments,1)),e=r.length,u=It(e);for(hr&&rt(n)&&(n=n.split(""));++tmt(a,c)){i&&a.push(c);for(var p=r;--p;)if(!(e[p]||(e[p]=B(t[p],0,100)))(c))continue n;f.push(c)}}return f},o.invert=X,o.invoke=function(n,t){var r=U(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=It(typeof o=="number"?o:0);return ct(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},o.keys=kr,o.map=lt,o.max=pt,o.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+""; -return Ht.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},o.merge=et,o.min=function(n,t,r){var e=1/0,u=e;if(!t&&Sr(n)){r=-1;for(var o=n.length;++rmt(o,r,1))&&(u[r]=n) -}),u},o.once=function(n){var t,r;return function(){return t?r:(t=!0,r=n.apply(this,arguments),n=null,r)}},o.pairs=function(n){for(var t=-1,r=kr(n),e=r.length,u=It(e);++tr?er(0,e+r):ur(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},o.mixin=Ot,o.noConflict=function(){return e._=Tt,this -},o.random=function(n,t){return null==n&&null==t&&(t=1),n=+n||0,null==t&&(t=n,n=0),n+Vt(or()*((+t||0)-n+1))},o.reduce=st,o.reduceRight=vt,o.result=function(n,t){var e=n?n[t]:r;return Z(e)?n[t]():e},o.runInContext=t,o.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:kr(n).length},o.some=gt,o.sortedIndex=_t,o.template=function(n,t,e){var u=o.templateSettings;n||(n=""),e=Nr({},e,u);var i,f=Nr({},e.imports,u.imports),u=kr(f),f=ut(f),a=0,c=e.interpolate||y,v="__p+='",c=Pt((e.escape||y).source+"|"+c.source+"|"+(c===h?g:y).source+"|"+(e.evaluate||y).source+"|$","g"); -n.replace(c,function(t,r,e,u,o,f){return e||(e=u),v+=n.slice(a,f).replace(d,T),r&&(v+="'+__e("+r+")+'"),o&&(i=!0,v+="';"+o+";__p+='"),e&&(v+="'+((__t=("+e+"))==null?'':__t)+'"),a=f+t.length,t}),v+="';\n",c=e=e.variable,c||(e="obj",v="with("+e+"){"+v+"}"),v=(i?v.replace(l,""):v).replace(p,"$1").replace(s,"$1;"),v="function("+e+"){"+(c?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+v+"return __p}";try{var m=qt(u,"return "+v).apply(r,f) -}catch(_){throw _.source=v,_}return t?m(t):(m.source=v,m)},o.unescape=function(n){return null==n?"":(n+"").replace(c,V)},o.uniqueId=function(n){var t=++i;return(null==n?"":n+"")+t},o.all=it,o.any=gt,o.detect=at,o.foldl=st,o.foldr=vt,o.include=ot,o.inject=st,Or(o,function(n,t){o.prototype[t]||(o.prototype[t]=function(){var t=[this.__wrapped__];return Jt.apply(t,arguments),n.apply(o,t)})}),o.first=ht,o.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;for(t=D(t,r);o--&&t(n[o],o,n);)e++ -}else if(e=t,null==e||r)return n[u-1];return U(n,er(0,u-e))}},o.take=ht,o.head=ht,Or(o,function(n,t){o.prototype[t]||(o.prototype[t]=function(t,r){var e=n(this.__wrapped__,t,r);return null==t||r&&typeof t!="function"?e:new o(e)})}),o.VERSION="1.0.1",o.prototype.toString=function(){return this.__wrapped__+""},o.prototype.value=St,o.prototype.valueOf=St,wr(["join","pop","shift"],function(n){var t=zt[n];o.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),wr(["push","reverse","sort","unshift"],function(n){var t=zt[n]; -o.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),wr(["concat","slice","splice"],function(n){var t=zt[n];o.prototype[n]=function(){return new o(t.apply(this.__wrapped__,arguments))}}),pr&&wr(["pop","shift","splice"],function(n){var t=zt[n],r="splice"==n;o.prototype[n]=function(){var n=this.__wrapped__,e=t.apply(n,arguments);return 0===n.length&&delete n[0],r?new o(e):e}}),o}var r,e=typeof exports=="object"&&exports,u=typeof module=="object"&&module&&module.exports==e&&module,o=typeof global=="object"&&global; -o.global===o&&(n=o);var i=0,f={},a=30,c=/&(?:amp|lt|gt|quot|#39);/g,l=/\b__p\+='';/g,p=/\b(__p\+=)''\+/g,s=/(__e\(.*?\)|\b__t\))\+'';/g,v=/\w*$/,g=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,h=/<%=([\s\S]+?)%>/g,y=/($^)/,m=/[&<>"']/g,d=/['\n\r\t\u2028\u2029\\]/g,_="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),b="[object Arguments]",j="[object Array]",w="[object Boolean]",x="[object Date]",O="[object Function]",S="[object Number]",k="[object Object]",E="[object RegExp]",A="[object String]",I={}; -I[O]=!1,I[b]=I[j]=I[w]=I[x]=I[S]=I[k]=I[E]=I[A]=!0;var N={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},$={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},q=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=q,define(function(){return q})):e?u?(u.exports=q)._=q:e._=q:n._=q})(this); \ No newline at end of file +;(function(n){function t(i){function a(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof a?(this.__wrapped__=n,void 0):new a(n)}function P(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||p);if(u){var o={};for(r=t-1;++rt||typeof n=="undefined")return 1; +if(nu;u++)r+="j='"+t.k[u]+"';if(","constructor"==t.k[u]&&(r+="!(g&&g.prototype===n)&&"),r+="i.call(n,j)){"+t.h+"}"; +return(t.b||t.i)&&(r+="}"),r+=t.c+";return u",Rt("f,i,k,l,m,r,p","return function("+n+"){"+r+"}")(T,Wt,Q,Ar,ot,B,or)}function L(n){return G.prototype=n,n=new G,G.prototype=u,n}function M(n){return"\\"+F[n]}function U(n){return Nr[n]}function V(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function G(){}function H(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);var e=-1;r=r-t||0;for(var u=qt(0>r?0:r);++er?ir(0,u+r):r)||0,typeof u=="number"?i=-1<(ot(n)?n.indexOf(t,r):bt(n,t,r)):kr(n,function(n){return++eu&&(u=i)}}else t=!t&&ot(n)?D:T(t,r),kr(n,function(n,r,o){r=t(n,r,o),r>e&&(e=r,u=n)});return u}function ht(n,t,r,e){var u=3>arguments.length;if(t=T(t,e,4),Ar(n)){var i=-1,f=n.length;for(u&&(r=n[++i]);++iarguments.length;if(typeof i!="number")var a=$r(n),i=a.length;else _r&&ot(n)&&(u=n.split(""));return t=T(t,e,4),st(n,function(n,e,c){e=a?a[--i]:--i,r=f?(f=o,u[e]):t(r,u[e],e,c)}),r}function mt(n,t,r){var e;if(t=T(t,r),Ar(n)){r=-1;for(var u=n.length;++rr?ir(0,u+r):r||0)-1;else if(r)return e=wt(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])bt(a,p))&&((r||c)&&a.push(p),f.push(e))}return f}function Ot(n,t){return vr||tr&&2/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:d,variable:"",imports:{_:a}}; +var xr={a:"q,w,h",l:"var a=arguments,b=0,c=typeof h=='number'?2:a.length;while(++b":">",'"':""","'":"'"},qr=nt(Nr),Br=K(xr,{l:xr.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=f(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[j]=d?d(u[j],n[j]):n[j]"}),Fr=K(xr);rt(/x/)&&(rt=function(n){return n instanceof Rt||nr.call(n)==E});var Rr=Qt?function(n){if(!n||typeof n!="object")return o;var t=n.valueOf,r=typeof t=="function"&&(r=Qt(t))&&Qt(r);return r?n==r||Qt(n)==r&&!Q(n):W(n)}:W,Pr=8==ar("08")?ar:function(n,t){return ar(ot(n)?n.replace(/^0+(?=.$)/,""):n,t||0) +},Dr=vt,zr=lt;return sr&&f&&typeof Yt=="function"&&(St=Ot(Yt,i)),a.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},a.assign=Br,a.at=function(n){var t=-1,r=Ht.apply(Kt,H(arguments,1)),e=r.length,u=qt(e);for(_r&&ot(n)&&(n=n.split(""));++tbt(a,c)){i&&a.push(c);for(var p=r;--p;)if(!(e[p]||(e[p]=P(t[p],0,100)))(c))continue n;f.push(c)}}return f},a.invert=nt,a.invoke=function(n,t){var r=H(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=qt(typeof o=="number"?o:0); +return st(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},a.keys=$r,a.map=vt,a.max=gt,a.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return Wt.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},a.merge=it,a.min=function(n,t,r){var e=1/0,u=e;if(!t&&Ar(n)){r=-1;for(var o=n.length;++rbt(o,r,1))&&(u[r]=n)}),u},a.once=function(n){var t,r;return function(){return t?r:(t=e,r=n.apply(this,arguments),n=u,r)}},a.pairs=function(n){for(var t=-1,r=$r(n),e=r.length,u=qt(e);++tr?ir(0,e+r):fr(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},a.mixin=Et,a.noConflict=function(){return i._=Mt,this},a.parseInt=Pr,a.random=function(n,t){return n==u&&t==u&&(t=1),n=+n||0,t==u&&(t=n,n=0),n+Jt(cr()*((+t||0)-n+1))},a.reduce=ht,a.reduceRight=yt,a.result=function(n,t){var e=n?n[t]:r;return rt(e)?n[t]():e},a.runInContext=t,a.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:$r(n).length},a.some=mt,a.sortedIndex=wt,a.template=function(n,t,u){var o=a.templateSettings; +n||(n=""),u=Fr({},u,o);var i,f=Fr({},u.imports,o.imports),o=$r(f),f=ft(f),c=0,l=u.interpolate||_,p="__p+='",l=Ct((u.escape||_).source+"|"+l.source+"|"+(l===d?m:_).source+"|"+(u.evaluate||_).source+"|$","g");n.replace(l,function(t,r,u,o,f,a){return u||(u=o),p+=n.slice(c,a).replace(j,M),r&&(p+="'+__e("+r+")+'"),f&&(i=e,p+="';"+f+";__p+='"),u&&(p+="'+((__t=("+u+"))==null?'':__t)+'"),c=a+t.length,t}),p+="';\n",l=u=u.variable,l||(u="obj",p="with("+u+"){"+p+"}"),p=(i?p.replace(v,""):p).replace(g,"$1").replace(h,"$1;"),p="function("+u+"){"+(l?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+p+"return __p}"; +try{var s=Rt(o,"return "+p).apply(r,f)}catch(y){throw y.source=p,y}return t?s(t):(s.source=p,s)},a.unescape=function(n){return n==u?"":(n+"").replace(s,J)},a.uniqueId=function(n){var t=++c;return(n==u?"":n+"")+t},a.all=ct,a.any=mt,a.detect=pt,a.foldl=ht,a.foldr=yt,a.include=at,a.inject=ht,Ir(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(){var t=[this.__wrapped__];return Xt.apply(t,arguments),n.apply(a,t)})}),a.first=dt,a.last=function(n,t,r){if(n){var e=0,o=n.length;if(typeof t!="number"&&t!=u){var i=o; +for(t=T(t,r);i--&&t(n[i],i,n);)e++}else if(e=t,e==u||r)return n[o-1];return H(n,ir(0,o-e))}},a.take=dt,a.head=dt,Ir(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(t,r){var e=n(this.__wrapped__,t,r);return t==u||r&&typeof t!="function"?e:new a(e)})}),a.VERSION="1.0.1",a.prototype.toString=function(){return this.__wrapped__+""},a.prototype.value=It,a.prototype.valueOf=It,kr(["join","pop","shift"],function(n){var t=Kt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)} +}),kr(["push","reverse","sort","unshift"],function(n){var t=Kt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),kr(["concat","slice","splice"],function(n){var t=Kt[n];a.prototype[n]=function(){return new a(t.apply(this.__wrapped__,arguments))}}),hr&&kr(["pop","shift","splice"],function(n){var t=Kt[n],r="splice"==n;a.prototype[n]=function(){var n=this.__wrapped__,e=t.apply(n,arguments);return 0===n.length&&delete n[0],r?new a(e):e}}),a}var r,e=!0,u=null,o=!1,i=typeof exports=="object"&&exports,f=typeof module=="object"&&module&&module.exports==i&&module,a=typeof global=="object"&&global; +a.global===a&&(n=a);var c=0,l={},p=30,s=/&(?:amp|lt|gt|quot|#39);/g,v=/\b__p\+='';/g,g=/\b(__p\+=)''\+/g,h=/(__e\(.*?\)|\b__t\))\+'';/g,y=/\w*$/,m=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,d=/<%=([\s\S]+?)%>/g,_=/($^)/,b=/[&<>"']/g,j=/['\n\r\t\u2028\u2029\\]/g,w="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),x="[object Arguments]",O="[object Array]",S="[object Boolean]",k="[object Date]",E="[object Function]",I="[object Number]",A="[object Object]",$="[object RegExp]",N="[object String]",q={}; +q[E]=o,q[x]=q[O]=q[S]=q[k]=q[I]=q[A]=q[$]=q[N]=e;var B={"boolean":o,"function":e,object:e,number:o,string:o,undefined:o},F={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},R=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=R,define(function(){return R})):i?f?(f.exports=R)._=R:i._=R:n._=R})(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index 6456d803a..bc5292a56 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -164,6 +164,7 @@ nativeKeys = reNative.test(nativeKeys = Object.keys) && nativeKeys, nativeMax = Math.max, nativeMin = Math.min, + nativeParseInt = context.parseInt, nativeRandom = Math.random; /** Detect various environments */ @@ -211,13 +212,13 @@ * `union`, `uniq`, `unshift`, `values`, `where`, `without`, `wrap`, and `zip` * * The non-chainable wrapper functions are: - * `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`, - * `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, - * `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, - * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, - * `lastIndexOf`, `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, - * `result`, `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`, - * `uniqueId`, and `value` + * `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, + * `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, + * `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, + * `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, + * `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `parseInt`, + * `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`, + * `sortedIndex`, `runInContext`, `template`, `unescape`, `uniqueId`, and `value` * * The wrapper functions `first` and `last` return wrapped values when `n` is * passed, otherwise they return unwrapped values. @@ -1959,6 +1960,27 @@ return result; } + /** + * Parses the given `value` into an integer of the specified `radix`. + * + * Note: This method avoids differences in ES3 and ES5 `parseInt` + * implementations. See http://es5.github.com/#E. + * + * @static + * @memberOf _ + * @category Objects + * @param {Mixed} value The value to parse. + * @returns {Number} Returns the new integer value. + * @example + * + * _.parseInt('08'); + * // => 8 + */ + var parseInt = nativeParseInt('08') == 8 ? nativeParseInt : function(value, radix) { + // Firefox and Opera have not changed to the ES5 specified implementation of `parseInt` + return nativeParseInt(isString(value) ? value.replace(/^0+(?=.$)/, '') : value, radix || 0); + }; + /** * Creates a shallow clone of `object` composed of the specified properties. * Property names may be specified as individual arguments or as arrays of property @@ -4900,6 +4922,7 @@ lodash.lastIndexOf = lastIndexOf; lodash.mixin = mixin; lodash.noConflict = noConflict; + lodash.parseInt = parseInt; lodash.random = random; lodash.reduce = reduce; lodash.reduceRight = reduceRight; diff --git a/dist/lodash.min.js b/dist/lodash.min.js index f79f6f198..6e15538e5 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -4,37 +4,38 @@ * Build: `lodash modern -o ./dist/lodash.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ -;(function(n){function t(e){function o(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof o?(this.__wrapped__=n,void 0):new o(n)}function q(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||a);if(u){var o={};for(r=t-1;++rt||typeof n=="undefined")return 1; -if(nr?0:r);++er?Wt(0,u+r):r)||0,typeof u=="number"?o=-1<(Y(n)?n.indexOf(t,r):vt(n,t,r)):rr(n,function(n){return++eu&&(u=i)}}else t=!t&&Y(n)?I:R(t,r),rr(n,function(n,r,o){r=t(n,r,o),r>e&&(e=r,u=n)});return u}function at(n,t,r,e){var u=3>arguments.length;if(t=R(t,e,4),or(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof u!="number")var i=ir(n),u=i.length;return t=R(t,e,4),ot(n,function(e,f,a){f=i?i[--u]:--u,r=o?(o=!1,n[f]):t(r,n[f],f,a)}),r}function lt(n,t,r){var e;if(t=R(t,r),or(n)){r=-1;for(var u=n.length;++rr?Wt(0,u+r):r||0)-1;else if(r)return e=ht(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])vt(f,l))&&((r||a)&&f.push(l),i.push(e))}return i}function mt(n,t){return Zt||Gt&&2/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:h,variable:"",imports:{_:o}};var xt={a:"q,w,h",l:"var a=arguments,b=0,c=typeof h=='number'?2:a.length;while(++b":">",'"':""","'":"'"},ar=J(fr),cr=D(xt,{l:xt.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=f(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[j]=d?d(u[j],n[j]):n[j]"}),lr=D(xt),pr=function(n){if(!n||typeof n!="object")return!1;var t=n.valueOf,r=typeof t=="function"&&(r=Pt(t))&&Pt(r);if(r)n=n==r||Pt(n)==r&&!U(n);else{var e=!1;!n||typeof n!="object"||U(n)?n=e:(t=n.constructor,!Q(t)||t instanceof t?(er(n,function(n,t){e=t -}),n=!1===e||Tt.call(n,e)):n=e)}return n};return At&&u&&typeof Mt=="function"&&(dt=mt(Mt,e)),o.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},o.assign=cr,o.at=function(n){for(var t=-1,r=zt.apply(qt,K(arguments,1)),e=r.length,u=wt(e);++tvt(a,c)){i&&a.push(c);for(var p=r;--p;)if(!(e[p]||(e[p]=q(t[p],0,100)))(c))continue n;f.push(c)}}return f},o.invert=J,o.invoke=function(n,t){var r=K(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=wt(typeof o=="number"?o:0); -return ot(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},o.keys=ir,o.map=it,o.max=ft,o.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return Tt.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},o.merge=Z,o.min=function(n,t,r){var e=1/0,u=e;if(!t&&or(n)){r=-1;for(var o=n.length;++rvt(o,r,1))&&(u[r]=n)}),u},o.once=function(n){var t,r;return function(){return t?r:(t=!0,r=n.apply(this,arguments),n=null,r)}},o.pairs=function(n){for(var t=-1,r=ir(n),e=r.length,u=wt(e);++tr?Wt(0,e+r):Xt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},o.mixin=bt,o.noConflict=function(){return e._=Bt,this},o.random=function(n,t){return null==n&&null==t&&(t=1),n=+n||0,null==t&&(t=n,n=0),n+Ct(Yt()*((+t||0)-n+1))},o.reduce=at,o.reduceRight=ct,o.result=function(n,t){var e=n?n[t]:r;return Q(e)?n[t]():e},o.runInContext=t,o.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:ir(n).length},o.some=lt,o.sortedIndex=ht,o.template=function(n,t,e){var u=o.templateSettings; -n||(n=""),e=lr({},e,u);var i,f=lr({},e.imports,u.imports),u=ir(f),f=nt(f),a=0,c=e.interpolate||y,v="__p+='",c=Nt((e.escape||y).source+"|"+c.source+"|"+(c===h?g:y).source+"|"+(e.evaluate||y).source+"|$","g");n.replace(c,function(t,r,e,u,o,f){return e||(e=u),v+=n.slice(a,f).replace(d,C),r&&(v+="'+__e("+r+")+'"),o&&(i=!0,v+="';"+o+";__p+='"),e&&(v+="'+((__t=("+e+"))==null?'':__t)+'"),a=f+t.length,t}),v+="';\n",c=e=e.variable,c||(e="obj",v="with("+e+"){"+v+"}"),v=(i?v.replace(l,""):v).replace(p,"$1").replace(s,"$1;"),v="function("+e+"){"+(c?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+v+"return __p}"; -try{var m=St(u,"return "+v).apply(r,f)}catch(_){throw _.source=v,_}return t?m(t):(m.source=v,m)},o.unescape=function(n){return null==n?"":(n+"").replace(c,M)},o.uniqueId=function(n){var t=++i;return(null==n?"":n+"")+t},o.all=rt,o.any=lt,o.detect=ut,o.foldl=at,o.foldr=ct,o.include=tt,o.inject=at,ur(o,function(n,t){o.prototype[t]||(o.prototype[t]=function(){var t=[this.__wrapped__];return Kt.apply(t,arguments),n.apply(o,t)})}),o.first=pt,o.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u; -for(t=R(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,null==e||r)return n[u-1];return K(n,Wt(0,u-e))}},o.take=pt,o.head=pt,ur(o,function(n,t){o.prototype[t]||(o.prototype[t]=function(t,r){var e=n(this.__wrapped__,t,r);return null==t||r&&typeof t!="function"?e:new o(e)})}),o.VERSION="1.0.1",o.prototype.toString=function(){return this.__wrapped__+""},o.prototype.value=jt,o.prototype.valueOf=jt,rr(["join","pop","shift"],function(n){var t=qt[n];o.prototype[n]=function(){return t.apply(this.__wrapped__,arguments) -}}),rr(["push","reverse","sort","unshift"],function(n){var t=qt[n];o.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),rr(["concat","slice","splice"],function(n){var t=qt[n];o.prototype[n]=function(){return new o(t.apply(this.__wrapped__,arguments))}}),o}var r,e=typeof exports=="object"&&exports,u=typeof module=="object"&&module&&module.exports==e&&module,o=typeof global=="object"&&global;o.global===o&&(n=o);var i=0,f={},a=30,c=/&(?:amp|lt|gt|quot|#39);/g,l=/\b__p\+='';/g,p=/\b(__p\+=)''\+/g,s=/(__e\(.*?\)|\b__t\))\+'';/g,v=/\w*$/,g=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,h=/<%=([\s\S]+?)%>/g,y=/($^)/,m=/[&<>"']/g,d=/['\n\r\t\u2028\u2029\\]/g,_="[object Arguments]",b="[object Array]",j="[object Boolean]",w="[object Date]",x="[object Number]",O="[object Object]",S="[object RegExp]",A="[object String]",k={"[object Function]":!1}; -k[_]=k[b]=k[j]=k[w]=k[x]=k[O]=k[S]=k[A]=!0;var E={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},N={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},$=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=$,define(function(){return $})):e?u?(u.exports=$)._=$:e._=$:n._=$})(this); \ No newline at end of file +;(function(n){function t(i){function a(n){if(!n||typeof n!="object")return o;var t=n.valueOf,r=typeof t=="function"&&(r=Ut(t))&&Ut(r);if(r)n=n==r||Ut(n)==r&&!J(n);else{var e=o;!n||typeof n!="object"||J(n)?n=e:(t=n.constructor,!Z(t)||t instanceof t?(ar(n,function(n,t){e=t}),n=e===o||Vt.call(n,e)):n=e)}return n}function F(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof F?(this.__wrapped__=n,void 0):new F(n)}function R(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||p);if(u){var o={};for(r=t-1;++rt||typeof n=="undefined")return 1;if(nr?0:r);++er?nr(0,u+r):r)||0,typeof u=="number"?i=-1<(rt(n)?n.indexOf(t,r):mt(n,t,r)):fr(n,function(n){return++eu&&(u=i)}}else t=!t&&rt(n)?D:P(t,r),fr(n,function(n,r,o){r=t(n,r,o),r>e&&(e=r,u=n)});return u}function st(n,t,r,e){var u=3>arguments.length;if(t=P(t,e,4),lr(n)){var i=-1,f=n.length;for(u&&(r=n[++i]);++iarguments.length;if(typeof u!="number")var f=pr(n),u=f.length;return t=P(t,e,4),ct(n,function(e,a,c){a=f?f[--u]:--u,r=i?(i=o,n[a]):t(r,n[a],a,c)}),r}function gt(n,t,r){var e;if(t=P(t,r),lr(n)){r=-1;for(var u=n.length;++rr?nr(0,u+r):r||0)-1;else if(r)return e=_t(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])mt(a,p))&&((r||c)&&a.push(p),f.push(e))}return f}function jt(n,t){return ur||Qt&&2/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:d,variable:"",imports:{_:F}};var $t={a:"q,w,h",l:"var a=arguments,b=0,c=typeof h=='number'?2:a.length;while(++b":">",'"':""","'":"'"},vr=X(sr),gr=T($t,{l:$t.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=f(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[j]=d?d(u[j],n[j]):n[j]"}),hr=T($t),Wt=8==rr("08")?rr:function(n,t){return rr(rt(n)?n.replace(/^0+(?=.$)/,""):n,t||0)};return It&&f&&typeof Ht=="function"&&(wt=jt(Ht,i)),F.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 +}},F.assign=gr,F.at=function(n){for(var t=-1,r=Kt.apply(Rt,G(arguments,1)),e=r.length,u=At(e);++tmt(a,c)){i&&a.push(c);for(var p=r;--p;)if(!(e[p]||(e[p]=R(t[p],0,100)))(c))continue n;f.push(c)}}return f},F.invert=X,F.invoke=function(n,t){var r=G(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=At(typeof o=="number"?o:0);return ct(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},F.keys=pr,F.map=lt,F.max=pt,F.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+""; +return Vt.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},F.merge=et,F.min=function(n,t,r){var e=1/0,u=e;if(!t&&lr(n)){r=-1;for(var o=n.length;++rmt(o,r,1))&&(u[r]=n) +}),u},F.once=function(n){var t,r;return function(){return t?r:(t=e,r=n.apply(this,arguments),n=u,r)}},F.pairs=function(n){for(var t=-1,r=pr(n),e=r.length,u=At(e);++tr?nr(0,e+r):tr(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},F.mixin=Ot,F.noConflict=function(){return i._=zt,this},F.parseInt=Wt,F.random=function(n,t){return n==u&&t==u&&(t=1),n=+n||0,t==u&&(t=n,n=0),n+Mt(er()*((+t||0)-n+1)) +},F.reduce=st,F.reduceRight=vt,F.result=function(n,t){var e=n?n[t]:r;return Z(e)?n[t]():e},F.runInContext=t,F.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:pr(n).length},F.some=gt,F.sortedIndex=_t,F.template=function(n,t,u){var o=F.templateSettings;n||(n=""),u=hr({},u,o);var i,f=hr({},u.imports,o.imports),o=pr(f),f=ut(f),a=0,c=u.interpolate||_,l="__p+='",c=Bt((u.escape||_).source+"|"+c.source+"|"+(c===d?m:_).source+"|"+(u.evaluate||_).source+"|$","g");n.replace(c,function(t,r,u,o,f,c){return u||(u=o),l+=n.slice(a,c).replace(j,M),r&&(l+="'+__e("+r+")+'"),f&&(i=e,l+="';"+f+";__p+='"),u&&(l+="'+((__t=("+u+"))==null?'':__t)+'"),a=c+t.length,t +}),l+="';\n",c=u=u.variable,c||(u="obj",l="with("+u+"){"+l+"}"),l=(i?l.replace(v,""):l).replace(g,"$1").replace(h,"$1;"),l="function("+u+"){"+(c?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}";try{var p=Et(o,"return "+l).apply(r,f)}catch(s){throw s.source=l,s}return t?p(t):(p.source=l,p)},F.unescape=function(n){return n==u?"":(n+"").replace(s,H)},F.uniqueId=function(n){var t=++c;return(n==u?"":n+"")+t +},F.all=it,F.any=gt,F.detect=at,F.foldl=st,F.foldr=vt,F.include=ot,F.inject=st,cr(F,function(n,t){F.prototype[t]||(F.prototype[t]=function(){var t=[this.__wrapped__];return Gt.apply(t,arguments),n.apply(F,t)})}),F.first=ht,F.last=function(n,t,r){if(n){var e=0,o=n.length;if(typeof t!="number"&&t!=u){var i=o;for(t=P(t,r);i--&&t(n[i],i,n);)e++}else if(e=t,e==u||r)return n[o-1];return G(n,nr(0,o-e))}},F.take=ht,F.head=ht,cr(F,function(n,t){F.prototype[t]||(F.prototype[t]=function(t,r){var e=n(this.__wrapped__,t,r); +return t==u||r&&typeof t!="function"?e:new F(e)})}),F.VERSION="1.0.1",F.prototype.toString=function(){return this.__wrapped__+""},F.prototype.value=St,F.prototype.valueOf=St,fr(["join","pop","shift"],function(n){var t=Rt[n];F.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),fr(["push","reverse","sort","unshift"],function(n){var t=Rt[n];F.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),fr(["concat","slice","splice"],function(n){var t=Rt[n];F.prototype[n]=function(){return new F(t.apply(this.__wrapped__,arguments)) +}}),F}var r,e=!0,u=null,o=!1,i=typeof exports=="object"&&exports,f=typeof module=="object"&&module&&module.exports==i&&module,a=typeof global=="object"&&global;a.global===a&&(n=a);var c=0,l={},p=30,s=/&(?:amp|lt|gt|quot|#39);/g,v=/\b__p\+='';/g,g=/\b(__p\+=)''\+/g,h=/(__e\(.*?\)|\b__t\))\+'';/g,y=/\w*$/,m=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,d=/<%=([\s\S]+?)%>/g,_=/($^)/,b=/[&<>"']/g,j=/['\n\r\t\u2028\u2029\\]/g,w="[object Arguments]",x="[object Array]",O="[object Boolean]",S="[object Date]",A="[object Number]",$="[object Object]",k="[object RegExp]",E="[object String]",I={"[object Function]":o}; +I[w]=I[x]=I[O]=I[S]=I[A]=I[$]=I[k]=I[E]=e;var N={"boolean":o,"function":e,object:e,number:o,string:o,undefined:o},q={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},B=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=B,define(function(){return B})):i?f?(f.exports=B)._=B:i._=B:n._=B})(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index 944ab58bd..3576a9e02 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -177,13 +177,13 @@ * `union`, `uniq`, `unshift`, `values`, `where`, `without`, `wrap`, and `zip` * * The non-chainable wrapper functions are: - * `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`, - * `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, - * `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, - * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, - * `lastIndexOf`, `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, - * `result`, `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`, - * `uniqueId`, and `value` + * `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, + * `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, + * `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, + * `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, + * `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `parseInt`, + * `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`, + * `sortedIndex`, `runInContext`, `template`, `unescape`, `uniqueId`, and `value` * * The wrapper functions `first` and `last` return wrapped values when `n` is * passed, otherwise they return unwrapped values. diff --git a/doc/README.md b/doc/README.md index 40e2f0978..657118214 100644 --- a/doc/README.md +++ b/doc/README.md @@ -139,6 +139,7 @@ * [`_.methods`](#_functionsobject) * [`_.omit`](#_omitobject-callback-prop1-prop2--thisarg) * [`_.pairs`](#_pairsobject) +* [`_.parseInt`](#_parseintvalue) * [`_.pick`](#_pickobject-callback-prop1-prop2--thisarg) * [`_.values`](#_valuesobject) @@ -198,7 +199,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3214 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3236 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -222,7 +223,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3244 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3266 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -247,7 +248,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3317 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3339 "View in source") [Ⓣ][1] Gets the first element of the `array`. If a number `n` is passed, the first `n` elements of the `array` are returned. If a `callback` function is passed, elements at the beginning of the array are returned as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -307,7 +308,7 @@ _.first(food, { 'type': 'fruit' }); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3356 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3378 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -335,7 +336,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3398 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3420 "View in source") [Ⓣ][1] Gets the index at which the first occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `fromIndex` will run a faster binary search. @@ -367,7 +368,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3472 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3494 "View in source") [Ⓣ][1] Gets all but the last element of `array`. If a number `n` is passed, the last `n` elements are excluded from the result. If a `callback` function is passed, elements at the end of the array are excluded from the result as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -424,7 +425,7 @@ _.initial(food, { 'type': 'vegetable' }); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3506 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3528 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -448,7 +449,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3598 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3620 "View in source") [Ⓣ][1] Gets the last element of the `array`. If a number `n` is passed, the last `n` elements of the `array` are returned. If a `callback` function is passed, elements at the end of the array are returned as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments;(value, index, array). @@ -505,7 +506,7 @@ _.last(food, { 'type': 'vegetable' }); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3639 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3661 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -534,7 +535,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3669 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3691 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -559,7 +560,7 @@ _.object(['moe', 'larry'], [30, 40]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3713 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3735 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. @@ -597,7 +598,7 @@ _.range(0); ### `_.rest(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3792 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3814 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. If a number `n` is passed, the first `n` values are excluded from the result. If a `callback` function is passed, elements at the beginning of the array are excluded from the result as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -657,7 +658,7 @@ _.rest(food, { 'type': 'fruit' }); ### `_.sortedIndex(array, value [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3856 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3878 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. @@ -706,7 +707,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3888 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3910 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -730,7 +731,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3935 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3957 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -777,7 +778,7 @@ _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3994 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4016 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -802,7 +803,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4025 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4047 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -833,7 +834,7 @@ _.zip(['moe', 'larry'], [30, 40], [true, false]); ### `_(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L308 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L309 "View in source") [Ⓣ][1] Creates a `lodash` object, that wraps the given `value`, to enable method chaining. @@ -846,7 +847,7 @@ The chainable wrapper functions are:
`after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, `concat`, `countBy`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `push`, `range`, `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `unshift`, `values`, `where`, `without`, `wrap`, and `zip` The non-chainable wrapper functions are:
-`clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`, `uniqueId`, and `value` +`clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `runInContext`, `template`, `unescape`, `uniqueId`, and `value` The wrapper functions `first` and `last` return wrapped values when `n` is passed, otherwise they return unwrapped values. @@ -864,7 +865,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4924 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4946 "View in source") [Ⓣ][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. @@ -894,7 +895,7 @@ _([1, 2, 3, 4]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4941 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4963 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -915,7 +916,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4958 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4980 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -946,7 +947,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2215 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2237 "View in source") [Ⓣ][1] Creates an array of elements from the specified indexes, or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. @@ -974,7 +975,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2257 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2279 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -1012,7 +1013,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2311 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2333 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of the `collection` through the given `callback`. The corresponding value of each key is the number of times the key was returned by the `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1048,7 +1049,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2363 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2385 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1094,7 +1095,7 @@ _.every(stooges, { 'age': 50 }); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2424 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2446 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1140,7 +1141,7 @@ _.filter(food, { 'type': 'fruit' }); ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2491 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2513 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first that the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1188,7 +1189,7 @@ var healthy = _.find(food, 'organic'); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2526 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2548 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1220,7 +1221,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2576 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2598 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of the `collection` through the `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1257,7 +1258,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2609 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2631 "View in source") [Ⓣ][1] Invokes the method named by `methodName` on each element in the `collection`, returning an array of the results of each invoked method. Additional arguments will be passed to each invoked method. If `methodName` is a function, it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1286,7 +1287,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2661 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2683 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through the `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1331,7 +1332,7 @@ _.map(stooges, 'name'); ### `_.max(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2718 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2740 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1373,7 +1374,7 @@ _.max(stooges, 'age'); ### `_.min(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2787 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2809 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1415,7 +1416,7 @@ _.min(stooges, 'age'); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2837 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2859 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1445,7 +1446,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2869 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2891 "View in source") [Ⓣ][1] Reduces a `collection` to a value that is the accumulated result of running each element in the `collection` through the `callback`, where each successive `callback` execution consumes the return value of the previous execution. If `accumulator` is not passed, the first element of the `collection` will be used as the initial `accumulator` value. The `callback` is bound to `thisArg` and invoked with four arguments; *(accumulator, value, index|key, collection)*. @@ -1483,7 +1484,7 @@ var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2912 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2934 "View in source") [Ⓣ][1] This method is similar to `_.reduce`, except that it iterates over a `collection` from right to left. @@ -1514,7 +1515,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2972 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2994 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1557,7 +1558,7 @@ _.reject(food, { 'type': 'fruit' }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2993 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3015 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1581,7 +1582,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3026 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3048 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1611,7 +1612,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3073 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3095 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1657,7 +1658,7 @@ _.some(food, { 'type': 'meat' }); ### `_.sortBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3129 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3151 "View in source") [Ⓣ][1] Creates an array of elements, sorted in ascending order by the results of running each element in the `collection` through the `callback`. This method performs a stable sort, that is, it will preserve the original sort order of equal elements. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1694,7 +1695,7 @@ _.sortBy(['banana', 'strawberry', 'apple'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3164 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3186 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1718,7 +1719,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3196 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3218 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that have the given `properties`. When checking `properties`, this method performs a deep comparison between values to determine if they are equivalent to each other. @@ -1755,7 +1756,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4058 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4080 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1783,7 +1784,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4091 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4113 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1814,7 +1815,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4122 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4144 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. Method names may be specified as individual arguments or as arrays of method names. If no method names are provided, all the function properties of `object` will be bound. @@ -1845,7 +1846,7 @@ jQuery('#docs').on('click', view.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4168 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4190 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed to the bound function. This method differs from `_.bind` by allowing bound functions to reference methods that will be redefined or don't yet exist. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1886,7 +1887,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4191 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4213 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1913,7 +1914,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4224 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4246 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1939,7 +1940,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4288 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4310 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1964,7 +1965,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4268 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4290 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1991,7 +1992,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4316 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4338 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -2017,7 +2018,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4343 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4365 "View in source") [Ⓣ][1] Creates a function that is restricted to execute `func` once. Repeat calls to the function will return the value of the first call. The `func` is executed with the `this` binding of the created function. @@ -2043,7 +2044,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4378 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4400 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `_.bind`, except it does **not** alter the `this` binding. @@ -2070,7 +2071,7 @@ hi('moe'); ### `_.partialRight(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4409 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4431 "View in source") [Ⓣ][1] This method is similar to `_.partial`, except that `partial` arguments are appended to those passed to the new function. @@ -2107,7 +2108,7 @@ options.imports ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4431 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4453 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -2132,7 +2133,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4484 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4506 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -2168,7 +2169,7 @@ hello(); ### `_.assign(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1110 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1111 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the destination object. Subsequent sources will overwrite propery assignments of previous sources. If a `callback` function is passed, it will be executed to produce the assigned values. The `callback` is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. @@ -2206,7 +2207,7 @@ defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.clone(value [, deep=false, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1165 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1166 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. If a `callback` function is passed, it will be executed to produce the cloned values. If `callback` returns `undefined`, cloning will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. @@ -2253,7 +2254,7 @@ clone.childNodes.length; ### `_.cloneDeep(value [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1290 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1291 "View in source") [Ⓣ][1] Creates a deep clone of `value`. If a `callback` function is passed, it will be executed to produce the cloned values. If `callback` returns the value it was passed, cloning will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. @@ -2299,7 +2300,7 @@ clone.node == view.node; ### `_.defaults(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1314 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1315 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the destination object for all destination properties that resolve to `undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -2325,7 +2326,7 @@ _.defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L930 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L931 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2361,7 +2362,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L955 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L956 "View in source") [Ⓣ][1] Iterates over an object's own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2389,7 +2390,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1331 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1332 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2416,7 +2417,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1356 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1357 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2441,7 +2442,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1373 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1374 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2465,7 +2466,7 @@ _.invert({ 'first': 'moe', 'second': 'larry' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L891 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L892 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -2492,7 +2493,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L973 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L974 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2519,7 +2520,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1399 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1400 "View in source") [Ⓣ][1] Checks if `value` is a boolean value. @@ -2543,7 +2544,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1416 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1417 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2567,7 +2568,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1433 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1434 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2591,7 +2592,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1458 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1459 "View in source") [Ⓣ][1] Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -2621,7 +2622,7 @@ _.isEmpty(''); ### `_.isEqual(a, b [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1517 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1518 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. If `callback` is passed, it will be executed to compare values. If `callback` returns `undefined`, comparisons will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with two arguments; *(a, b)*. @@ -2666,7 +2667,7 @@ _.isEqual(words, otherWords, function(a, b) { ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1698 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1699 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2704,7 +2705,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1715 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1716 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2728,7 +2729,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1778 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1779 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -2763,7 +2764,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1800 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1801 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2790,7 +2791,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1817 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1818 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2814,7 +2815,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1745 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1746 "View in source") [Ⓣ][1] Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* @@ -2844,7 +2845,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1845 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1846 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2879,7 +2880,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1870 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1871 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2903,7 +2904,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1887 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1888 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -2927,7 +2928,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1904 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1905 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -2951,7 +2952,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L992 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L993 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -2975,7 +2976,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1964 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1965 "View in source") [Ⓣ][1] Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the destination object. Subsequent sources will overwrite propery assignments of previous sources. If a `callback` function is passed, it will be executed to produce the merged values of the destination and source properties. If `callback` returns `undefined`, merging will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. @@ -3031,7 +3032,7 @@ _.merge(food, otherFood, function(a, b) { ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2071 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2072 "View in source") [Ⓣ][1] Creates a shallow clone of `object` excluding the specified properties. Property names may be specified as individual arguments or as arrays of property names. If a `callback` function is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -3062,7 +3063,7 @@ _.omit({ 'name': 'moe', 'age': 40 }, function(value) { ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2105 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2106 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -3083,10 +3084,36 @@ _.pairs({ 'moe': 30, 'larry': 40 }); + + +### `_.parseInt(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2135 "View in source") [Ⓣ][1] + +Parses the given `value` into an integer of the specified `radix`. + +Note: This method avoids differences in ES3 and ES5 `parseInt` implementations. See http://es5.github.com/#E. + +#### Arguments +1. `value` *(Mixed)*: The value to parse. + +#### Returns +*(Number)*: Returns the new integer value. + +#### Example +```js +_.parseInt('08'); +// => 8 +``` + +* * * + + + + ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2143 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2165 "View in source") [Ⓣ][1] Creates a shallow clone of `object` composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. If `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -3117,7 +3144,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2180 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2202 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -3148,7 +3175,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4508 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4530 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -3172,7 +3199,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4526 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4548 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -3197,7 +3224,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4552 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4574 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -3227,7 +3254,7 @@ _('moe').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4576 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4598 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -3247,7 +3274,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4599 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4621 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -3275,7 +3302,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4637 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4659 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function, it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -3328,7 +3355,7 @@ Create a new `lodash` function using the given `context` object. ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4725 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4747 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -3412,7 +3439,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4850 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4872 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3444,7 +3471,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4876 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4898 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3468,7 +3495,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4896 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4918 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3502,7 +3529,7 @@ _.uniqueId(); ### `_.templateSettings.imports._` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L377 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L378 "View in source") [Ⓣ][1] A reference to the `lodash` function. @@ -3521,7 +3548,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5127 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5150 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -3533,7 +3560,7 @@ A reference to the `lodash` function. ### `_.templateSettings` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L329 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L330 "View in source") [Ⓣ][1] *(Object)*: By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby *(ERB)*. Change the following template settings to use alternative delimiters. @@ -3545,7 +3572,7 @@ A reference to the `lodash` function. ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L337 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L338 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to be HTML-escaped. @@ -3557,7 +3584,7 @@ A reference to the `lodash` function. ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L345 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L346 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect code to be evaluated. @@ -3569,7 +3596,7 @@ A reference to the `lodash` function. ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L353 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L354 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to inject. @@ -3581,7 +3608,7 @@ A reference to the `lodash` function. ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L361 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L362 "View in source") [Ⓣ][1] *(String)*: Used to reference the data object in the template text. @@ -3593,7 +3620,7 @@ A reference to the `lodash` function. ### `_.templateSettings.imports` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L369 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L370 "View in source") [Ⓣ][1] *(Object)*: Used to import variables into the compiled template. diff --git a/lodash.js b/lodash.js index 236c26f0b..c0e8d332a 100644 --- a/lodash.js +++ b/lodash.js @@ -169,6 +169,7 @@ nativeKeys = reNative.test(nativeKeys = Object.keys) && nativeKeys, nativeMax = Math.max, nativeMin = Math.min, + nativeParseInt = context.parseInt, nativeRandom = Math.random; /** Detect various environments */ @@ -288,13 +289,13 @@ * `union`, `uniq`, `unshift`, `values`, `where`, `without`, `wrap`, and `zip` * * The non-chainable wrapper functions are: - * `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`, - * `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, - * `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, - * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, - * `lastIndexOf`, `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`, - * `result`, `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`, - * `uniqueId`, and `value` + * `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, + * `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, + * `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, + * `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, + * `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `parseInt`, + * `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`, + * `sortedIndex`, `runInContext`, `template`, `unescape`, `uniqueId`, and `value` * * The wrapper functions `first` and `last` return wrapped values when `n` is * passed, otherwise they return unwrapped values. @@ -2115,6 +2116,27 @@ return result; } + /** + * Parses the given `value` into an integer of the specified `radix`. + * + * Note: This method avoids differences in ES3 and ES5 `parseInt` + * implementations. See http://es5.github.com/#E. + * + * @static + * @memberOf _ + * @category Objects + * @param {Mixed} value The value to parse. + * @returns {Number} Returns the new integer value. + * @example + * + * _.parseInt('08'); + * // => 8 + */ + var parseInt = nativeParseInt('08') == 8 ? nativeParseInt : function(value, radix) { + // Firefox and Opera have not changed to the ES5 specified implementation of `parseInt` + return nativeParseInt(isString(value) ? value.replace(/^0+(?=.$)/, '') : value, radix || 0); + }; + /** * Creates a shallow clone of `object` composed of the specified properties. * Property names may be specified as individual arguments or as arrays of property @@ -4666,7 +4688,6 @@ * interpolate - The "interpolate" delimiter regexp. * sourceURL - The sourceURL of the template's compiled source. * variable - The data object variable name. - * * @returns {Function|String} Returns a compiled function when no `data` object * is given, else it returns the interpolated text. * @example @@ -5063,6 +5084,7 @@ lodash.lastIndexOf = lastIndexOf; lodash.mixin = mixin; lodash.noConflict = noConflict; + lodash.parseInt = parseInt; lodash.random = random; lodash.reduce = reduce; lodash.reduceRight = reduceRight; diff --git a/test/test-build.js b/test/test-build.js index 317fa4fad..0e7af1455 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -210,6 +210,7 @@ 'merge', 'omit', 'pairs', + 'parseInt', 'pick', 'values' ]; @@ -291,6 +292,7 @@ 'forOwn', 'isPlainObject', 'merge', + 'parseInt', 'partialRight', 'runInContext' ])); diff --git a/test/test.js b/test/test.js index 545b3c437..e04205b42 100644 --- a/test/test.js +++ b/test/test.js @@ -1767,6 +1767,22 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.parseInt'); + + (function() { + test('should parse strings with leading zeros with a `radix` of 10 by default (test in Firefox and Opera)', function() { + equal(_.parseInt('08'), 8); + }); + + test('should internally use a radix of 10 if `radix` is `undefined` or `0`', function() { + equal(_.parseInt('10', 0), 10); + equal(_.parseInt('10'), 10); + equal(_.parseInt('10', undefined), 10); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('partial methods'); _.each(['partial', 'partialRight'], function(methodName) {