diff --git a/.travis.yml b/.travis.yml index 9dd4af0ad6..7cc82bd0ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,11 +9,11 @@ env: matrix: - BUILD="compat" - BUILD="modern" - - BUILD="legacy" MAKE=true - - BUILD="mobile" MAKE=true + - BUILD="legacy" + - BUILD="mobile" - BIN="phantomjs" BUILD="compat" - - BIN="phantomjs" BUILD="legacy" MAKE=true - - BIN="phantomjs" BUILD="mobile" MAKE=true + - BIN="phantomjs" BUILD="legacy" + - BIN="phantomjs" BUILD="mobile" matrix: include: - node_js: "0.10" @@ -21,25 +21,25 @@ matrix: - node_js: "0.10" env: BIN="narwhal" BUILD="compat" - node_js: "0.10" - env: BIN="narwhal" BUILD="legacy" MAKE=true + env: BIN="narwhal" BUILD="legacy" - node_js: "0.10" env: BIN="rhino" BUILD="compat" - node_js: "0.10" - env: BIN="rhino" BUILD="legacy" MAKE=true + env: BIN="rhino" BUILD="legacy" - node_js: "0.10" env: BIN="rhino" BUILD="compat" OPTION="-require" - node_js: "0.10" - env: BIN="rhino" BUILD="legacy" MAKE=true OPTION="-require" + env: BIN="rhino" BUILD="legacy" OPTION="-require" - node_js: "0.10" env: BIN="ringo" BUILD="compat" - node_js: "0.10" - env: BIN="ringo" BUILD="legacy" MAKE=true + env: BIN="ringo" BUILD="legacy" git: depth: 1 branches: only: - master -before_script: +before_install: - "[ $BIN == 'istanbul' ] && npm install -g istanbul || true" - "[ $BIN == 'narwhal' ] && wget https://github.com/280north/narwhal/archive/v0.3.2.zip && sudo unzip v0.3.2 -d /opt/ && rm v0.3.2.zip || true" - "[ $BIN == 'narwhal' ] && sudo ln -s /opt/narwhal-0.3.2/bin/narwhal /usr/local/bin/narwhal && sudo chmod +x /usr/local/bin/narwhal || true" @@ -49,6 +49,7 @@ before_script: - "[ $BIN == 'ringo' ] && sudo ln -s /opt/ringojs-0.9/bin/ringo /usr/local/bin/ringo && sudo chmod +x /usr/local/bin/ringo || true" script: - "[ $BIN == 'istanbul' ] && $BIN cover ./test/test.js || true" + - "[ $BUILD != false ] && [ $BUILD != 'compat' ] && [ $BUILD != 'modern' ] && MAKE=true || true" - "[ $MAKE != false ] && git clone --depth=1 --branch=master git://github.com/lodash/lodash-cli.git ./node_modules/lodash-cli || true" - "[ $MAKE != false ] && mkdir ./node_modules/lodash-cli/node_modules && cd ./node_modules/lodash-cli/node_modules/ && ln -s ../../../ ./lodash && cd ../ && npm i . && cd ../../ || true" - "[ $MAKE != false ] && node ./node_modules/lodash-cli/bin/lodash $BUILD -o ./dist/lodash.$BUILD.js || true" diff --git a/README.md b/README.md index ca83c37d53..3a2abc5321 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@ -# Lo-Dash v2.2.0 +# Lo-Dash v2.2.1 A utility library delivering consistency, [customization](http://lodash.com/custom-builds), [performance](http://lodash.com/benchmarks), & [extras](http://lodash.com/#features). ## Download * Modern builds perfect for newer browsers/environments:
-[Development](https://raw.github.com/lodash/lodash/2.2.0/dist/lodash.js) & -[Production](https://raw.github.com/lodash/lodash/2.2.0/dist/lodash.min.js) +[Development](https://raw.github.com/lodash/lodash/2.2.1/dist/lodash.js) & +[Production](https://raw.github.com/lodash/lodash/2.2.1/dist/lodash.min.js) * Compatibility builds for older environment support too:
-[Development](https://raw.github.com/lodash/lodash/2.2.0/dist/lodash.compat.js) & -[Production](https://raw.github.com/lodash/lodash/2.2.0/dist/lodash.compat.min.js) +[Development](https://raw.github.com/lodash/lodash/2.2.1/dist/lodash.compat.js) & +[Production](https://raw.github.com/lodash/lodash/2.2.1/dist/lodash.compat.min.js) * Underscore builds to use as a drop-in replacement:
-[Development](https://raw.github.com/lodash/lodash/2.2.0/dist/lodash.underscore.js) & -[Production](https://raw.github.com/lodash/lodash/2.2.0/dist/lodash.underscore.min.js) +[Development](https://raw.github.com/lodash/lodash/2.2.1/dist/lodash.underscore.js) & +[Production](https://raw.github.com/lodash/lodash/2.2.1/dist/lodash.underscore.min.js) CDN copies are available on [cdnjs](http://cdnjs.com/libraries/lodash.js/) & [jsDelivr](http://www.jsdelivr.com/#!lodash).
For smaller file sizes, create [custom builds](http://lodash.com/custom-builds) with only the features needed.
@@ -79,7 +79,7 @@ The full changelog for this release is available on our [wiki](https://github.co ## Support -Tested in Chrome 5~29, Firefox 2~24, IE 6-10, Opera 9.25~16, Safari 3-6, Node.js 0.6.8-0.10.18, Narwhal 0.3.2, PhantomJS 1.9.2, RingoJS 0.9, & Rhino 1.7RC5. +Tested in Chrome 5~29, Firefox 2~24, IE 6-10, Opera 9.25~16, Safari 3-6, Node.js 0.6.8-0.10.20, Narwhal 0.3.2, PhantomJS 1.9.2, RingoJS 0.9, & Rhino 1.7RC5. ## Installation & usage diff --git a/bower.json b/bower.json index 4b4db66e9f..352320e2cc 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "lodash", - "version": "2.2.0", + "version": "2.2.1", "main": "dist/lodash.compat.js", "ignore": [ ".*", diff --git a/component.json b/component.json index df4ea20e72..5750a62152 100644 --- a/component.json +++ b/component.json @@ -1,10 +1,10 @@ { "name": "lodash", "repo": "lodash/lodash", - "version": "2.2.0", + "version": "2.2.1", "description": "A utility library delivering consistency, customization, performance, & extras.", "license": "MIT", - "keywords": ["amd", "browser", "client", "customize", "functional", "performance", "server", "speed", "util"], + "keywords": ["amd", "browser", "client", "functional", "server", "util"], "scripts": [ "index.js", "dist/lodash.compat.js" diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 49136ed90d..e48344d4cf 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -1,6 +1,6 @@ /** * @license - * Lo-Dash 2.2.0 (Custom Build) + * Lo-Dash 2.2.1 (Custom Build) * Build: `lodash -o ./dist/lodash.compat.js` * Copyright 2012-2013 The Dojo Foundation * Based on Underscore.js 1.5.2 @@ -587,8 +587,8 @@ /*--------------------------------------------------------------------------*/ /** - * Creates a `lodash` object which wraps the given value to enable method - * chaining. + * Creates a `lodash` object which wraps the given value to enable intuitive + * method chaining. * * In addition to Lo-Dash methods, wrappers also have the following `Array` methods: * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`, @@ -622,6 +622,8 @@ * The wrapper functions `first` and `last` return wrapped values when `n` is * provided, otherwise they return unwrapped values. * + * Explicit chaining can be enabled by using the `_.chain` method. + * * @name _ * @constructor * @category Chaining @@ -5899,9 +5901,12 @@ push.apply(args, arguments); var result = func.apply(object, args); - return (value && typeof value == 'object' && value === result) - ? this - : new ctor(result); + if (value && typeof value == 'object' && value === result) { + return this; + } + result = new ctor(result); + result.__chain__ = this.__chain__; + return result; }; } }); @@ -6303,7 +6308,8 @@ /*--------------------------------------------------------------------------*/ /** - * Creates a `lodash` object that wraps the given value. + * Creates a `lodash` object that wraps the given value with explicit + * method chaining enabled. * * @static * @memberOf _ @@ -6319,9 +6325,10 @@ * ]; * * var youngest = _.chain(stooges) - * .sortBy(function(stooge) { return stooge.age; }) + * .sortBy('age') * .map(function(stooge) { return stooge.name + ' is ' + stooge.age; }) - * .first(); + * .first() + * .value(); * // => 'moe is 40' */ function chain(value) { @@ -6358,7 +6365,7 @@ } /** - * Enables method chaining on the wrapper object. + * Enables explicit method chaining on the wrapper object. * * @name chain * @memberOf _ @@ -6366,11 +6373,21 @@ * @returns {*} Returns the wrapper object. * @example * - * var sum = _([1, 2, 3]) - * .chain() - * .reduce(function(sum, num) { return sum + num; }) - * .value() - * // => 6` + * var stooges = [ + * { 'name': 'moe', 'age': 40 }, + * { 'name': 'larry', 'age': 50 } + * ]; + * + * // without explicit chaining + * _(stooges).first(); + * // => { 'name': 'moe', 'age': 40 } + * + * // with explicit chaining + * _(stooges).chain() + * .first() + * .pick('age') + * .value() + * // => { 'age': 40 } */ function wrapperChain() { this.__chain__ = true; @@ -6604,7 +6621,7 @@ * @memberOf _ * @type string */ - lodash.VERSION = '2.2.0'; + lodash.VERSION = '2.2.1'; // add "Chaining" functions to the wrapper lodash.prototype.chain = wrapperChain; diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 090098cf12..a2d078c27a 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -1,56 +1,56 @@ /** * @license - * Lo-Dash 2.2.0 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE + * Lo-Dash 2.2.1 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE * Build: `lodash -o ./dist/lodash.compat.js` */ -;(function(){function n(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++er||typeof e=="undefined")return 1;if(ee?0:e);++r=w&&l===n,h=u||g?i():c;if(g){var v=o(h);v?(l=t,h=v):(g=!1,h=u?h:(p(h),c))}for(;++al(h,y))&&((u||g)&&h.push(y),c.push(v))}return g?(p(h.k),s(h)):u&&p(h),c}function it(n){return function(t,e,r){var u={}; -if(e=y.createCallback(e,r,3),Je(t)){r=-1;for(var o=t.length;++rk;k++)r+="n='"+e.h[k]+"';if((!(r&&x[n])&&m.call(t,n))",e.j||(r+="||(!x[n]&&t[n]!==A[n])"),r+="){"+e.g+"}";r+="}"}return(e.b||We.nonEnumArgs)&&(r+="}"),r+=e.c+";return E",n("d,j,k,m,o,p,q,s,v,A,B,y,I,J,L",t+r+"}")(Z,K,le,de,b,vt,Je,jt,X.f,fe,Y,Ke,H,ce,ke) -}function ct(n){return _t(n)?Ie(n):{}}function pt(n){return Xe[n]}function st(){var t=(t=y.indexOf)===Lt?n:t;return t}function gt(n){var t,e;return!n||ke.call(n)!=J||(t=n.constructor,bt(t)&&!(t instanceof t))||!We.argsClass&&vt(n)||!We.nodeClass&&f(n)?!1:We.ownLast?(ur(n,function(n,t,r){return e=de.call(r,t),!1}),false!==e):(ur(n,function(n,t){e=t}),typeof e=="undefined"||de.call(n,e))}function ht(n){return Ye[n]}function vt(n){return n&&typeof n=="object"&&typeof n.length=="number"&&ke.call(n)==L||!1 -}function yt(n,t,e){var r=He(n),u=r.length;for(t=Z(t,e,3);u--&&(e=r[u],false!==t(n[e],e,n)););return n}function mt(n){var t=[];return ur(n,function(n,e){bt(n)&&t.push(e)}),t.sort()}function dt(n){for(var t=-1,e=He(n),r=e.length,u={};++tk;k++)r+="n='"+e.h[k]+"';if((!(r&&x[n])&&m.call(t,n))",e.j||(r+="||(!x[n]&&t[n]!==A[n])"),r+="){"+e.g+"}";r+="}"}return(e.b||We.nonEnumArgs)&&(r+="}"),r+=e.c+";return E",n("d,j,k,m,o,p,q,s,v,A,B,y,I,J,L",t+r+"}")(Z,K,le,de,_,vt,Je,jt,X.f,fe,Y,Ke,H,ce,ke) +}function ct(n){return bt(n)?Ie(n):{}}function pt(n){return Xe[n]}function st(){var t=(t=y.indexOf)===Lt?n:t;return t}function gt(n){var t,e;return!n||ke.call(n)!=J||(t=n.constructor,_t(t)&&!(t instanceof t))||!We.argsClass&&vt(n)||!We.nodeClass&&f(n)?!1:We.ownLast?(ur(n,function(n,t,r){return e=de.call(r,t),!1}),false!==e):(ur(n,function(n,t){e=t}),typeof e=="undefined"||de.call(n,e))}function ht(n){return Ye[n]}function vt(n){return n&&typeof n=="object"&&typeof n.length=="number"&&ke.call(n)==L||!1 +}function yt(n,t,e){var r=He(n),u=r.length;for(t=Z(t,e,3);u--&&(e=r[u],false!==t(n[e],e,n)););return n}function mt(n){var t=[];return ur(n,function(n,e){_t(n)&&t.push(e)}),t.sort()}function dt(n){for(var t=-1,e=He(n),r=e.length,u={};++te?Pe(0,o+e):e)||0,Je(n)?a=-1o&&(o=i)}}else t=!t&&jt(n)?r:y.createCallback(t,e,3),tr(n,function(n,e,r){e=t(n,e,r),e>u&&(u=e,o=n)});return o }function Bt(n,t,e,r){var u=3>arguments.length;if(t=Z(t,r,4),Je(n)){var o=-1,a=n.length;for(u&&(e=n[++o]);++oarguments.length;return t=Z(t,r,4),It(n,function(n,r,o){e=u?(u=!1,n):t(e,n,r,o)}),e}function Pt(n){var t=-1,e=n?n.length:0,r=Xt(typeof e=="number"?e:0);return St(n,function(n){var e=Vt(++t);r[t]=r[e],r[e]=n}),r}function Rt(n,t,e){var r;if(t=y.createCallback(t,e,3),Je(n)){e=-1;for(var u=n.length;++e=w&&u===n;if(f){var c=o(i);c?(u=t,i=c):f=!1}for(;++ru(i,c)&&l.push(c);return f&&s(i),l}function $t(n,t,e){var r=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=-1;for(t=y.createCallback(t,e,3);++or?Pe(0,u+r):r||0}else if(r)return r=zt(t,e),t[r]===e?r:-1; return n(t,e,r)}function Tt(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0;for(t=y.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:y}},Ie||(ct=function(n){if(_t(n)){c.prototype=n;var t=new c;c.prototype=null}return t||{}});var Ge=Oe?function(n,t){Q.value=t,Oe(n,"__bindData__",Q)}:c;We.argsClass||(vt=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&de.call(n,"callee")||!1});var Je=Ae||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&ke.call(n)==T||!1 -},Me=ft({a:"z",e:"[]",i:"if(!(B[typeof z]))return E",g:"E.push(n)"}),He=De?function(n){return _t(n)?We.enumPrototypes&&typeof n=="function"||We.nonEnumArgs&&n.length&&vt(n)?Me(n):De(n):[]}:Me,Ue={a:"g,e,K",i:"e=e&&typeof K=='undefined'?e:d(e,K,3)",b:"typeof u=='number'",v:He,g:"if(e(t[n],n,g)===false)return E"},Ve={a:"z,H,l",i:"var a=arguments,b=0,c=typeof l=='number'?2:a.length;while(++b":">",'"':""","'":"'"},Ye=dt(Xe),Ze=ue("("+He(Ye).join("|")+")","g"),nr=ue("["+He(Xe).join("")+"]","g"),tr=ft(Ue),er=ft(Ve,{i:Ve.i.replace(";",";if(c>3&&typeof a[c-2]=='function'){var e=d(a[--c-1],a[c--],2)}else if(c>2&&typeof a[c-1]=='function'){e=a[--c]}"),g:"E[n]=e?e(E[n],t[n]):t[n]"}),rr=ft(Ve),ur=ft(Ue,Qe,{j:!1}),or=ft(Ue,Qe); -bt(/x/)&&(bt=function(n){return typeof n=="function"&&ke.call(n)==W});var ar=me?function(n){if(!n||ke.call(n)!=J||!We.argsClass&&vt(n))return!1;var t=n.valueOf,e=typeof t=="function"&&(e=me(t))&&me(e);return e?n==e||me(n)==e:gt(n)}:gt,ir=it(function(n,t,e){de.call(n,e)?n[e]++:n[e]=1}),lr=it(function(n,t,e){(de.call(n,e)?n[e]:n[e]=[]).push(t)}),fr=it(function(n,t,e){n[e]=t}),cr=At;ze&&rt&&typeof je=="function"&&(Mt=function(n){if(!bt(n))throw new ae;return je.apply(e,arguments)});var pr=8==Fe(x+"08")?Fe:function(n,t){return Fe(jt(n)?n.replace(B,""):n,t||0) -};return y.after=function(n,t){if(!bt(t))throw new ae;return function(){return 1>--n?t.apply(this,arguments):void 0}},y.assign=er,y.at=function(n){var t=arguments,e=-1,r=tt(t,!0,!1,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=Xt(t);for(We.unindexedChars&&jt(n)&&(n=n.split(""));++e/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:y}},Ie||(ct=function(n){if(bt(n)){c.prototype=n;var t=new c;c.prototype=null}return t||{}});var Ge=Oe?function(n,t){Q.value=t,Oe(n,"__bindData__",Q)}:c;We.argsClass||(vt=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&de.call(n,"callee")||!1});var Je=Ae||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&ke.call(n)==T||!1 +},Me=ft({a:"z",e:"[]",i:"if(!(B[typeof z]))return E",g:"E.push(n)"}),He=De?function(n){return bt(n)?We.enumPrototypes&&typeof n=="function"||We.nonEnumArgs&&n.length&&vt(n)?Me(n):De(n):[]}:Me,Ue={a:"g,e,K",i:"e=e&&typeof K=='undefined'?e:d(e,K,3)",b:"typeof u=='number'",v:He,g:"if(e(t[n],n,g)===false)return E"},Ve={a:"z,H,l",i:"var a=arguments,b=0,c=typeof l=='number'?2:a.length;while(++b":">",'"':""","'":"'"},Ye=dt(Xe),Ze=ue("("+He(Ye).join("|")+")","g"),nr=ue("["+He(Xe).join("")+"]","g"),tr=ft(Ue),er=ft(Ve,{i:Ve.i.replace(";",";if(c>3&&typeof a[c-2]=='function'){var e=d(a[--c-1],a[c--],2)}else if(c>2&&typeof a[c-1]=='function'){e=a[--c]}"),g:"E[n]=e?e(E[n],t[n]):t[n]"}),rr=ft(Ve),ur=ft(Ue,Qe,{j:!1}),or=ft(Ue,Qe); +_t(/x/)&&(_t=function(n){return typeof n=="function"&&ke.call(n)==W});var ar=me?function(n){if(!n||ke.call(n)!=J||!We.argsClass&&vt(n))return!1;var t=n.valueOf,e=typeof t=="function"&&(e=me(t))&&me(e);return e?n==e||me(n)==e:gt(n)}:gt,ir=it(function(n,t,e){de.call(n,e)?n[e]++:n[e]=1}),lr=it(function(n,t,e){(de.call(n,e)?n[e]:n[e]=[]).push(t)}),fr=it(function(n,t,e){n[e]=t}),cr=At;ze&&rt&&typeof je=="function"&&(Mt=function(n){if(!_t(n))throw new ae;return je.apply(e,arguments)});var pr=8==Fe(x+"08")?Fe:function(n,t){return Fe(jt(n)?n.replace(B,""):n,t||0) +};return y.after=function(n,t){if(!_t(t))throw new ae;return function(){return 1>--n?t.apply(this,arguments):void 0}},y.assign=er,y.at=function(n){var t=arguments,e=-1,r=tt(t,!0,!1,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=Xt(t);for(We.unindexedChars&&jt(n)&&(n=n.split(""));++e=w&&o(a?r[a]:v)}n:for(;++f(m?t(m,y):c(v,y))){for(a=u,(m||v).push(y);--a;)if(m=l[a],0>(m?t(m,y):c(r[a],y)))continue n;h.push(y)}}for(;u--;)(m=l[u])&&s(m);return p(l),p(v),h},y.invert=dt,y.invoke=function(n,t){var e=Le.call(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,a=Xt(typeof o=="number"?o:0);return St(n,function(n){a[++r]=(u?t:n[t]).apply(n,e)}),a},y.keys=He,y.map=At,y.max=Nt,y.memoize=function(n,t){function e(){var r=e.cache,u=t?t.apply(this,arguments):_+arguments[0]; -return de.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}if(!bt(n))throw new ae;return e.cache={},e},y.merge=function(n){var t=arguments,e=2;if(!_t(n))return n;if("number"!=typeof t[2]&&(e=t.length),3r(a,e))&&(o[e]=n)}),o},y.once=function(n){var t,e;if(!bt(n))throw new ae;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e)}},y.pairs=function(n){for(var t=-1,e=He(n),r=e.length,u=Xt(r);++t=w&&o(a?r[a]:v)}n:for(;++f(m?t(m,y):c(v,y))){for(a=u,(m||v).push(y);--a;)if(m=l[a],0>(m?t(m,y):c(r[a],y)))continue n;h.push(y)}}for(;u--;)(m=l[u])&&s(m);return p(l),p(v),h},y.invert=dt,y.invoke=function(n,t){var e=Le.call(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,a=Xt(typeof o=="number"?o:0);return St(n,function(n){a[++r]=(u?t:n[t]).apply(n,e)}),a},y.keys=He,y.map=At,y.max=Nt,y.memoize=function(n,t){function e(){var r=e.cache,u=t?t.apply(this,arguments):b+arguments[0]; +return de.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}if(!_t(n))throw new ae;return e.cache={},e},y.merge=function(n){var t=arguments,e=2;if(!bt(n))return n;if("number"!=typeof t[2]&&(e=t.length),3r(a,e))&&(o[e]=n)}),o},y.once=function(n){var t,e;if(!_t(n))throw new ae;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e)}},y.pairs=function(n){for(var t=-1,e=He(n),r=e.length,u=Xt(r);++te?Pe(0,r+e):Re(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},y.mixin=Ut,y.noConflict=function(){return e._=pe,this},y.parseInt=pr,y.random=Vt,y.reduce=Bt,y.reduceRight=Dt,y.result=function(n,t){if(n){var e=n[t];return bt(e)?n[t]():e}},y.runInContext=h,y.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:He(n).length},y.some=Rt,y.sortedIndex=zt,y.template=function(n,t,e){var r=y.templateSettings; +},y.isEmpty=function(n){var t=!0;if(!n)return t;var e=ke.call(n),r=n.length;return e==T||e==H||(We.argsClass?e==L:vt(n))||e==J&&typeof r=="number"&&_t(n.splice)?!r:(or(n,function(){return t=!1}),t)},y.isEqual=function(n,t,e,r){return et(n,t,typeof e=="function"&&Z(e,r,2))},y.isFinite=function(n){return Ne(n)&&!Be(parseFloat(n))},y.isFunction=_t,y.isNaN=function(n){return wt(n)&&n!=+n},y.isNull=function(n){return null===n},y.isNumber=wt,y.isObject=bt,y.isPlainObject=ar,y.isRegExp=function(n){return n&&Y[typeof n]?ke.call(n)==M:!1 +},y.isString=jt,y.isUndefined=function(n){return typeof n=="undefined"},y.lastIndexOf=function(n,t,e){var r=n?n.length:0;for(typeof e=="number"&&(r=(0>e?Pe(0,r+e):Re(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},y.mixin=Ut,y.noConflict=function(){return e._=pe,this},y.parseInt=pr,y.random=Vt,y.reduce=Bt,y.reduceRight=Dt,y.result=function(n,t){if(n){var e=n[t];return _t(e)?n[t]():e}},y.runInContext=h,y.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:He(n).length},y.some=Rt,y.sortedIndex=zt,y.template=function(n,t,e){var r=y.templateSettings; n||(n=""),e=rr({},e,r);var u,o=rr({},e.imports,r.imports),r=He(o),o=xt(o),i=0,l=e.interpolate||D,f="__p+='",l=ue((e.escape||D).source+"|"+l.source+"|"+(l===N?S:D).source+"|"+(e.evaluate||D).source+"|$","g");n.replace(l,function(t,e,r,o,l,c){return r||(r=o),f+=n.slice(i,c).replace(R,a),e&&(f+="'+__e("+e+")+'"),l&&(u=!0,f+="';"+l+";__p+='"),r&&(f+="'+((__t=("+r+"))==null?'':__t)+'"),i=c+t.length,t}),f+="';\n",l=e=e.variable,l||(e="obj",f="with("+e+"){"+f+"}"),f=(u?f.replace(C,""):f).replace(E,"$1").replace(O,"$1;"),f="function("+e+"){"+(l?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+f+"return __p}"; -try{var c=ne(r,"return "+f).apply(v,o)}catch(p){throw p.source=f,p}return t?c(t):(c.source=f,c)},y.unescape=function(n){return null==n?"":oe(n).replace(Ze,ht)},y.uniqueId=function(n){var t=++d;return oe(null==n?"":n)+t},y.all=kt,y.any=Rt,y.detect=Ot,y.findWhere=Ot,y.foldl=Bt,y.foldr=Dt,y.include=Ct,y.inject=Bt,or(y,function(n,t){y.prototype[t]||(y.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return _e.apply(t,arguments),t=n.apply(y,t),e?new m(t,e):t})}),y.first=$t,y.last=function(n,t,e){var r=0,u=n?n.length:0; +try{var c=ne(r,"return "+f).apply(v,o)}catch(p){throw p.source=f,p}return t?c(t):(c.source=f,c)},y.unescape=function(n){return null==n?"":oe(n).replace(Ze,ht)},y.uniqueId=function(n){var t=++d;return oe(null==n?"":n)+t},y.all=kt,y.any=Rt,y.detect=Ot,y.findWhere=Ot,y.foldl=Bt,y.foldr=Dt,y.include=Ct,y.inject=Bt,or(y,function(n,t){y.prototype[t]||(y.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return be.apply(t,arguments),t=n.apply(y,t),e?new m(t,e):t})}),y.first=$t,y.last=function(n,t,e){var r=0,u=n?n.length:0; if(typeof t!="number"&&null!=t){var o=u;for(t=y.createCallback(t,e,3);o--&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n?n[u-1]:v;return g(n,Pe(0,u-r))},y.sample=function(n,t,e){var r=n?n.length:0;return typeof r!="number"?n=xt(n):We.unindexedChars&&jt(n)&&(n=n.split("")),null==t||e?n?n[Vt(r-1)]:v:(n=Pt(n),n.length=Re(Pe(0,t),n.length),n)},y.take=$t,y.head=$t,or(y,function(n,t){var e="sample"!==t;y.prototype[t]||(y.prototype[t]=function(t,r){var u=this.__chain__,o=n(this.__wrapped__,t,r);return u||null!=t&&(!r||e&&typeof t=="function")?new m(o,u):o -})}),y.VERSION="2.2.0",y.prototype.chain=function(){return this.__chain__=!0,this},y.prototype.toString=function(){return oe(this.__wrapped__)},y.prototype.value=Qt,y.prototype.valueOf=Qt,tr(["join","pop","shift"],function(n){var t=ie[n];y.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new m(e,n):e}}),tr(["push","reverse","sort","unshift"],function(n){var t=ie[n];y.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),tr(["concat","slice","splice"],function(n){var t=ie[n]; -y.prototype[n]=function(){return new m(t.apply(this.__wrapped__,arguments),this.__chain__)}}),We.spliceObjects||tr(["pop","shift","splice"],function(n){var t=ie[n],e="splice"==n;y.prototype[n]=function(){var n=this.__chain__,r=this.__wrapped__,u=t.apply(r,arguments);return 0===r.length&&delete r[0],n||e?new m(u,n):u}}),y}var v,y=[],m=[],d=0,b={},_=+new Date+"",w=75,j=40,x=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",C=/\b__p\+='';/g,E=/\b(__p\+=)''\+/g,O=/(__e\(.*?\)|\b__t\))\+'';/g,S=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,I=/\w*$/,A=/^function[ \n\r\t]+\w/,N=/<%=([\s\S]+?)%>/g,B=RegExp("^["+x+"]*0+(?=.$)"),D=/($^)/,P=/\bthis\b/,R=/['\n\r\t\u2028\u2029\\]/g,F="Array Boolean Date Error Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),$="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),L="[object Arguments]",T="[object Array]",z="[object Boolean]",q="[object Date]",K="[object Error]",W="[object Function]",G="[object Number]",J="[object Object]",M="[object RegExp]",H="[object String]",U={}; +})}),y.VERSION="2.2.1",y.prototype.chain=function(){return this.__chain__=!0,this},y.prototype.toString=function(){return oe(this.__wrapped__)},y.prototype.value=Qt,y.prototype.valueOf=Qt,tr(["join","pop","shift"],function(n){var t=ie[n];y.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new m(e,n):e}}),tr(["push","reverse","sort","unshift"],function(n){var t=ie[n];y.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),tr(["concat","slice","splice"],function(n){var t=ie[n]; +y.prototype[n]=function(){return new m(t.apply(this.__wrapped__,arguments),this.__chain__)}}),We.spliceObjects||tr(["pop","shift","splice"],function(n){var t=ie[n],e="splice"==n;y.prototype[n]=function(){var n=this.__chain__,r=this.__wrapped__,u=t.apply(r,arguments);return 0===r.length&&delete r[0],n||e?new m(u,n):u}}),y}var v,y=[],m=[],d=0,_={},b=+new Date+"",w=75,j=40,x=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",C=/\b__p\+='';/g,E=/\b(__p\+=)''\+/g,O=/(__e\(.*?\)|\b__t\))\+'';/g,S=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,I=/\w*$/,A=/^function[ \n\r\t]+\w/,N=/<%=([\s\S]+?)%>/g,B=RegExp("^["+x+"]*0+(?=.$)"),D=/($^)/,P=/\bthis\b/,R=/['\n\r\t\u2028\u2029\\]/g,F="Array Boolean Date Error Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),$="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),L="[object Arguments]",T="[object Array]",z="[object Boolean]",q="[object Date]",K="[object Error]",W="[object Function]",G="[object Number]",J="[object Object]",M="[object RegExp]",H="[object String]",U={}; U[W]=!1,U[L]=U[T]=U[z]=U[q]=U[G]=U[J]=U[M]=U[H]=!0;var V={leading:!1,maxWait:0,trailing:!1},Q={configurable:!1,enumerable:!1,value:null,writable:!1},X={a:"",b:null,c:"",d:"",e:"",v:null,g:"",h:null,support:null,i:"",j:!1},Y={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},Z={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},nt=Y[typeof window]&&window||this,tt=Y[typeof exports]&&exports&&!exports.nodeType&&exports,et=Y[typeof module]&&module&&!module.nodeType&&module,rt=et&&et.exports===tt&&tt,ut=Y[typeof global]&&global; !ut||ut.global!==ut&&ut.window!==ut||(nt=ut);var ot=h();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(nt._=ot, define(function(){return ot})):tt&&et?rt?(et.exports=ot)._=ot:tt._=ot:nt._=ot}).call(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index cdd275d73c..568c476c84 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -1,6 +1,6 @@ /** * @license - * Lo-Dash 2.2.0 (Custom Build) + * Lo-Dash 2.2.1 (Custom Build) * Build: `lodash modern -o ./dist/lodash.js` * Copyright 2012-2013 The Dojo Foundation * Based on Underscore.js 1.5.2 @@ -526,8 +526,8 @@ /*--------------------------------------------------------------------------*/ /** - * Creates a `lodash` object which wraps the given value to enable method - * chaining. + * Creates a `lodash` object which wraps the given value to enable intuitive + * method chaining. * * In addition to Lo-Dash methods, wrappers also have the following `Array` methods: * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`, @@ -561,6 +561,8 @@ * The wrapper functions `first` and `last` return wrapped values when `n` is * provided, otherwise they return unwrapped values. * + * Explicit chaining can be enabled by using the `_.chain` method. + * * @name _ * @constructor * @category Chaining @@ -1330,6 +1332,17 @@ function createObject(prototype) { return isObject(prototype) ? nativeCreate(prototype) : {}; } + // fallback for browsers without `Object.create` + if (!nativeCreate) { + createObject = function(prototype) { + if (isObject(prototype)) { + noop.prototype = prototype; + var result = new noop; + noop.prototype = null; + } + return result || {}; + }; + } /** * Used by `escape` to convert characters to HTML entities. @@ -5549,9 +5562,12 @@ push.apply(args, arguments); var result = func.apply(object, args); - return (value && typeof value == 'object' && value === result) - ? this - : new ctor(result); + if (value && typeof value == 'object' && value === result) { + return this; + } + result = new ctor(result); + result.__chain__ = this.__chain__; + return result; }; } }); @@ -5953,7 +5969,8 @@ /*--------------------------------------------------------------------------*/ /** - * Creates a `lodash` object that wraps the given value. + * Creates a `lodash` object that wraps the given value with explicit + * method chaining enabled. * * @static * @memberOf _ @@ -5969,9 +5986,10 @@ * ]; * * var youngest = _.chain(stooges) - * .sortBy(function(stooge) { return stooge.age; }) + * .sortBy('age') * .map(function(stooge) { return stooge.name + ' is ' + stooge.age; }) - * .first(); + * .first() + * .value(); * // => 'moe is 40' */ function chain(value) { @@ -6008,7 +6026,7 @@ } /** - * Enables method chaining on the wrapper object. + * Enables explicit method chaining on the wrapper object. * * @name chain * @memberOf _ @@ -6016,11 +6034,21 @@ * @returns {*} Returns the wrapper object. * @example * - * var sum = _([1, 2, 3]) - * .chain() - * .reduce(function(sum, num) { return sum + num; }) - * .value() - * // => 6` + * var stooges = [ + * { 'name': 'moe', 'age': 40 }, + * { 'name': 'larry', 'age': 50 } + * ]; + * + * // without explicit chaining + * _(stooges).first(); + * // => { 'name': 'moe', 'age': 40 } + * + * // with explicit chaining + * _(stooges).chain() + * .first() + * .pick('age') + * .value() + * // => { 'age': 40 } */ function wrapperChain() { this.__chain__ = true; @@ -6254,7 +6282,7 @@ * @memberOf _ * @type string */ - lodash.VERSION = '2.2.0'; + lodash.VERSION = '2.2.1'; // add "Chaining" functions to the wrapper lodash.prototype.chain = wrapperChain; diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 7ebe2c9bc6..0fd9246efa 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -1,52 +1,54 @@ /** * @license - * Lo-Dash 2.2.0 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE + * Lo-Dash 2.2.1 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE * Build: `lodash modern -o ./dist/lodash.js` */ -;(function(){function n(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++er||typeof e=="undefined")return 1;if(ee?0:e);++r=_&&f===n,h=u||v?i():s;if(v){var g=o(h);g?(f=t,h=g):(v=!1,h=u?h:(c(h),s))}for(;++af(h,y))&&((u||v)&&h.push(y),s.push(g))}return v?(c(h.k),p(h)):u&&c(h),s}function it(n){return function(t,e,r){var u={};e=Y.createCallback(e,r,3),r=-1;var o=t?t.length:0;if(typeof o=="number")for(;++re?Se(0,o+e):e)||0,ze(n)?a=-1o&&(o=i)}}else t=!t&&dt(n)?r:Y.createCallback(t,e,3),Ot(n,function(n,e,r){e=t(n,e,r),e>u&&(u=e,o=n)});return o}function St(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Qt(r);++earguments.length;t=et(t,r,4);var o=-1,a=n.length;if(typeof a=="number")for(u&&(e=n[++o]);++oarguments.length;return t=et(t,r,4),It(n,function(n,r,o){e=u?(u=!1,n):t(e,n,r,o)}),e}function Dt(n){var t=-1,e=n?n.length:0,r=Qt(typeof e=="number"?e:0);return Ot(n,function(n){var e=Ht(++t);r[t]=r[e],r[e]=n}),r}function Bt(n,t,e){var r;t=Y.createCallback(t,e,3),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e=_&&u===n; -if(l){var c=o(i);c?(u=t,i=c):l=!1}for(;++ru(i,c)&&f.push(c);return l&&p(i),f}function Ft(n,t,e){var r=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=-1;for(t=Y.createCallback(t,e,3);++or?Se(0,u+r):r||0}else if(r)return r=qt(t,e),t[r]===e?r:-1;return n(t,e,r)}function Wt(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0; -for(t=Y.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:Y}};var qe=ke?function(n,t){U.value=t,ke(n,"__bindData__",U)}:l,ze=Oe||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&we.call(n)==$||!1},Pe=Ee?function(n){return bt(n)?Ee(n):[]}:Q,Ke={"&":"&","<":"<",">":">",'"':""","'":"'"},Le=yt(Ke),Me=re("("+Pe(Le).join("|")+")","g"),Ue=re("["+Pe(Ke).join("")+"]","g"),Ve=it(function(n,t,e){ge.call(n,e)?n[e]++:n[e]=1 -}),Ge=it(function(n,t,e){(ge.call(n,e)?n[e]:n[e]=[]).push(t)}),He=it(function(n,t,e){n[e]=t});Fe&&X&&typeof be=="function"&&(Ut=function(n){if(!mt(n))throw new oe;return be.apply(e,arguments)});var Je=8==Ae(w+"08")?Ae:function(n,t){return Ae(dt(n)?n.replace(E,""):n,t||0)};return Y.after=function(n,t){if(!mt(t))throw new oe;return function(){return 1>--n?t.apply(this,arguments):void 0}},Y.assign=J,Y.at=function(n){for(var t=arguments,e=-1,r=rt(t,!0,!1,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=Qt(t);++e=_&&o(a?r[a]:g)}n:for(;++l(m?t(m,y):s(g,y))){for(a=u,(m||g).push(y);--a;)if(m=f[a],0>(m?t(m,y):s(r[a],y)))continue n;h.push(y)}}for(;u--;)(m=f[u])&&p(m);return c(f),c(g),h},Y.invert=yt,Y.invoke=function(n,t){var e=Be.call(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,a=Qt(typeof o=="number"?o:0); -return Ot(n,function(n){a[++r]=(u?t:n[t]).apply(n,e)}),a},Y.keys=Pe,Y.map=Nt,Y.max=Et,Y.memoize=function(n,t){function e(){var r=e.cache,u=t?t.apply(this,arguments):b+arguments[0];return ge.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}if(!mt(n))throw new oe;return e.cache={},e},Y.merge=function(n){var t=arguments,e=2;if(!bt(n))return n;if("number"!=typeof t[2]&&(e=t.length),3r(a,e))&&(o[e]=n)}),o},Y.once=function(n){var t,e;if(!mt(n))throw new oe;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e) -}},Y.pairs=function(n){for(var t=-1,e=Pe(n),r=e.length,u=Qt(r);++te?Se(0,r+e):Re(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},Y.mixin=Gt,Y.noConflict=function(){return e._=fe,this},Y.parseInt=Je,Y.random=Ht,Y.reduce=Rt,Y.reduceRight=At,Y.result=function(n,t){if(n){var e=n[t];return mt(e)?n[t]():e}},Y.runInContext=v,Y.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Pe(n).length},Y.some=Bt,Y.sortedIndex=qt,Y.template=function(n,t,e){var r=Y.templateSettings; -n||(n=""),e=G({},e,r);var u,o=G({},e.imports,r.imports),r=Pe(o),o=wt(o),i=0,f=e.interpolate||S,l="__p+='",f=re((e.escape||S).source+"|"+f.source+"|"+(f===N?C:S).source+"|"+(e.evaluate||S).source+"|$","g");n.replace(f,function(t,e,r,o,f,c){return r||(r=o),l+=n.slice(i,c).replace(A,a),e&&(l+="'+__e("+e+")+'"),f&&(u=!0,l+="';"+f+";__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),i=c+t.length,t}),l+="';\n",f=e=e.variable,f||(e="obj",l="with("+e+"){"+l+"}"),l=(u?l.replace(j,""):l).replace(k,"$1").replace(x,"$1;"),l="function("+e+"){"+(f?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}"; -try{var c=Zt(r,"return "+l).apply(h,o)}catch(p){throw p.source=l,p}return t?c(t):(c.source=l,c)},Y.unescape=function(n){return null==n?"":ue(n).replace(Me,st)},Y.uniqueId=function(n){var t=++m;return ue(null==n?"":n)+t},Y.all=kt,Y.any=Bt,Y.detect=Ct,Y.findWhere=Ct,Y.foldl=Rt,Y.foldr=At,Y.include=jt,Y.inject=Rt,y(Y,function(n,t){Y.prototype[t]||(Y.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return me.apply(t,arguments),t=n.apply(Y,t),e?new nt(t,e):t})}),Y.first=Ft,Y.last=function(n,t,e){var r=0,u=n?n.length:0; -if(typeof t!="number"&&null!=t){var o=u;for(t=Y.createCallback(t,e,3);o--&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n?n[u-1]:h;return s(n,Se(0,u-r))},Y.sample=function(n,t,e){var r=n?n.length:0;return typeof r!="number"&&(n=wt(n)),null==t||e?n?n[Ht(r-1)]:h:(n=Dt(n),n.length=Re(Se(0,t),n.length),n)},Y.take=Ft,Y.head=Ft,y(Y,function(n,t){var e="sample"!==t;Y.prototype[t]||(Y.prototype[t]=function(t,r){var u=this.__chain__,o=n(this.__wrapped__,t,r);return u||null!=t&&(!r||e&&typeof t=="function")?new nt(o,u):o -})}),Y.VERSION="2.2.0",Y.prototype.chain=function(){return this.__chain__=!0,this},Y.prototype.toString=function(){return ue(this.__wrapped__)},Y.prototype.value=Jt,Y.prototype.valueOf=Jt,Ot(["join","pop","shift"],function(n){var t=ae[n];Y.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new nt(e,n):e}}),Ot(["push","reverse","sort","unshift"],function(n){var t=ae[n];Y.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Ot(["concat","slice","splice"],function(n){var t=ae[n]; -Y.prototype[n]=function(){return new nt(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Y}var h,g=[],y=[],m=0,b=+new Date+"",_=75,d=40,w=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",j=/\b__p\+='';/g,k=/\b(__p\+=)''\+/g,x=/(__e\(.*?\)|\b__t\))\+'';/g,C=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,O=/\w*$/,I=/^function[ \n\r\t]+\w/,N=/<%=([\s\S]+?)%>/g,E=RegExp("^["+w+"]*0+(?=.$)"),S=/($^)/,R=/\bthis\b/,A=/['\n\r\t\u2028\u2029\\]/g,D="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),B="[object Arguments]",$="[object Array]",F="[object Boolean]",T="[object Date]",W="[object Function]",q="[object Number]",z="[object Object]",P="[object RegExp]",K="[object String]",L={}; +}function l(){}function c(n){n.length=0,g.lengthe?0:e);++r=b&&f===n,h=u||v?i():s;if(v){var g=o(h);g?(f=t,h=g):(v=!1,h=u?h:(c(h),s))}for(;++af(h,y))&&((u||v)&&h.push(y),s.push(g))}return v?(c(h.k),p(h)):u&&c(h),s}function it(n){return function(t,e,r){var u={};e=Y.createCallback(e,r,3),r=-1;var o=t?t.length:0;if(typeof o=="number")for(;++re?Re(0,o+e):e)||0,Pe(n)?a=-1o&&(o=i)}}else t=!t&&wt(n)?r:Y.createCallback(t,e,3),It(n,function(n,e,r){e=t(n,e,r),e>u&&(u=e,o=n)});return o}function Rt(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Xt(r);++earguments.length;t=et(t,r,4);var o=-1,a=n.length;if(typeof a=="number")for(u&&(e=n[++o]);++oarguments.length;return t=et(t,r,4),Nt(n,function(n,r,o){e=u?(u=!1,n):t(e,n,r,o)}),e}function Bt(n){var t=-1,e=n?n.length:0,r=Xt(typeof e=="number"?e:0);return It(n,function(n){var e=Jt(++t);r[t]=r[e],r[e]=n}),r}function $t(n,t,e){var r;t=Y.createCallback(t,e,3),e=-1; +var u=n?n.length:0;if(typeof u=="number")for(;++e=b&&u===n;if(l){var c=o(i);c?(u=t,i=c):l=!1}for(;++ru(i,c)&&f.push(c);return l&&p(i),f}function Tt(n,t,e){var r=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=-1;for(t=Y.createCallback(t,e,3);++or?Re(0,u+r):r||0}else if(r)return r=zt(t,e),t[r]===e?r:-1;return n(t,e,r)}function qt(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0;for(t=Y.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:Y}},Oe||(lt=function(n){if(bt(n)){l.prototype=n;var t=new l;l.prototype=null}return t||{}});var ze=xe?function(n,t){U.value=t,xe(n,"__bindData__",U)}:l,Pe=Ie||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&je.call(n)==$||!1},Ke=Se?function(n){return bt(n)?Se(n):[] +}:Q,Le={"&":"&","<":"<",">":">",'"':""","'":"'"},Me=mt(Le),Ue=ue("("+Ke(Me).join("|")+")","g"),Ve=ue("["+Ke(Le).join("")+"]","g"),Ge=it(function(n,t,e){ye.call(n,e)?n[e]++:n[e]=1}),He=it(function(n,t,e){(ye.call(n,e)?n[e]:n[e]=[]).push(t)}),Je=it(function(n,t,e){n[e]=t});Te&&X&&typeof be=="function"&&(Vt=function(n){if(!_t(n))throw new ae;return be.apply(e,arguments)});var Qe=8==De(w+"08")?De:function(n,t){return De(wt(n)?n.replace(E,""):n,t||0)};return Y.after=function(n,t){if(!_t(t))throw new ae; +return function(){return 1>--n?t.apply(this,arguments):void 0}},Y.assign=J,Y.at=function(n){for(var t=arguments,e=-1,r=rt(t,!0,!1,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=Xt(t);++e=b&&o(a?r[a]:g) +}n:for(;++l(m?t(m,y):s(g,y))){for(a=u,(m||g).push(y);--a;)if(m=f[a],0>(m?t(m,y):s(r[a],y)))continue n;h.push(y)}}for(;u--;)(m=f[u])&&p(m);return c(f),c(g),h},Y.invert=mt,Y.invoke=function(n,t){var e=$e.call(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,a=Xt(typeof o=="number"?o:0);return It(n,function(n){a[++r]=(u?t:n[t]).apply(n,e)}),a},Y.keys=Ke,Y.map=Et,Y.max=St,Y.memoize=function(n,t){function e(){var r=e.cache,u=t?t.apply(this,arguments):_+arguments[0];return ye.call(r,u)?r[u]:r[u]=n.apply(this,arguments) +}if(!_t(n))throw new ae;return e.cache={},e},Y.merge=function(n){var t=arguments,e=2;if(!bt(n))return n;if("number"!=typeof t[2]&&(e=t.length),3r(a,e))&&(o[e]=n)}),o},Y.once=function(n){var t,e;if(!_t(n))throw new ae;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e)}},Y.pairs=function(n){for(var t=-1,e=Ke(n),r=e.length,u=Xt(r);++te?Re(0,r+e):Ae(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},Y.mixin=Ht,Y.noConflict=function(){return e._=le,this},Y.parseInt=Qe,Y.random=Jt,Y.reduce=At,Y.reduceRight=Dt,Y.result=function(n,t){if(n){var e=n[t];return _t(e)?n[t]():e}},Y.runInContext=v,Y.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Ke(n).length},Y.some=$t,Y.sortedIndex=zt,Y.template=function(n,t,e){var r=Y.templateSettings; +n||(n=""),e=G({},e,r);var u,o=G({},e.imports,r.imports),r=Ke(o),o=jt(o),i=0,f=e.interpolate||S,l="__p+='",f=ue((e.escape||S).source+"|"+f.source+"|"+(f===N?C:S).source+"|"+(e.evaluate||S).source+"|$","g");n.replace(f,function(t,e,r,o,f,c){return r||(r=o),l+=n.slice(i,c).replace(A,a),e&&(l+="'+__e("+e+")+'"),f&&(u=!0,l+="';"+f+";__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),i=c+t.length,t}),l+="';\n",f=e=e.variable,f||(e="obj",l="with("+e+"){"+l+"}"),l=(u?l.replace(j,""):l).replace(k,"$1").replace(x,"$1;"),l="function("+e+"){"+(f?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}"; +try{var c=ne(r,"return "+l).apply(h,o)}catch(p){throw p.source=l,p}return t?c(t):(c.source=l,c)},Y.unescape=function(n){return null==n?"":oe(n).replace(Ue,vt)},Y.uniqueId=function(n){var t=++m;return oe(null==n?"":n)+t},Y.all=xt,Y.any=$t,Y.detect=Ot,Y.findWhere=Ot,Y.foldl=At,Y.foldr=Dt,Y.include=kt,Y.inject=At,y(Y,function(n,t){Y.prototype[t]||(Y.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return _e.apply(t,arguments),t=n.apply(Y,t),e?new nt(t,e):t})}),Y.first=Tt,Y.last=function(n,t,e){var r=0,u=n?n.length:0; +if(typeof t!="number"&&null!=t){var o=u;for(t=Y.createCallback(t,e,3);o--&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n?n[u-1]:h;return s(n,Re(0,u-r))},Y.sample=function(n,t,e){var r=n?n.length:0;return typeof r!="number"&&(n=jt(n)),null==t||e?n?n[Jt(r-1)]:h:(n=Bt(n),n.length=Ae(Re(0,t),n.length),n)},Y.take=Tt,Y.head=Tt,y(Y,function(n,t){var e="sample"!==t;Y.prototype[t]||(Y.prototype[t]=function(t,r){var u=this.__chain__,o=n(this.__wrapped__,t,r);return u||null!=t&&(!r||e&&typeof t=="function")?new nt(o,u):o +})}),Y.VERSION="2.2.1",Y.prototype.chain=function(){return this.__chain__=!0,this},Y.prototype.toString=function(){return oe(this.__wrapped__)},Y.prototype.value=Qt,Y.prototype.valueOf=Qt,It(["join","pop","shift"],function(n){var t=ie[n];Y.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new nt(e,n):e}}),It(["push","reverse","sort","unshift"],function(n){var t=ie[n];Y.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),It(["concat","slice","splice"],function(n){var t=ie[n]; +Y.prototype[n]=function(){return new nt(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Y}var h,g=[],y=[],m=0,_=+new Date+"",b=75,d=40,w=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",j=/\b__p\+='';/g,k=/\b(__p\+=)''\+/g,x=/(__e\(.*?\)|\b__t\))\+'';/g,C=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,O=/\w*$/,I=/^function[ \n\r\t]+\w/,N=/<%=([\s\S]+?)%>/g,E=RegExp("^["+w+"]*0+(?=.$)"),S=/($^)/,R=/\bthis\b/,A=/['\n\r\t\u2028\u2029\\]/g,D="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),B="[object Arguments]",$="[object Array]",F="[object Boolean]",T="[object Date]",W="[object Function]",q="[object Number]",z="[object Object]",P="[object RegExp]",K="[object String]",L={}; L[W]=!1,L[B]=L[$]=L[F]=L[T]=L[q]=L[z]=L[P]=L[K]=!0;var M={leading:!1,maxWait:0,trailing:!1},U={configurable:!1,enumerable:!1,value:null,writable:!1},V={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},G={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},H=V[typeof window]&&window||this,J=V[typeof exports]&&exports&&!exports.nodeType&&exports,Q=V[typeof module]&&module&&!module.nodeType&&module,X=Q&&Q.exports===J&&J,Y=V[typeof global]&&global;!Y||Y.global!==Y&&Y.window!==Y||(H=Y); var Z=v();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(H._=Z, define(function(){return Z})):J&&Q?X?(Q.exports=Z)._=Z:J._=Z:H._=Z}).call(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index cb6a2bf91a..950c73f373 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -1,6 +1,6 @@ /** * @license - * Lo-Dash 2.2.0 (Custom Build) + * Lo-Dash 2.2.1 (Custom Build) * Build: `lodash underscore exports="amd,commonjs,global,node" -o ./dist/lodash.underscore.js` * Copyright 2012-2013 The Dojo Foundation * Based on Underscore.js 1.5.2 @@ -206,8 +206,8 @@ /*--------------------------------------------------------------------------*/ /** - * Creates a `lodash` object which wraps the given value to enable method - * chaining. + * Creates a `lodash` object which wraps the given value to enable intuitive + * method chaining. * * In addition to Lo-Dash methods, wrappers also have the following `Array` methods: * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`, @@ -241,6 +241,8 @@ * The wrapper functions `first` and `last` return wrapped values when `n` is * provided, otherwise they return unwrapped values. * + * Explicit chaining can be enabled by using the `_.chain` method. + * * @name _ * @constructor * @category Chaining @@ -4146,11 +4148,9 @@ push.apply(args, arguments); var result = func.apply(lodash, args); - if (this.__chain__) { - result = new lodashWrapper(result); - result.__chain__ = true; - } - return result; + return this.__chain__ + ? new lodashWrapper(result, true) + : result; }; }); } @@ -4467,7 +4467,8 @@ /*--------------------------------------------------------------------------*/ /** - * Creates a `lodash` object that wraps the given value. + * Creates a `lodash` object that wraps the given value with explicit + * method chaining enabled. * * @static * @memberOf _ @@ -4483,9 +4484,10 @@ * ]; * * var youngest = _.chain(stooges) - * .sortBy(function(stooge) { return stooge.age; }) + * .sortBy('age') * .map(function(stooge) { return stooge.name + ' is ' + stooge.age; }) - * .first(); + * .first() + * .value(); * // => 'moe is 40' */ function chain(value) { @@ -4522,7 +4524,7 @@ } /** - * Enables method chaining on the wrapper object. + * Enables explicit method chaining on the wrapper object. * * @name chain * @memberOf _ @@ -4530,11 +4532,21 @@ * @returns {*} Returns the wrapper object. * @example * - * var sum = _([1, 2, 3]) - * .chain() - * .reduce(function(sum, num) { return sum + num; }) - * .value() - * // => 6` + * var stooges = [ + * { 'name': 'moe', 'age': 40 }, + * { 'name': 'larry', 'age': 50 } + * ]; + * + * // without explicit chaining + * _(stooges).first(); + * // => { 'name': 'moe', 'age': 40 } + * + * // with explicit chaining + * _(stooges).chain() + * .first() + * .pick('age') + * .value() + * // => { 'age': 40 } */ function wrapperChain() { this.__chain__ = true; @@ -4696,7 +4708,7 @@ * @memberOf _ * @type string */ - lodash.VERSION = '2.2.0'; + lodash.VERSION = '2.2.1'; // add "Chaining" functions to the wrapper lodash.prototype.chain = wrapperChain; diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index 25284789ac..3c3a4c3cd2 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -1,6 +1,6 @@ /** * @license - * Lo-Dash 2.2.0 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE + * Lo-Dash 2.2.1 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE * Build: `lodash underscore exports="amd,commonjs,global,node" -o ./dist/lodash.underscore.js` */ ;(function(){function n(n,r,t){t=(t||0)-1;for(var e=n?n.length:0;++te||typeof t=="undefined")return 1;if(targuments.length;r=i var u=n?n.length:0;if(typeof u=="number")for(;++tt(u,i)&&o.push(i)}return o}function P(n,r,t){var e=0,u=n?n.length:0;if(typeof r!="number"&&null!=r){var o=-1;for(r=K(r,t,3);++oe?$r(0,u+e):e||0}else if(e)return e=G(r,t),r[e]===t?e:-1;return n(r,t,e)}function V(n,r,t){if(typeof r!="number"&&null!=r){var e=0,u=-1,o=n?n.length:0;for(r=K(r,t,3);++u>>1,t(n[e])/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},kr||(s=function(n){if(x(n)){e.prototype=n;var r=new e;e.prototype=null}return r||{}}),y(arguments)||(y=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Ar.call(n,"callee")||!1});var Vr=Fr||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Br.call(n)==ir||!1 @@ -34,5 +34,5 @@ o in n&&(u[o]=n[o])}return u},u.pluck=D,u.range=function(n,r,t){n=+n||0,t=+t||1, },u.isNumber=E,u.isObject=x,u.isRegExp=function(n){return n&&hr[typeof n]?Br.call(n)==pr:!1},u.isString=T,u.isUndefined=function(n){return typeof n=="undefined"},u.lastIndexOf=function(n,r,t){var e=n?n.length:0;for(typeof t=="number"&&(e=(0>t?$r(0,e+t):Ir(t,e-1))+1);e--;)if(n[e]===r)return e;return-1},u.mixin=X,u.noConflict=function(){return gr._=jr,this},u.random=Y,u.reduce=M,u.reduceRight=$,u.result=function(n,r){if(n){var t=n[r];return j(t)?n[r]():t}},u.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:Hr(n).length },u.some=W,u.sortedIndex=G,u.template=function(n,r,e){var o=u,i=o.templateSettings;n||(n=""),e=_({},e,i);var f=0,a="__p+='",i=e.variable;n.replace(RegExp((e.escape||er).source+"|"+(e.interpolate||er).source+"|"+(e.evaluate||er).source+"|$","g"),function(r,e,u,o,i){return a+=n.slice(f,i).replace(ur,t),e&&(a+="'+_.escape("+e+")+'"),o&&(a+="';"+o+";__p+='"),u&&(a+="'+((__t=("+u+"))==null?'':__t)+'"),f=i+r.length,r}),a+="';\n",i||(i="obj",a="with("+i+"||{}){"+a+"}"),a="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+a+"return __p}"; try{var l=Function("_","return "+a)(o)}catch(c){throw c.source=a,c}return r?l(r):(l.source=a,l)},u.unescape=function(n){return null==n?"":(n+"").replace(Lr,g)},u.uniqueId=function(n){var r=++nr+"";return n?n+r:r},u.all=S,u.any=W,u.detect=N,u.findWhere=function(n,r){return z(n,r,!0)},u.foldl=M,u.foldr=$,u.include=O,u.inject=M,u.first=P,u.last=function(n,r,t){var e=0,u=n?n.length:0;if(typeof r!="number"&&null!=r){var o=u;for(r=K(r,t,3);o--&&r(n[o],o,n);)e++}else if(e=r,null==e||t)return n?n[u-1]:Z; -return zr.call(n,$r(0,u-e))},u.sample=function(n,r,t){var e=n?n.length:0;return typeof e!="number"&&(n=A(n)),null==r||t?n?n[Y(e-1)]:Z:(n=I(n),n.length=Ir($r(0,r),n.length),n)},u.take=P,u.head=P,X(u),u.VERSION="2.2.0",u.prototype.chain=function(){return this.__chain__=!0,this},u.prototype.value=function(){return this.__wrapped__},R("pop push reverse shift sort splice unshift".split(" "),function(n){var r=br[n];u.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),Ur.spliceObjects||0!==n.length||delete n[0],this +return zr.call(n,$r(0,u-e))},u.sample=function(n,r,t){var e=n?n.length:0;return typeof e!="number"&&(n=A(n)),null==r||t?n?n[Y(e-1)]:Z:(n=I(n),n.length=Ir($r(0,r),n.length),n)},u.take=P,u.head=P,X(u),u.VERSION="2.2.1",u.prototype.chain=function(){return this.__chain__=!0,this},u.prototype.value=function(){return this.__wrapped__},R("pop push reverse shift sort splice unshift".split(" "),function(n){var r=br[n];u.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),Ur.spliceObjects||0!==n.length||delete n[0],this }}),R(["concat","join","slice"],function(n){var r=br[n];u.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=!0),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(gr._=u, define(function(){return u})):yr&&mr?_r?(mr.exports=u)._=u:yr._=u:gr._=u}).call(this); \ No newline at end of file diff --git a/doc/README.md b/doc/README.md index 1a52f5891a..62363df959 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,4 +1,4 @@ -# Lo-Dash v2.2.0 +# Lo-Dash v2.2.1 @@ -233,7 +233,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4186 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4188 "View in source") [Ⓣ][1] Creates an array with all falsey values removed. The values `false`, `null`, `0`, `""`, `undefined`, and `NaN` are all falsey. @@ -257,7 +257,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array, [array])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4215 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4217 "View in source") [Ⓣ][1] Creates an array excluding all values of the provided arrays using strict equality for comparisons, i.e. `===`. @@ -282,7 +282,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.findIndex(array, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4265 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4267 "View in source") [Ⓣ][1] This method is like `_.find` except that it returns the index of the first element that passes the callback check, instead of the element itself. @@ -310,7 +310,7 @@ _.findIndex(['apple', 'banana', 'beet'], function(food) { ### `_.findLastIndex(array, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4298 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4300 "View in source") [Ⓣ][1] This method is like `_.findIndex` except that it iterates over elements of a `collection` from right to left. @@ -338,7 +338,7 @@ _.findLastIndex(['apple', 'banana', 'beet'], function(food) { ### `_.first(array, [callback], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4365 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4367 "View in source") [Ⓣ][1] Gets the first element or first `n` elements of an array. If a callback is provided elements at the beginning of the array are returned as long as the callback returns truey. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -398,7 +398,7 @@ _.first(food, { 'type': 'fruit' }); ### `_.flatten(array, [isShallow=false], [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4425 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4427 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `isShallow` is truey, the array will only be flattened a single level. If a callback is provided each element of the array is passed through the callback before flattening. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -441,7 +441,7 @@ _.flatten(stooges, 'quotes'); ### `_.indexOf(array, value, [fromIndex=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4462 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4464 "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 providing `true` for `fromIndex` will run a faster binary search. @@ -473,7 +473,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array, [callback=1], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4528 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4530 "View in source") [Ⓣ][1] Gets all but the last element or last `n` elements of an array. If a callback is provided elements at the end of the array are excluded from the result as long as the callback returns truey. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -530,7 +530,7 @@ _.initial(food, { 'type': 'vegetable' }); ### `_.intersection([array])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4558 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4560 "View in source") [Ⓣ][1] Creates an array of unique values present in all provided arrays using strict equality for comparisons, i.e. `===`. @@ -554,7 +554,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array, [callback], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4658 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4660 "View in source") [Ⓣ][1] Gets the last element or last `n` elements of an array. If a callback is provided elements at the end of the array are returned as long as the callback returns truey. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -611,7 +611,7 @@ _.last(food, { 'type': 'vegetable' }); ### `_.lastIndexOf(array, value, [fromIndex=array.length-1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4697 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4699 "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. @@ -640,7 +640,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.pull(array, [value])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4727 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4729 "View in source") [Ⓣ][1] Removes all provided values from the given array using strict equality for comparisons, i.e. `===`. @@ -667,7 +667,7 @@ console.log(array); ### `_.range([start=0], end, [step=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4778 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4780 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. If `start` is less than `stop` a zero-length range is created unless a negative `step` is specified. @@ -708,7 +708,7 @@ _.range(0); ### `_.remove(array, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4831 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4833 "View in source") [Ⓣ][1] Removes all elements from an array that the callback returns truey for and returns an array of removed elements. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -744,7 +744,7 @@ console.log(evens); ### `_.rest(array, [callback=1], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4905 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4907 "View in source") [Ⓣ][1] The opposite of `_.initial` this method gets all but the first element or first `n` elements of an array. If a callback function is provided elements at the beginning of the array are excluded from the result as long as the callback returns truey. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -804,7 +804,7 @@ _.rest(food, { 'type': 'fruit' }); ### `_.sortedIndex(array, value, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4969 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4971 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which a value should be inserted into a given sorted array in order to maintain the sort order of the array. If a callback is provided it will be executed for `value` and each element of `array` to compute their sort ranking. The callback is bound to `thisArg` and invoked with one argument; *(value)*. @@ -853,7 +853,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5000 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5002 "View in source") [Ⓣ][1] Creates an array of unique values, in order, of the provided arrays using strict equality for comparisons, i.e. `===`. @@ -877,7 +877,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array, [isSorted=false], [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5048 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5050 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of an array using strict equality for comparisons, i.e. `===`. If the array is sorted, providing `true` for `isSorted` will use a faster algorithm. If a callback is provided each element of `array` is passed through the callback before uniqueness is computed. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -924,7 +924,7 @@ _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); ### `_.without(array, [value])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5076 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5078 "View in source") [Ⓣ][1] Creates an array excluding all provided values using strict equality for comparisons, i.e. `===`. @@ -949,7 +949,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5096 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5098 "View in source") [Ⓣ][1] Creates an array of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. @@ -976,7 +976,7 @@ _.zip(['moe', 'larry'], [30, 40], [true, false]); ### `_.zipObject(keys, [values=[]])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5126 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5128 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Provide either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]` or two arrays, one of `keys` and one of corresponding `values`. @@ -1011,9 +1011,9 @@ _.zipObject(['moe', 'larry'], [30, 40]); ### `_(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L650 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L652 "View in source") [Ⓣ][1] -Creates a `lodash` object which wraps the given value to enable method chaining. +Creates a `lodash` object which wraps the given value to enable intuitive method chaining. In addition to Lo-Dash methods, wrappers also have the following `Array` methods:
`concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`, and `unshift` @@ -1028,6 +1028,8 @@ The non-chainable wrapper functions are:
The wrapper functions `first` and `last` return wrapped values when `n` is provided, otherwise they return unwrapped values. +Explicit chaining can be enabled by using the `_.chain` method. + #### Arguments 1. `value` *(\*)*: The value to wrap in a `lodash` instance. @@ -1064,9 +1066,9 @@ _.isArray(squares.value()); ### `_.chain(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6344 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L6351 "View in source") [Ⓣ][1] -Creates a `lodash` object that wraps the given value. +Creates a `lodash` object that wraps the given value with explicit method chaining enabled. #### Arguments 1. `value` *(\*)*: The value to wrap. @@ -1083,9 +1085,10 @@ var stooges = [ ]; var youngest = _.chain(stooges) - .sortBy(function(stooge) { return stooge.age; }) + .sortBy('age') .map(function(stooge) { return stooge.name + ' is ' + stooge.age; }) - .first(); + .first() + .value(); // => 'moe is 40' ``` @@ -1097,7 +1100,7 @@ var youngest = _.chain(stooges) ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6372 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L6379 "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. @@ -1127,20 +1130,30 @@ _([1, 2, 3, 4]) ### `_.prototype.chain()` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6392 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L6409 "View in source") [Ⓣ][1] -Enables method chaining on the wrapper object. +Enables explicit method chaining on the wrapper object. #### Returns *(\*)*: Returns the wrapper object. #### Example ```js -var sum = _([1, 2, 3]) - .chain() - .reduce(function(sum, num) { return sum + num; }) - .value() -// => 6` +var stooges = [ + { 'name': 'moe', 'age': 40 }, + { 'name': 'larry', 'age': 50 } +]; + +// without explicit chaining +_(stooges).first(); +// => { 'name': 'moe', 'age': 40 } + +// with explicit chaining +_(stooges).chain() + .first() + .pick('age') + .value() +// => { 'age': 40 } ``` * * * @@ -1151,7 +1164,7 @@ var sum = _([1, 2, 3]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6409 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L6426 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -1172,7 +1185,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6426 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L6443 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -1203,7 +1216,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection, [index])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3040 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3042 "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. @@ -1231,7 +1244,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target, [fromIndex=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3083 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3085 "View in source") [Ⓣ][1] Checks if a given value 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. @@ -1269,7 +1282,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3138 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3140 "View in source") [Ⓣ][1] Creates an object composed of keys generated from the results of running each element of `collection` through the 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)*. @@ -1305,7 +1318,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3183 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3185 "View in source") [Ⓣ][1] Checks if the given callback returns truey value for **all** elements of a collection. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1351,7 +1364,7 @@ _.every(stooges, { 'age': 50 }); ### `_.filter(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3244 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3246 "View in source") [Ⓣ][1] Iterates over elements of a collection, returning an array of all elements the callback returns truey for. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1397,7 +1410,7 @@ _.filter(food, { 'type': 'fruit' }); ### `_.find(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3311 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3313 "View in source") [Ⓣ][1] Iterates over elements of a collection, returning the first element that the callback returns truey for. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1446,7 +1459,7 @@ _.find(food, 'organic'); ### `_.findLast(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3356 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3358 "View in source") [Ⓣ][1] This method is like `_.find` except that it iterates over elements of a `collection` from right to left. @@ -1474,7 +1487,7 @@ _.findLast([1, 2, 3, 4], function(num) { ### `_.forEach(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3390 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3392 "View in source") [Ⓣ][1] Iterates over elements of a collection, executing the callback for each element. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1506,7 +1519,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); ### `_.forEachRight(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3423 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3425 "View in source") [Ⓣ][1] This method is like `_.forEach` except that it iterates over elements of a `collection` from right to left. @@ -1535,7 +1548,7 @@ _([1, 2, 3]).forEachRight(function(num) { console.log(num); }).join(','); ### `_.groupBy(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3484 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3486 "View in source") [Ⓣ][1] Creates an object composed of keys generated from the results of running each element of a collection through the callback. The corresponding value of each key is an array of the elements responsible for generating the key. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1572,7 +1585,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.indexBy(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3527 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3529 "View in source") [Ⓣ][1] Creates an object composed of keys generated from the results of running each element of the collection through the given callback. The corresponding value of each key is the last element responsible for generating the key. The callback is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1613,7 +1626,7 @@ _.indexBy(stooges, function(key) { this.fromCharCode(key.code); }, String); ### `_.invoke(collection, methodName, [arg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3553 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3555 "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 provided to each invoked method. If `methodName` is a function it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1642,7 +1655,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3605 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3607 "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)*. @@ -1687,7 +1700,7 @@ _.map(stooges, 'name'); ### `_.max(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3663 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3665 "View in source") [Ⓣ][1] Retrieves the maximum value of a collection. If the collection is empty or falsey `-Infinity` is returned. If a callback is provided it will be executed for each value in the collection to generate the criterion by which the value is ranked. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1729,7 +1742,7 @@ _.max(stooges, 'age'); ### `_.min(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3733 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3735 "View in source") [Ⓣ][1] Retrieves the minimum value of a collection. If the collection is empty or falsey `Infinity` is returned. If a callback is provided it will be executed for each value in the collection to generate the criterion by which the value is ranked. The callback is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1771,7 +1784,7 @@ _.min(stooges, 'age'); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3783 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3785 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1801,7 +1814,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection, [callback=identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3815 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3817 "View in source") [Ⓣ][1] Reduces a collection to a value which 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 provided 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)*. @@ -1839,7 +1852,7 @@ var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { ### `_.reduceRight(collection, [callback=identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3858 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3860 "View in source") [Ⓣ][1] This method is like `_.reduce` except that it iterates over elements of a `collection` from right to left. @@ -1870,7 +1883,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3907 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3909 "View in source") [Ⓣ][1] The opposite of `_.filter` this method returns the elements of a collection that the callback does **not** return truey for. @@ -1913,7 +1926,7 @@ _.reject(food, { 'type': 'fruit' }); ### `_.sample(collection, [n])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3933 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3935 "View in source") [Ⓣ][1] Retrieves a random element or `n` random elements from a collection. @@ -1941,7 +1954,7 @@ _.sample([1, 2, 3, 4], 2); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3962 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3964 "View in source") [Ⓣ][1] Creates an array of shuffled values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1965,7 +1978,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3995 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3997 "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. @@ -1995,7 +2008,7 @@ _.size('curly'); ### `_.some(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4042 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4044 "View in source") [Ⓣ][1] Checks if the callback returns a truey value for **any** element of a collection. The function returns as soon as it finds a 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)*. @@ -2041,7 +2054,7 @@ _.some(food, { 'type': 'meat' }); ### `_.sortBy(collection, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4098 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4100 "View in source") [Ⓣ][1] Creates an array of elements, sorted in ascending order by the results of running each element in a 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)*. @@ -2078,7 +2091,7 @@ _.sortBy(['banana', 'strawberry', 'apple'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4134 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4136 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -2102,7 +2115,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L4168 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L4170 "View in source") [Ⓣ][1] Performs a deep comparison of each element in a `collection` to the given `properties` object, returning an array of all elements that have equivalent property values. @@ -2142,7 +2155,7 @@ _.where(stooges, { 'quotes': ['Poifect!'] }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5168 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5170 "View in source") [Ⓣ][1] Creates a function that executes `func`, with the `this` binding and arguments of the created function, only after being called `n` times. @@ -2175,7 +2188,7 @@ _.forEach(saves, function(type) { ### `_.bind(func, [thisArg], [arg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5201 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5203 "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 provided to the bound function. @@ -2206,7 +2219,7 @@ func(); ### `_.bindAll(object, [methodName])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5231 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5233 "View in source") [Ⓣ][1] Binds methods of an object to the object itself, 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. @@ -2237,7 +2250,7 @@ jQuery('#docs').on('click', view.onClick); ### `_.bindKey(object, key, [arg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5277 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5279 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those provided 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. @@ -2278,7 +2291,7 @@ func(); ### `_.compose([func])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5313 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5315 "View in source") [Ⓣ][1] Creates a function that is the composition of the provided 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. @@ -2316,7 +2329,7 @@ welcome('curly'); ### `_.createCallback([func=identity], [thisArg], [argCount])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5364 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5366 "View in source") [Ⓣ][1] Produces a callback bound to an optional `thisArg`. If `func` is a property name the created callback will return the property value for a given element. If `func` is an object the created callback will return `true` for elements that contain the equivalent object properties, otherwise it will return `false`. @@ -2355,7 +2368,7 @@ _.filter(stooges, 'age__gt45'); ### `_.curry(func, [arity=func.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5429 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5431 "View in source") [Ⓣ][1] Creates a function which accepts one or more arguments of `func` that when invoked either executes `func` returning its result, if all `func` arguments have been provided, or returns a function that accepts one or more of the remaining `func` arguments, and so on. The arity of `func` can be specified if `func.length` is not sufficient. @@ -2390,7 +2403,7 @@ curried(1, 2, 3); ### `_.debounce(func, wait, [options], [options.maxWait])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5473 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5475 "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. Provide an options object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -2434,7 +2447,7 @@ source.addEventListener('message', _.debounce(batchLog, 250, { ### `_.defer(func, [arg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5574 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5576 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be provided to `func` when it is invoked. @@ -2459,7 +2472,7 @@ _.defer(function() { console.log('deferred'); }); ### `_.delay(func, wait, [arg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5608 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5610 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be provided to `func` when it is invoked. @@ -2486,7 +2499,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func, [resolver])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5650 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5652 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is provided it will be used to determine the cache key for storing the result based on the arguments provided to the memoized function. By default, the first argument provided to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. The result cache is exposed as the `cache` property on the memoized function. @@ -2526,7 +2539,7 @@ stooge('curly'); ### `_.once(func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5683 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5685 "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. @@ -2552,7 +2565,7 @@ initialize(); ### `_.partial(func, [arg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5721 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5723 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those provided to the new function. This method is similar to `_.bind` except it does **not** alter the `this` binding. @@ -2579,7 +2592,7 @@ hi('moe'); ### `_.partialRight(func, [arg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5752 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5754 "View in source") [Ⓣ][1] This method is like `_.partial` except that `partial` arguments are appended to those provided to the new function. @@ -2616,7 +2629,7 @@ options.imports ### `_.throttle(func, wait, [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5787 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5789 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. Provide an options object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -2652,7 +2665,7 @@ jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5829 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5831 "View in source") [Ⓣ][1] Creates a function that provides `value` to the wrapper function as its first argument. Additional arguments provided to the function are appended to those provided to the wrapper function. The wrapper is executed with the `this` binding of the created function. @@ -2688,7 +2701,7 @@ hello(); ### `_.assign(object, [source], [callback], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L1966 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L1968 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the destination object. Subsequent sources will overwrite property assignments of previous sources. If a callback is provided it will be executed to produce the assigned values. The callback is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. @@ -2726,7 +2739,7 @@ defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.clone(value, [deep=false], [callback], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2019 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2021 "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 is provided it will be executed to produce the cloned values. If the callback returns `undefined` cloning will be handled by the method instead. The callback is bound to `thisArg` and invoked with one argument; *(value)*. @@ -2773,7 +2786,7 @@ clone.childNodes.length; ### `_.cloneDeep(value, [callback], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2071 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2073 "View in source") [Ⓣ][1] Creates a deep clone of `value`. If a callback is provided it will be executed to produce the cloned values. If the callback returns `undefined` cloning will be handled by the method instead. The callback is bound to `thisArg` and invoked with one argument; *(value)*. @@ -2819,7 +2832,7 @@ clone.node == view.node; ### `_.defaults(object, [source])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2095 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2097 "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. @@ -2845,7 +2858,7 @@ _.defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.findKey(object, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2117 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2119 "View in source") [Ⓣ][1] This method is like `_.findIndex` except that it returns the key of the first element that passes the callback check, instead of the element itself. @@ -2873,7 +2886,7 @@ _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { ### `_.findLastKey(object, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2149 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2151 "View in source") [Ⓣ][1] This method is like `_.findKey` except that it iterates over elements of a `collection` in the opposite order. @@ -2901,7 +2914,7 @@ _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { ### `_.forIn(object, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2190 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2192 "View in source") [Ⓣ][1] Iterates over own and inherited enumerable properties of an object, 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`. @@ -2937,7 +2950,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forInRight(object, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2220 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2222 "View in source") [Ⓣ][1] This method is like `_.forIn` except that it iterates over elements of a `collection` in the opposite order. @@ -2973,7 +2986,7 @@ _.forInRight(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2258 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2260 "View in source") [Ⓣ][1] Iterates over own enumerable properties of an object, 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`. @@ -3001,7 +3014,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.forOwnRight(object, [callback=identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2278 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2280 "View in source") [Ⓣ][1] This method is like `_.forOwn` except that it iterates over elements of a `collection` in the opposite order. @@ -3029,7 +3042,7 @@ _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2307 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2309 "View in source") [Ⓣ][1] Creates a sorted array of property names of all enumerable properties, own and inherited, of `object` that have function values. @@ -3056,7 +3069,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2332 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2334 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -3081,7 +3094,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2349 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2351 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given object. @@ -3105,7 +3118,7 @@ _.invert({ 'first': 'moe', 'second': 'larry' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L1791 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L1793 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -3132,7 +3145,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L1820 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L1822 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -3159,7 +3172,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2375 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2377 "View in source") [Ⓣ][1] Checks if `value` is a boolean value. @@ -3183,7 +3196,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2392 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2394 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -3207,7 +3220,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2409 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2411 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -3231,7 +3244,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2434 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2436 "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". @@ -3261,7 +3274,7 @@ _.isEmpty(''); ### `_.isEqual(a, b, [callback], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2491 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2493 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. If a callback is provided it will be executed to compare values. If the callback returns `undefined` comparisons will be handled by the method instead. The callback is bound to `thisArg` and invoked with two arguments; *(a, b)*. @@ -3306,7 +3319,7 @@ _.isEqual(words, otherWords, function(a, b) { ### `_.isFinite(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2523 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2525 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -3344,7 +3357,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2540 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2542 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -3368,7 +3381,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2603 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2605 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -3403,7 +3416,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2625 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2627 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -3430,7 +3443,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2644 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2646 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -3456,7 +3469,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2570 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2572 "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('')`)* @@ -3486,7 +3499,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2672 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2674 "View in source") [Ⓣ][1] Checks if `value` is an object created by the `Object` constructor. @@ -3521,7 +3534,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2697 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2699 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -3545,7 +3558,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2714 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2716 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -3569,7 +3582,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2731 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2733 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -3593,7 +3606,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L1854 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L1856 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of an object. @@ -3617,7 +3630,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object, [source], [callback], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2786 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2788 "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 property assignments of previous sources. If a callback is provided it will be executed to produce the merged values of the destination and source properties. If the callback returns `undefined` merging will be handled by the method instead. The callback is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. @@ -3673,7 +3686,7 @@ _.merge(food, otherFood, function(a, b) { ### `_.omit(object, [callback], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2842 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2844 "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 is provided it will be executed for each property of `object` omitting the properties the callback returns truey for. The callback is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -3704,7 +3717,7 @@ _.omit({ 'name': 'moe', 'age': 40 }, function(value) { ### `_.pairs(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2877 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2879 "View in source") [Ⓣ][1] Creates a two dimensional array of an object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -3728,7 +3741,7 @@ _.pairs({ 'moe': 30, 'larry': 40 }); ### `_.pick(object, [callback], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2917 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2919 "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 a callback is provided it will be executed for each property of `object` picking the properties the callback returns truey for. The callback is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -3759,7 +3772,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.transform(collection, [callback=identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L2972 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L2974 "View in source") [Ⓣ][1] An alternative to `_.reduce` this method transforms `object` to a new `accumulator` object which is the result of running each of its elements through a callback, with each callback execution potentially mutating the `accumulator` object. The callback is bound to `thisArg` and invoked with four arguments; *(accumulator, value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -3796,7 +3809,7 @@ var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) ### `_.values(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L3005 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L3007 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -3827,7 +3840,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5856 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5858 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -3851,7 +3864,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5874 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5876 "View in source") [Ⓣ][1] This method returns the first argument provided to it. @@ -3876,7 +3889,7 @@ moe === _.identity(moe); ### `_.mixin(object, object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5901 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5903 "View in source") [Ⓣ][1] Adds function properties of a source object to the `lodash` function and chainable wrapper. @@ -3907,7 +3920,7 @@ _('moe').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5939 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5944 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -3927,7 +3940,7 @@ var lodash = _.noConflict(); ### `_.parseInt(value, [radix])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5963 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L5968 "View in source") [Ⓣ][1] Converts the given value into an integer of the specified radix. If `radix` is `undefined` or `0` a `radix` of `10` is used unless the `value` is a hexadecimal, in which case a `radix` of `16` is used. @@ -3954,7 +3967,7 @@ _.parseInt('08'); ### `_.random([min=0], [max=1], [floating=false])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L5995 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L6000 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is provided a number between `0` and the given number will be returned. If `floating` is truey or either `min` or `max` are floats a floating-point number will be returned instead of an integer. @@ -3989,7 +4002,7 @@ _.random(1.2, 5.2); ### `_.result(object, property)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6052 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L6057 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked with the `this` binding of `object` and its result returned, else the property value is returned. If `object` is falsey then `undefined` is returned. @@ -4024,7 +4037,7 @@ _.result(object, 'stuff'); ### `_.runInContext([context=root])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L471 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L471 "View in source") [Ⓣ][1] Create a new `lodash` function using the given context object. @@ -4042,7 +4055,7 @@ Create a new `lodash` function using the given context object. ### `_.template(text, data, [options], [options.escape], [options.evaluate], [options.imports], [options.interpolate], [sourceURL], [variable])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6145 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L6150 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -4136,7 +4149,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback, [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6268 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L6273 "View in source") [Ⓣ][1] Executes the callback `n` times, returning an array of the results of each callback execution. The callback is bound to `thisArg` and invoked with one argument; *(index)*. @@ -4168,7 +4181,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6295 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L6300 "View in source") [Ⓣ][1] The inverse of `_.escape` this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -4192,7 +4205,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6315 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L6320 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is provided the ID will be appended to it. @@ -4226,7 +4239,7 @@ _.uniqueId(); ### `_.templateSettings.imports._` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L878 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L880 "View in source") [Ⓣ][1] A reference to the `lodash` function. @@ -4245,7 +4258,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6624 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L6641 "View in source") [Ⓣ][1] *(string)*: The semantic version number. @@ -4257,7 +4270,7 @@ A reference to the `lodash` function. ### `_.support` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L679 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L681 "View in source") [Ⓣ][1] *(Object)*: An object used to flag environments features. @@ -4269,7 +4282,7 @@ A reference to the `lodash` function. ### `_.support.argsClass` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L696 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L698 "View in source") [Ⓣ][1] *(boolean)*: Detect if an `arguments` object's [[Class]] is resolvable *(all but Firefox < `4`, IE < `9`)*. @@ -4281,7 +4294,7 @@ A reference to the `lodash` function. ### `_.support.argsObject` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L704 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L706 "View in source") [Ⓣ][1] *(boolean)*: Detect if `arguments` objects are `Object` objects *(all but Narwhal and Opera < `10.5`)*. @@ -4293,7 +4306,7 @@ A reference to the `lodash` function. ### `_.support.enumErrorProps` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L713 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L715 "View in source") [Ⓣ][1] *(boolean)*: Detect if `name` or `message` properties of `Error.prototype` are enumerable by default. *(IE < `9`, Safari < `5.1`)* @@ -4305,7 +4318,7 @@ A reference to the `lodash` function. ### `_.support.enumPrototypes` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L726 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L728 "View in source") [Ⓣ][1] *(boolean)*: Detect if `prototype` properties are enumerable by default. @@ -4319,7 +4332,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p ### `_.support.fastBind` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L734 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L736 "View in source") [Ⓣ][1] *(boolean)*: Detect if `Function#bind` exists and is inferred to be fast *(all but V8)*. @@ -4331,7 +4344,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p ### `_.support.funcDecomp` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L743 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L745 "View in source") [Ⓣ][1] *(boolean)*: Detect if functions can be decompiled by `Function#toString` *(all but PS3 and older Opera mobile browsers & avoided in Windows `8` apps)*. @@ -4343,7 +4356,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p ### `_.support.funcNames` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L751 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L753 "View in source") [Ⓣ][1] *(boolean)*: Detect if `Function#name` is supported *(all but IE)*. @@ -4355,7 +4368,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p ### `_.support.nonEnumArgs` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L760 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L762 "View in source") [Ⓣ][1] *(boolean)*: Detect if `arguments` object indexes are non-enumerable *(Firefox < `4`, IE < `9`, PhantomJS, Safari < `5.1`)*. @@ -4367,7 +4380,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p ### `_.support.nonEnumShadows` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L771 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L773 "View in source") [Ⓣ][1] *(boolean)*: Detect if properties shadowing those on `Object.prototype` are non-enumerable. @@ -4381,7 +4394,7 @@ In IE < `9` an objects own properties, shadowing non-enumerable ones, are made n ### `_.support.ownLast` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L779 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L781 "View in source") [Ⓣ][1] *(boolean)*: Detect if own properties are iterated after inherited properties *(all but IE < `9`)*. @@ -4393,7 +4406,7 @@ In IE < `9` an objects own properties, shadowing non-enumerable ones, are made n ### `_.support.spliceObjects` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L793 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L795 "View in source") [Ⓣ][1] *(boolean)*: Detect if `Array#shift` and `Array#splice` augment array-like objects correctly. @@ -4407,7 +4420,7 @@ Firefox < `10`, IE compatibility mode, and IE < `9` have buggy Array `shift()` a ### `_.support.unindexedChars` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L804 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L806 "View in source") [Ⓣ][1] *(boolean)*: Detect lack of support for accessing string characters by index. @@ -4421,7 +4434,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L830 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L832 "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. @@ -4433,7 +4446,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L838 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L840 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to be HTML-escaped. @@ -4445,7 +4458,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L846 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L848 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect code to be evaluated. @@ -4457,7 +4470,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L854 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L856 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to inject. @@ -4469,7 +4482,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L862 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L864 "View in source") [Ⓣ][1] *(string)*: Used to reference the data object in the template text. @@ -4481,7 +4494,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.imports` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L870 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/2.2.1/lodash.js#L872 "View in source") [Ⓣ][1] *(Object)*: Used to import variables into the compiled template. @@ -4496,4 +4509,4 @@ IE < `8` can't access characters by index and IE `8` can only access characters - [1]: #Arrays "Jump back to the TOC." \ No newline at end of file + [1]: #Arrays "Jump back to the TOC." diff --git a/doc/parse.php b/doc/parse.php index 66f4554236..1dad09d1a9 100644 --- a/doc/parse.php +++ b/doc/parse.php @@ -1,36 +1,38 @@ version; + // generate Markdown $markdown = docdown(array( - 'path' => '../' . $file, - 'title' => 'Lo-Dash v2.2.0', + 'path' => '../' . $filePath, + 'title' => 'Lo-Dash v' . $version . '', 'toc' => 'categories', - 'url' => 'https://github.com/lodash/lodash/blob/master/lodash.js' + 'url' => 'https://github.com/lodash/lodash/blob/' . $version . '/lodash.js' )); - // save to a .md file - file_put_contents($output . '.md', $markdown); + // save to a `.md` file + file_put_contents($outputName . '.md', $markdown); // print header('Content-Type: text/plain;charset=utf-8'); echo $markdown . PHP_EOL; - -?> \ No newline at end of file +?> diff --git a/lodash.js b/lodash.js index af31f64a57..71bb2c452f 100644 --- a/lodash.js +++ b/lodash.js @@ -1,6 +1,6 @@ /** * @license - * Lo-Dash 2.2.0 + * Lo-Dash 2.2.1 * Copyright 2012-2013 The Dojo Foundation * Based on Underscore.js 1.5.2 * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors @@ -586,8 +586,8 @@ /*--------------------------------------------------------------------------*/ /** - * Creates a `lodash` object which wraps the given value to enable method - * chaining. + * Creates a `lodash` object which wraps the given value to enable intuitive + * method chaining. * * In addition to Lo-Dash methods, wrappers also have the following `Array` methods: * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`, @@ -621,6 +621,8 @@ * The wrapper functions `first` and `last` return wrapped values when `n` is * provided, otherwise they return unwrapped values. * + * Explicit chaining can be enabled by using the `_.chain` method. + * * @name _ * @constructor * @category Chaining @@ -5916,9 +5918,12 @@ push.apply(args, arguments); var result = func.apply(object, args); - return (value && typeof value == 'object' && value === result) - ? this - : new ctor(result); + if (value && typeof value == 'object' && value === result) { + return this; + } + result = new ctor(result); + result.__chain__ = this.__chain__; + return result; }; } }); @@ -6320,7 +6325,8 @@ /*--------------------------------------------------------------------------*/ /** - * Creates a `lodash` object that wraps the given value. + * Creates a `lodash` object that wraps the given value with explicit + * method chaining enabled. * * @static * @memberOf _ @@ -6336,9 +6342,10 @@ * ]; * * var youngest = _.chain(stooges) - * .sortBy(function(stooge) { return stooge.age; }) + * .sortBy('age') * .map(function(stooge) { return stooge.name + ' is ' + stooge.age; }) - * .first(); + * .first() + * .value(); * // => 'moe is 40' */ function chain(value) { @@ -6375,7 +6382,7 @@ } /** - * Enables method chaining on the wrapper object. + * Enables explicit method chaining on the wrapper object. * * @name chain * @memberOf _ @@ -6383,11 +6390,21 @@ * @returns {*} Returns the wrapper object. * @example * - * var sum = _([1, 2, 3]) - * .chain() - * .reduce(function(sum, num) { return sum + num; }) - * .value() - * // => 6` + * var stooges = [ + * { 'name': 'moe', 'age': 40 }, + * { 'name': 'larry', 'age': 50 } + * ]; + * + * // without explicit chaining + * _(stooges).first(); + * // => { 'name': 'moe', 'age': 40 } + * + * // with explicit chaining + * _(stooges).chain() + * .first() + * .pick('age') + * .value() + * // => { 'age': 40 } */ function wrapperChain() { this.__chain__ = true; @@ -6621,7 +6638,7 @@ * @memberOf _ * @type string */ - lodash.VERSION = '2.2.0'; + lodash.VERSION = '2.2.1'; // add "Chaining" functions to the wrapper lodash.prototype.chain = wrapperChain; diff --git a/package.json b/package.json index 991fbc3d94..637ace8ac2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lodash", - "version": "2.2.0", + "version": "2.2.1", "description": "A utility library delivering consistency, customization, performance, & extras.", "homepage": "http://lodash.com/", "license": "MIT", diff --git a/perf/perf-ui.js b/perf/asset/perf-ui.js similarity index 100% rename from perf/perf-ui.js rename to perf/asset/perf-ui.js diff --git a/test/test-ui.js b/test/asset/test-ui.js similarity index 98% rename from test/test-ui.js rename to test/asset/test-ui.js index 06ff770222..29dd1f9c3f 100644 --- a/test/test-ui.js +++ b/test/asset/test-ui.js @@ -73,7 +73,7 @@ }()); // used to indicate testing a modularized build - ui.isModularize = /\b(?:commonjs|(index|main)\.js|lodash-(?:amd|node)|modularize)\b/.test([location.pathname, location.search, ui.buildPath]); + ui.isModularize = /\b(?:commonjs|(index|main)\.js|lodash-(?:amd|node)|modularize|npm)\b/.test([location.pathname, location.search, ui.buildPath]); // initialize controls addListener(window, 'load', function() { diff --git a/test/worker.js b/test/asset/worker.js similarity index 74% rename from test/worker.js rename to test/asset/worker.js index 521249af8d..75f21c9a58 100644 --- a/test/worker.js +++ b/test/asset/worker.js @@ -1,6 +1,6 @@ addEventListener('message', function(e) { if (e.data) { - importScripts(e.data); + importScripts('../' + e.data); postMessage(_.VERSION); } }, false); diff --git a/test/backbone.html b/test/backbone.html index 67fc71fa88..a4962d73cb 100644 --- a/test/backbone.html +++ b/test/backbone.html @@ -22,7 +22,7 @@

Test

- + diff --git a/test/index.html b/test/index.html index a2453ecb6c..255766ceb9 100644 --- a/test/index.html +++ b/test/index.html @@ -13,7 +13,7 @@ - +
- +