From feac1786e1e0ff0a820110090763d636110c2615 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 11 Nov 2013 18:55:11 -0800 Subject: [PATCH 01/57] Move min tested Node.js version up to match travis-ci to avoid local testing on top of travis-ci. [ci skip] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 854345f794..954c46c9ed 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ A list of upcoming features is available on our [roadmap](https://github.com/lod ## Support -Tested in Chrome 5~30, Firefox 2~25, IE 6-11, Opera 9.25~17, Safari 3-7, Node.js 0.6.8-0.10.21, Narwhal 0.3.2, PhantomJS 1.9.2, RingoJS 0.9, & Rhino 1.7RC5. +Tested in Chrome 5~30, Firefox 2~25, IE 6-11, Opera 9.25~17, Safari 3-7, Node.js 0.6.21~0.10.21, Narwhal 0.3.2, PhantomJS 1.9.2, RingoJS 0.9, & Rhino 1.7RC5. Special thanks to [Sauce Labs](https://saucelabs.com/) for providing automated browser testing.
[![Sauce Labs](http://lodash.com/_img/sauce.png)](https://saucelabs.com/ "Sauce Labs: Selenium Testing & More") From 807d75e13a81bdcc339024f342a110bb6bfe44e8 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 11 Nov 2013 22:07:56 -0800 Subject: [PATCH 02/57] Remove exposing `root._` in the AMD fork of the UMD because Lo-Dash is defined as an anonymous module and the issue it solves isn't applicable to it. --- dist/lodash.compat.js | 6 ------ dist/lodash.compat.min.js | 2 +- dist/lodash.js | 6 ------ dist/lodash.min.js | 34 +++++++++++++++++----------------- dist/lodash.underscore.js | 6 ------ dist/lodash.underscore.min.js | 2 +- lodash.js | 6 ------ 7 files changed, 19 insertions(+), 43 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 957c070c07..5295d60b30 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -6922,12 +6922,6 @@ // some AMD build optimizers like r.js check for condition patterns like the following: if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) { - // Expose Lo-Dash to the global object even when an AMD loader is present in - // case Lo-Dash was injected by a third-party script and not intended to be - // loaded as a module. The global assignment can be reverted in the Lo-Dash - // module by its `noConflict()` method. - root._ = _; - // define as an anonymous module so, through path mapping, it can be // referenced as the "underscore" module define(function() { diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index a1e683e87d..e4a1ec02f5 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -55,4 +55,4 @@ for(t=v.createCallback(t,e,3),Nt(n,function(n,e,u){var o=a[++r]=l();o.m=t(n,e,u) return n?new y(e,n):e}}),Ze(["push","reverse","sort","unshift"],function(n){var t=ce[n];v.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Ze(["concat","slice","splice"],function(n){var t=ce[n];v.prototype[n]=function(){return new y(t.apply(this.__wrapped__,arguments),this.__chain__)}}),qe.spliceObjects||Ze(["pop","shift","splice"],function(n){var t=ce[n],e="splice"==n;v.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 y(u,n):u }}),v}var h,v=[],y=[],m=0,d={},b=+new Date+"",_=75,w=40,j=" \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",x=/\b__p\+='';/g,C=/\b(__p\+=)''\+/g,E=/(__e\(.*?\)|\b__t\))\+'';/g,O=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,S=/\w*$/,I=/^\s*function[ \n\r\t]+\w/,A=/<%=([\s\S]+?)%>/g,D=RegExp("^["+j+"]*0+(?=.$)"),N=/($^)/,B=/\bthis\b/,P=/['\n\r\t\u2028\u2029\\]/g,R="Array Boolean Date Error Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),F="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),$="[object Arguments]",L="[object Array]",T="[object Boolean]",z="[object Date]",q="[object Error]",K="[object Function]",W="[object Number]",G="[object Object]",J="[object RegExp]",M="[object String]",H={}; H[K]=false,H[$]=H[L]=H[T]=H[z]=H[W]=H[G]=H[J]=H[M]=true;var U={leading:false,maxWait:0,trailing:false},V={configurable:false,enumerable:false,value:null,writable:false},Q={a:"",b:null,c:"",d:"",e:"",v:null,g:"",h:null,support:null,i:"",j:false},X={"boolean":false,"function":true,object:true,number:false,string:false,undefined:false},Y={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},Z=X[typeof window]&&window||this,nt=X[typeof exports]&&exports&&!exports.nodeType&&exports,tt=X[typeof module]&&module&&!module.nodeType&&module,et=tt&&tt.exports===nt&&nt,rt=X[typeof global]&&global; -!rt||rt.global!==rt&&rt.window!==rt||(Z=rt);var ut=g();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Z._=ut, define(function(){return ut})):nt&&tt?et?(tt.exports=ut)._=ut:nt._=ut:Z._=ut}).call(this); \ No newline at end of file +!rt||rt.global!==rt&&rt.window!==rt||(Z=rt);var ut=g();typeof define=="function"&&typeof define.amd=="object"&&define.amd? define(function(){return ut}):nt&&tt?et?(tt.exports=ut)._=ut:nt._=ut:Z._=ut}).call(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index ad754a0e11..6358c5470a 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -6561,12 +6561,6 @@ // some AMD build optimizers like r.js check for condition patterns like the following: if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) { - // Expose Lo-Dash to the global object even when an AMD loader is present in - // case Lo-Dash was injected by a third-party script and not intended to be - // loaded as a module. The global assignment can be reverted in the Lo-Dash - // module by its `noConflict()` method. - root._ = _; - // define as an anonymous module so, through path mapping, it can be // referenced as the "underscore" module define(function() { diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 37e1b2b183..dbc8705e1c 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -5,19 +5,19 @@ */ ;(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);++re?0:e);++r=_&&i===n,l=[];if(f){var p=o(r);p?(i=t,r=p):f=false}for(;++ui(r,p)&&l.push(p);return f&&c(r),l}function at(n,t,e,r){r=(r||0)-1;for(var u=n?n.length:0,o=[];++r=b&&i===n,l=[];if(f){var p=o(r);p?(i=t,r=p):f=false}for(;++ui(r,p)&&l.push(p);return f&&c(r),l}function at(n,t,e,r){r=(r||0)-1;for(var u=n?n.length:0,o=[];++r=_&&f===n,h=u||v?a():s; +if(f!=q)return false;if(f=n.constructor,p=t.constructor,f!=p&&!(jt(f)&&f instanceof f&&jt(p)&&p instanceof p)&&"constructor"in n&&"constructor"in t)return false}for(p=!u,u||(u=a()),o||(o=a()),f=u.length;f--;)if(u[f]==n)return o[f]==t;var v=0,i=true;if(u.push(n),o.push(t),c){if(f=n.length,v=t.length,i=v==n.length,!i&&!r)return i;for(;v--;)if(c=f,p=t[v],r)for(;c--&&!(i=ft(n[c],p,e,r,u,o)););else if(!(i=ft(n[v],p,e,r,u,o)))break;return i}return _(t,function(t,a,f){return de.call(f,a)?(v++,i=de.call(n,a)&&ft(n[a],t,e,r,u,o)):void 0 +}),i&&!r&&_(n,function(n,t,e){return de.call(e,t)?i=-1<--v:void 0}),p&&(l(u),l(o)),i}function lt(n,t,e,r,u){(qe(t)?Rt:g)(t,function(t,o){var i,a,f=t,l=n[o];if(t&&((a=qe(t))||h(t))){for(f=r.length;f--;)if(i=r[f]==t){l=u[f];break}if(!i){var c;e&&(f=e(l,t),c=typeof f!="undefined")&&(l=f),c||(l=a?qe(l)?l:[]:h(l)?l:{}),r.push(t),u.push(l),c||lt(l,t,e,r,u)}}else e&&(f=e(l,t),typeof f=="undefined"&&(f=t)),typeof f!="undefined"&&(l=f);n[o]=l})}function ct(n,t){return n+me(Fe()*(t-n+1))}function pt(e,r,u){var i=-1,f=gt(),p=e?e.length:0,s=[],v=!r&&p>=b&&f===n,h=u||v?a():s; if(v){var g=o(h);g?(f=t,h=g):(v=false,h=u?h:(l(h),s))}for(;++if(h,y))&&((u||v)&&h.push(y),s.push(g))}return v?(l(h.k),c(h)):u&&l(h),s}function st(n){return function(t,e,r){var u={};e=Z.createCallback(e,r,3),r=-1;var o=t?t.length:0;if(typeof o=="number")for(;++re?Ae(0,o+e):e)||0,qe(n)?i=-1e?0:e);++t=v; m?(i&&(i=ye(i)),s=f,a=n.apply(l,o)):i||(i=ke(r,v))}return m&&c?c=ye(c):c||t===h||(c=ke(u,t)),e&&(m=true,a=n.apply(l,o)),!m||c||i||(o=l=null),a}}function Jt(n){if(!jt(n))throw new le;var t=p(arguments,1);return ke(function(){n.apply(v,t)},1)}function Qt(n){return n}function Xt(n,t){var e=n,r=!t||jt(e);t||(e=nt,t=n,n=Z),Rt(dt(t),function(u){var o=n[u]=t[u];r&&(e.prototype[u]=function(){var t=this.__wrapped__,r=[t];return je.apply(r,arguments),r=o.apply(n,r),t&&typeof t=="object"&&t===r?this:(r=new e(r),r.__chain__=this.__chain__,r) -})})}function Yt(){}function Zt(){return this.__wrapped__}e=e?Y.defaults(G.Object(),e,Y.pick(G,A)):G;var ne=e.Array,te=e.Boolean,ee=e.Date,re=e.Function,ue=e.Math,oe=e.Number,ie=e.Object,ae=e.RegExp,fe=e.String,le=e.TypeError,ce=[],pe=ie.prototype,se=e._,ve=pe.toString,he=ae("^"+fe(ve).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),ge=ue.ceil,ye=e.clearTimeout,me=ue.floor,_e=re.prototype.toString,be=he.test(be=ie.getPrototypeOf)&&be,de=pe.hasOwnProperty,we=he.test(we=ee.now)&&we||function(){return+new ee +})})}function Yt(){}function Zt(){return this.__wrapped__}e=e?Y.defaults(G.Object(),e,Y.pick(G,A)):G;var ne=e.Array,te=e.Boolean,ee=e.Date,re=e.Function,ue=e.Math,oe=e.Number,ie=e.Object,ae=e.RegExp,fe=e.String,le=e.TypeError,ce=[],pe=ie.prototype,se=e._,ve=pe.toString,he=ae("^"+fe(ve).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),ge=ue.ceil,ye=e.clearTimeout,me=ue.floor,be=re.prototype.toString,_e=he.test(_e=ie.getPrototypeOf)&&_e,de=pe.hasOwnProperty,we=he.test(we=ee.now)&&we||function(){return+new ee },je=ce.push,ke=e.setTimeout,xe=ce.splice,Ce=typeof(Ce=X&&Q&&X.setImmediate)=="function"&&!he.test(Ce)&&Ce,Oe=function(){try{var n={},t=he.test(t=ie.defineProperty)&&t,e=t(n,n,n)&&t}catch(r){}return e}(),Ie=he.test(Ie=ie.create)&&Ie,Ne=he.test(Ne=ne.isArray)&&Ne,Se=e.isFinite,Ee=e.isNaN,Re=he.test(Re=ie.keys)&&Re,Ae=ue.max,De=ue.min,$e=e.parseInt,Fe=ue.random,Te={};Te[$]=ne,Te[F]=te,Te[T]=ee,Te[B]=re,Te[q]=ie,Te[W]=oe,Te[z]=ae,Te[P]=fe,nt.prototype=Z.prototype;var Be=Z.support={};Be.funcDecomp=!he.test(e.a)&&E.test(s),Be.funcNames=typeof re.name=="string",Z.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:I,variable:"",imports:{_:Z}},Ie||(rt=function(){function n(){}return function(t){if(kt(t)){n.prototype=t; var r=new n;n.prototype=null}return r||e.Object()}}());var We=Oe?function(n,t){M.value=t,Oe(n,"__bindData__",M)}:Yt,qe=Ne||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&ve.call(n)==$||false},ze=Re?function(n){return kt(n)?Re(n):[]}:J,Pe={"&":"&","<":"<",">":">",'"':""","'":"'"},Ke=wt(Pe),Le=ae("("+ze(Ke).join("|")+")","g"),Me=ae("["+ze(Pe).join("")+"]","g"),Ue=st(function(n,t,e){de.call(n,e)?n[e]++:n[e]=1}),Ve=st(function(n,t,e){(de.call(n,e)?n[e]:n[e]=[]).push(t) }),Ge=st(function(n,t,e){n[e]=t});Ce&&(Jt=function(n){if(!jt(n))throw new le;return Ce.apply(e,arguments)});var He=8==$e(d+"08")?$e:function(n,t){return $e(Ct(n)?n.replace(N,""):n,t||0)};return Z.after=function(n,t){if(!jt(t))throw new le;return function(){return 1>--n?t.apply(this,arguments):void 0}},Z.assign=H,Z.at=function(n){for(var t=arguments,e=-1,r=at(t,true,false,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=ne(t);++e=_&&o(i?r[i]:g)}n:for(;++p(m?t(m,y):s(g,y))){for(i=u,(m||g).push(y);--i;)if(m=f[i],0>(m?t(m,y):s(r[i],y)))continue n;h.push(y)}}for(;u--;)(m=f[u])&&c(m);return l(f),l(g),h},Z.invert=wt,Z.invoke=function(n,t){var e=p(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,i=ne(typeof o=="number"?o:0); +var e=p(arguments,2);return ke(function(){n.apply(v,e)},t)},Z.difference=function(n){return it(n,at(arguments,true,true,1))},Z.filter=St,Z.flatten=function(n,t,e,r){return typeof t!="boolean"&&null!=t&&(r=e,e=typeof t!="function"&&r&&r[t]===n?null:t,t=false),null!=e&&(n=Dt(n,e,r)),at(n,t)},Z.forEach=Rt,Z.forEachRight=At,Z.forIn=_,Z.forInRight=function(n,t,e){var r=[];_(n,function(n,t){r.push(t,n)});var u=r.length;for(t=ut(t,e,3);u--&&false!==t(r[u--],r[u],n););return n},Z.forOwn=g,Z.forOwnRight=_t,Z.functions=dt,Z.groupBy=Ve,Z.indexBy=Ge,Z.initial=function(n,t,e){var r=0,u=n?n.length:0; +if(typeof t!="number"&&null!=t){var o=u;for(t=Z.createCallback(t,e,3);o--&&t(n[o],o,n);)r++}else r=null==t||e?1:t||r;return p(n,0,De(Ae(0,u-r),u))},Z.intersection=function(e){for(var r=arguments,u=r.length,i=-1,f=a(),p=-1,s=gt(),v=e?e.length:0,h=[],g=a();++i=b&&o(i?r[i]:g)}n:for(;++p(m?t(m,y):s(g,y))){for(i=u,(m||g).push(y);--i;)if(m=f[i],0>(m?t(m,y):s(r[i],y)))continue n;h.push(y)}}for(;u--;)(m=f[u])&&c(m);return l(f),l(g),h},Z.invert=wt,Z.invoke=function(n,t){var e=p(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,i=ne(typeof o=="number"?o:0); return Rt(n,function(n){i[++r]=(u?t:n[t]).apply(n,e)}),i},Z.keys=ze,Z.map=Dt,Z.max=$t,Z.memoize=function(n,t){function e(){var r=e.cache,u=t?t.apply(this,arguments):m+arguments[0];return de.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}if(!jt(n))throw new le;return e.cache={},e},Z.merge=function(n){var t=arguments,e=2;if(!kt(n))return n;if("number"!=typeof t[2]&&(e=t.length),3e?Ae(0,r+e):De(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},Z.mixin=Xt,Z.noConflict=function(){return e._=se,this },Z.noop=Yt,Z.parseInt=He,Z.random=function(n,t,e){var r=null==n,u=null==t;return null==e&&(typeof n=="boolean"&&u?(e=n,n=1):u||typeof t!="boolean"||(e=t,u=true)),r&&u&&(t=1),n=+n||0,u?(t=n,n=0):t=+t||0,e||n%1||t%1?(e=Fe(),De(n+e*(t-n+parseFloat("1e-"+((e+"").length-1))),t)):ct(n,t)},Z.reduce=Tt,Z.reduceRight=Bt,Z.result=function(n,t){if(n){var e=n[t];return jt(e)?n[t]():e}},Z.runInContext=s,Z.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:ze(n).length},Z.some=qt,Z.sortedIndex=Lt,Z.template=function(n,t,e){var r=Z.templateSettings; n=fe(n||""),e=V({},e,r);var u,o=V({},e.imports,r.imports),r=ze(o),o=Ot(o),a=0,f=e.interpolate||S,l="__p+='",f=ae((e.escape||S).source+"|"+f.source+"|"+(f===I?x:S).source+"|"+(e.evaluate||S).source+"|$","g");n.replace(f,function(t,e,r,o,f,c){return r||(r=o),l+=n.slice(a,c).replace(R,i),e&&(l+="'+__e("+e+")+'"),f&&(u=true,l+="';"+f+";\n__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),a=c+t.length,t}),l+="';",f=e=e.variable,f||(e="obj",l="with("+e+"){"+l+"}"),l=(u?l.replace(w,""):l).replace(j,"$1").replace(k,"$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=re(r,"return "+l).apply(v,o)}catch(p){throw p.source=l,p}return t?c(t):(c.source=l,c)},Z.unescape=function(n){return null==n?"":fe(n).replace(Le,mt)},Z.uniqueId=function(n){var t=++y;return fe(null==n?"":n)+t},Z.all=Nt,Z.any=qt,Z.detect=Et,Z.findWhere=Et,Z.foldl=Tt,Z.foldr=Bt,Z.include=It,Z.inject=Tt,g(Z,function(n,t){Z.prototype[t]||(Z.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return je.apply(t,arguments),t=n.apply(Z,t),e?new nt(t,e):t})}),Z.first=zt,Z.last=function(n,t,e){var r=0,u=n?n.length:0; if(typeof t!="number"&&null!=t){var o=u;for(t=Z.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 p(n,Ae(0,u-r))},Z.sample=function(n,t,e){return n&&typeof n.length!="number"&&(n=Ot(n)),null==t||e?n?n[ct(0,n.length-1)]:v:(n=Wt(n),n.length=De(Ae(0,t),n.length),n)},Z.take=zt,Z.head=zt,g(Z,function(n,t){var e="sample"!==t;Z.prototype[t]||(Z.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 })}),Z.VERSION="2.3.0",Z.prototype.chain=function(){return this.__chain__=true,this},Z.prototype.toString=function(){return fe(this.__wrapped__)},Z.prototype.value=Zt,Z.prototype.valueOf=Zt,Rt(["join","pop","shift"],function(n){var t=ce[n];Z.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new nt(e,n):e}}),Rt(["push","reverse","sort","unshift"],function(n){var t=ce[n];Z.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Rt(["concat","slice","splice"],function(n){var t=ce[n]; -Z.prototype[n]=function(){return new nt(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Z}var v,h=[],g=[],y=0,m=+new Date+"",_=75,b=40,d=" \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",w=/\b__p\+='';/g,j=/\b(__p\+=)''\+/g,k=/(__e\(.*?\)|\b__t\))\+'';/g,x=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,C=/\w*$/,O=/^\s*function[ \n\r\t]+\w/,I=/<%=([\s\S]+?)%>/g,N=RegExp("^["+d+"]*0+(?=.$)"),S=/($^)/,E=/\bthis\b/,R=/['\n\r\t\u2028\u2029\\]/g,A="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),D="[object Arguments]",$="[object Array]",F="[object Boolean]",T="[object Date]",B="[object Function]",W="[object Number]",q="[object Object]",z="[object RegExp]",P="[object String]",K={}; +Z.prototype[n]=function(){return new nt(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Z}var v,h=[],g=[],y=0,m=+new Date+"",b=75,_=40,d=" \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",w=/\b__p\+='';/g,j=/\b(__p\+=)''\+/g,k=/(__e\(.*?\)|\b__t\))\+'';/g,x=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,C=/\w*$/,O=/^\s*function[ \n\r\t]+\w/,I=/<%=([\s\S]+?)%>/g,N=RegExp("^["+d+"]*0+(?=.$)"),S=/($^)/,E=/\bthis\b/,R=/['\n\r\t\u2028\u2029\\]/g,A="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),D="[object Arguments]",$="[object Array]",F="[object Boolean]",T="[object Date]",B="[object Function]",W="[object Number]",q="[object Object]",z="[object RegExp]",P="[object String]",K={}; K[B]=false,K[D]=K[$]=K[F]=K[T]=K[W]=K[q]=K[z]=K[P]=true;var L={leading:false,maxWait:0,trailing:false},M={configurable:false,enumerable:false,value:null,writable:false},U={"boolean":false,"function":true,object:true,number:false,string:false,undefined:false},V={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},G=U[typeof window]&&window||this,H=U[typeof exports]&&exports&&!exports.nodeType&&exports,J=U[typeof module]&&module&&!module.nodeType&&module,Q=J&&J.exports===H&&H,X=U[typeof global]&&global;!X||X.global!==X&&X.window!==X||(G=X); -var Y=s();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(G._=Y, define(function(){return Y})):H&&J?Q?(J.exports=Y)._=Y:H._=Y:G._=Y}).call(this); \ No newline at end of file +var Y=s();typeof define=="function"&&typeof define.amd=="object"&&define.amd? define(function(){return Y}):H&&J?Q?(J.exports=Y)._=Y:H._=Y:G._=Y}).call(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index ae0b08cdde..8da1016aba 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -4863,12 +4863,6 @@ // some AMD build optimizers like r.js check for condition patterns like the following: if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) { - // Expose Lo-Dash to the global object even when an AMD loader is present in - // case Lo-Dash was injected by a third-party script and not intended to be - // loaded as a module. The global assignment can be reverted in the Lo-Dash - // module by its `noConflict()` method. - root._ = lodash; - // define as an anonymous module so, through path mapping, it can be // referenced as the "underscore" module define(function() { diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index 53f56367b5..001bc64737 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -36,4 +36,4 @@ for(t=Q(t,e,3),q(n,function(n,r,e){i[++u]={m:t(n,r,e),n:u,o:n}}),o=i.length,i.so },u.reduce=W,u.reduceRight=z,u.result=function(n,r){if(n){var t=n[r];return E(t)?n[r]():t}},u.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:Ur(n).length},u.some=P,u.sortedIndex=J,u.template=function(n,r,e){var o=u,i=o.templateSettings;n=(n||"")+"",e=w({},e,i);var f=0,a="__p+='",i=e.variable;n.replace(RegExp((e.escape||ur).source+"|"+(e.interpolate||ur).source+"|"+(e.evaluate||ur).source+"|$","g"),function(r,e,u,o,i){return a+=n.slice(f,i).replace(or,t),e&&(a+="'+_.escape("+e+")+'"),o&&(a+="';"+o+";\n__p+='"),u&&(a+="'+((__t=("+u+"))==null?'':__t)+'"),f=i+r.length,r }),a+="';",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(Hr,_)},u.uniqueId=function(n){var r=++rr+"";return n?n+r:r},u.all=k,u.any=P,u.detect=F,u.findWhere=function(n,r){return U(n,r,true)},u.foldl=W,u.foldr=z,u.include=R,u.inject=W,u.first=V,u.last=function(n,r,t){var u=0,o=n?n.length:0; if(typeof r!="number"&&null!=r){var i=o;for(r=Q(r,t,3);i--&&r(n[i],i,n);)u++}else if(u=r,null==u||t)return n?n[o-1]:nr;return e(n,Mr(0,o-u))},u.sample=function(n,r,t){return n&&typeof n.length!="number"&&(n=N(n)),null==r||t?n?n[0+Or(Wr()*(n.length-1-0+1))]:nr:(n=C(n),n.length=$r(Mr(0,r),n.length),n)},u.take=V,u.head=V,Z(u),u.VERSION="2.3.0",u.prototype.chain=function(){return this.__chain__=true,this},u.prototype.value=function(){return this.__wrapped__},q("pop push reverse shift sort splice unshift".split(" "),function(n){var r=wr[n]; -u.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),zr.spliceObjects||0!==n.length||delete n[0],this}}),q(["concat","join","slice"],function(n){var r=wr[n];u.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=true),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(yr._=u, define(function(){return u})):mr&&_r?dr?(_r.exports=u)._=u:mr._=u:yr._=u}).call(this); \ No newline at end of file +u.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),zr.spliceObjects||0!==n.length||delete n[0],this}}),q(["concat","join","slice"],function(n){var r=wr[n];u.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=true),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd? define(function(){return u}):mr&&_r?dr?(_r.exports=u)._=u:mr._=u:yr._=u}).call(this); \ No newline at end of file diff --git a/lodash.js b/lodash.js index a3de6e032a..18d994653e 100644 --- a/lodash.js +++ b/lodash.js @@ -6945,12 +6945,6 @@ // some AMD build optimizers like r.js check for condition patterns like the following: if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) { - // Expose Lo-Dash to the global object even when an AMD loader is present in - // case Lo-Dash was injected by a third-party script and not intended to be - // loaded as a module. The global assignment can be reverted in the Lo-Dash - // module by its `noConflict()` method. - root._ = _; - // define as an anonymous module so, through path mapping, it can be // referenced as the "underscore" module define(function() { From 8dedc6d3dce9d84e36927aef913ac389386a19e7 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 12 Nov 2013 00:20:42 -0800 Subject: [PATCH 03/57] Make use of `_.noop` more in test/test.js. --- test/test.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/test.js b/test/test.js index ae34ef654f..1ee7e8de25 100644 --- a/test/test.js +++ b/test/test.js @@ -5742,8 +5742,7 @@ _.forEach(['reduce', 'reduceRight'], function(methodName) { var array = [1, 2, 3], - func = _[methodName], - noop = function() {}; + func = _[methodName]; test('`_.' + methodName + '` should reduce a collection to a single value', 1, function() { var actual = func(['a', 'b', 'c'], function(accumulator, value) { @@ -5780,7 +5779,7 @@ _.forEach(empties, function(value) { try { - actual.push(func(value, noop)); + actual.push(func(value, _.noop)); } catch(e) { } }); @@ -5792,7 +5791,7 @@ var actual = _.map(empties, function(value) { try { - return func(value, noop, 'x'); + return func(value, _.noop, 'x'); } catch(e) { } }); @@ -5800,7 +5799,7 @@ }); test('`_.' + methodName + '` should handle an initial `accumulator` value of `undefined`', 1, function() { - var actual = func([], noop, undefined); + var actual = func([], _.noop, undefined); strictEqual(actual, undefined); }); }); @@ -6970,7 +6969,7 @@ setTimeout(function() { strictEqual(count, 2); QUnit.start(); - }, 256); + }, 512); } else { skipTest(3); From 8153f97899d1c27982cb8a1f9a2b9e6685911708 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 12 Nov 2013 00:21:29 -0800 Subject: [PATCH 04/57] Update docdown to correctly detect `_.noop` as a function. [ci skip] --- doc/README.md | 40 ++++++++++++++-------------- vendor/docdown/src/DocDown/Entry.php | 3 ++- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/doc/README.md b/doc/README.md index 1331ebe800..8919ede0dc 100644 --- a/doc/README.md +++ b/doc/README.md @@ -170,11 +170,11 @@ ## `Utilities` -* [`_.noop`](#_noop) * [`_.escape`](#_escapestring) * [`_.identity`](#_identityvalue) * [`_.mixin`](#_mixinobject-object) * [`_.noConflict`](#_noconflict) +* [`_.noop`](#_noop) * [`_.parseInt`](#_parseintvalue-radix) * [`_.random`](#_randommin0-max1-floatingfalse) * [`_.result`](#_resultobject-property) @@ -3941,25 +3941,6 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ## `“Utilities” Methods` - - -### `_.noop` -# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6176 "View in source") [Ⓣ][1] - -*(unknown)*: A no-operation function. - -#### Example -```js -var object = { 'name': 'fred' }; -_.noop(object) === undefined; -// => true -``` - -* * * - - - - ### `_.escape(string)` @@ -4060,6 +4041,25 @@ var lodash = _.noConflict(); + + +### `_.noop()` +# [Ⓢ](https://github.com/lodash/lodash/blob/master/lodash.js#L6176 "View in source") [Ⓣ][1] + +A no-operation function. + +#### Example +```js +var object = { 'name': 'fred' }; +_.noop(object) === undefined; +// => true +``` + +* * * + + + + ### `_.parseInt(value, [radix])` diff --git a/vendor/docdown/src/DocDown/Entry.php b/vendor/docdown/src/DocDown/Entry.php index 3108aaede1..51facb64d9 100644 --- a/vendor/docdown/src/DocDown/Entry.php +++ b/vendor/docdown/src/DocDown/Entry.php @@ -77,7 +77,8 @@ private function isFunction() { $this->isCtor() || count($this->getParams()) || count($this->getReturns()) || - preg_match('/\*[\t ]*@function\b/', $this->entry) + preg_match('/\*[\t ]*@function\b/', $this->entry) || + preg_match('#\*/\s*function #', $this->entry) ); } return $this->_isFunction; From 37ccc80ba404326a57707cd5b46a99f4c5f9e491 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 12 Nov 2013 08:59:40 -0800 Subject: [PATCH 05/57] Fix `_.size` doc typo. [ci skip] [closes #394] --- dist/lodash.compat.js | 2 +- dist/lodash.js | 2 +- dist/lodash.underscore.js | 2 +- doc/README.md | 2 +- lodash.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 5295d60b30..9117a0a83c 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -4176,7 +4176,7 @@ * // => 3 * * _.size('pebbles'); - * // => 5 + * // => 7 */ function size(collection) { var length = collection ? collection.length : 0; diff --git a/dist/lodash.js b/dist/lodash.js index 6358c5470a..00aa8d50b5 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -3839,7 +3839,7 @@ * // => 3 * * _.size('pebbles'); - * // => 5 + * // => 7 */ function size(collection) { var length = collection ? collection.length : 0; diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index 8da1016aba..cb6c1898e2 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -2666,7 +2666,7 @@ * // => 3 * * _.size('pebbles'); - * // => 5 + * // => 7 */ function size(collection) { var length = collection ? collection.length : 0; diff --git a/doc/README.md b/doc/README.md index 8919ede0dc..7cfe6570d6 100644 --- a/doc/README.md +++ b/doc/README.md @@ -2018,7 +2018,7 @@ _.size({ 'one': 1, 'two': 2, 'three': 3 }); // => 3 _.size('pebbles'); -// => 5 +// => 7 ``` * * * diff --git a/lodash.js b/lodash.js index 18d994653e..a715a2ab5f 100644 --- a/lodash.js +++ b/lodash.js @@ -4194,7 +4194,7 @@ * // => 3 * * _.size('pebbles'); - * // => 5 + * // => 7 */ function size(collection) { var length = collection ? collection.length : 0; From ac5e92c879cffe5631772fbc0eeb691b39378777 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 13 Nov 2013 00:20:17 -0800 Subject: [PATCH 06/57] Update doc whitespace and `_.template` doc example. [ci skip] --- dist/lodash.compat.js | 10 +++++----- dist/lodash.js | 10 +++++----- dist/lodash.underscore.js | 10 +++++----- doc/README.md | 8 ++++---- lodash.js | 10 +++++----- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 9117a0a83c..392d3f0db8 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -2505,7 +2505,7 @@ * @returns {Object} Returns the created inverted object. * @example * - * _.invert({ 'first': 'fred', 'second': 'barney' }); + * _.invert({ 'first': 'fred', 'second': 'barney' }); * // => { 'fred': 'first', 'barney': 'second' } */ function invert(object) { @@ -5409,8 +5409,8 @@ * @example * * var view = { - * 'label': 'docs', - * 'onClick': function() { console.log('clicked ' + this.label); } + * 'label': 'docs', + * 'onClick': function() { console.log('clicked ' + this.label); } * }; * * _.bindAll(view); @@ -6335,8 +6335,8 @@ * // => 'hello mustache!' * * // using the `imports` option to import jQuery - * var list = '<% $.each(people, function(name) { %>
  • <%- name %>
  • <% }); %>'; - * _.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { '$': jQuery } }); + * var list = '<% jq.each(people, function(name) { %>
  • <%- name %>
  • <% }); %>'; + * _.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { 'jq': jQuery } }); * // => '
  • fred
  • barney
  • ' * * // using the `sourceURL` option to specify a custom sourceURL for the template diff --git a/dist/lodash.js b/dist/lodash.js index 00aa8d50b5..5026d40a95 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -2172,7 +2172,7 @@ * @returns {Object} Returns the created inverted object. * @example * - * _.invert({ 'first': 'fred', 'second': 'barney' }); + * _.invert({ 'first': 'fred', 'second': 'barney' }); * // => { 'fred': 'first', 'barney': 'second' } */ function invert(object) { @@ -5070,8 +5070,8 @@ * @example * * var view = { - * 'label': 'docs', - * 'onClick': function() { console.log('clicked ' + this.label); } + * 'label': 'docs', + * 'onClick': function() { console.log('clicked ' + this.label); } * }; * * _.bindAll(view); @@ -5996,8 +5996,8 @@ * // => 'hello mustache!' * * // using the `imports` option to import jQuery - * var list = '<% $.each(people, function(name) { %>
  • <%- name %>
  • <% }); %>'; - * _.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { '$': jQuery } }); + * var list = '<% jq.each(people, function(name) { %>
  • <%- name %>
  • <% }); %>'; + * _.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { 'jq': jQuery } }); * // => '
  • fred
  • barney
  • ' * * // using the `sourceURL` option to specify a custom sourceURL for the template diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index cb6c1898e2..cc8d5685c5 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -1237,7 +1237,7 @@ * @returns {Object} Returns the created inverted object. * @example * - * _.invert({ 'first': 'fred', 'second': 'barney' }); + * _.invert({ 'first': 'fred', 'second': 'barney' }); * // => { 'fred': 'first', 'barney': 'second' } */ function invert(object) { @@ -3681,8 +3681,8 @@ * @example * * var view = { - * 'label': 'docs', - * 'onClick': function() { console.log('clicked ' + this.label); } + * 'label': 'docs', + * 'onClick': function() { console.log('clicked ' + this.label); } * }; * * _.bindAll(view); @@ -4423,8 +4423,8 @@ * // => 'hello mustache!' * * // using the `imports` option to import jQuery - * var list = '<% $.each(people, function(name) { %>
  • <%- name %>
  • <% }); %>'; - * _.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { '$': jQuery } }); + * var list = '<% jq.each(people, function(name) { %>
  • <%- name %>
  • <% }); %>'; + * _.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { 'jq': jQuery } }); * // => '
  • fred
  • barney
  • ' * * // using the `sourceURL` option to specify a custom sourceURL for the template diff --git a/doc/README.md b/doc/README.md index 7cfe6570d6..5ef59b1cd6 100644 --- a/doc/README.md +++ b/doc/README.md @@ -2254,8 +2254,8 @@ Binds methods of an object to the object itself, overwriting the existing method #### Example ```js var view = { - 'label': 'docs', - 'onClick': function() { console.log('clicked ' + this.label); } + 'label': 'docs', + 'onClick': function() { console.log('clicked ' + this.label); } }; _.bindAll(view); @@ -4237,8 +4237,8 @@ _.template('hello {{ name }}!', { 'name': 'mustache' }); // => 'hello mustache!' // using the `imports` option to import jQuery -var list = '<% $.each(people, function(name) { %>
  • <%- name %>
  • <% }); %>'; -_.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { '$': jQuery } }); +var list = '<% jq.each(people, function(name) { %>
  • <%- name %>
  • <% }); %>'; +_.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { 'jq': jQuery } }); // => '
  • fred
  • barney
  • ' // using the `sourceURL` option to specify a custom sourceURL for the template diff --git a/lodash.js b/lodash.js index a715a2ab5f..41b1a966ae 100644 --- a/lodash.js +++ b/lodash.js @@ -2523,7 +2523,7 @@ * @returns {Object} Returns the created inverted object. * @example * - * _.invert({ 'first': 'fred', 'second': 'barney' }); + * _.invert({ 'first': 'fred', 'second': 'barney' }); * // => { 'fred': 'first', 'barney': 'second' } */ function invert(object) { @@ -5427,8 +5427,8 @@ * @example * * var view = { - * 'label': 'docs', - * 'onClick': function() { console.log('clicked ' + this.label); } + * 'label': 'docs', + * 'onClick': function() { console.log('clicked ' + this.label); } * }; * * _.bindAll(view); @@ -6353,8 +6353,8 @@ * // => 'hello mustache!' * * // using the `imports` option to import jQuery - * var list = '<% $.each(people, function(name) { %>
  • <%- name %>
  • <% }); %>'; - * _.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { '$': jQuery } }); + * var list = '<% jq.each(people, function(name) { %>
  • <%- name %>
  • <% }); %>'; + * _.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { 'jq': jQuery } }); * // => '
  • fred
  • barney
  • ' * * // using the `sourceURL` option to specify a custom sourceURL for the template From f6fcf5fce406db5718235b36509dcd9402c0269e Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 13 Nov 2013 00:24:08 -0800 Subject: [PATCH 07/57] Attempt to make sauce tests public with names, tags, and customized options. --- .travis.yml | 20 ++-- test/saucelabs.js | 249 ++++++++++++++++++++++++++++++---------------- 2 files changed, 175 insertions(+), 94 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2ea46dcbba..1e371d4b1f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,8 @@ node_js: env: global: - BIN="node" BUILD=false COMPAT=false MAKE=false OPTION="" SAUCE_LABS=false - - SAUCE_USERNAME="jdalton" - - secure: "woILQltl1pI3DgadZ5NrcqntdPvnRmQBwIVNZL91Ht5d9snIhgyAixI6xNAS8F8BzD9RzqzVPHay5sHfn+GhNaojcaiHs1nXAbdyclevMyfP+3MQ1HGfMSU0bv1GdT35LJ+C0u4Y3SuuZSbBlNEeLXRPMngPZahf4xL8RsZz/is=" + - SAUCE_USERNAME="lodash" + - secure: "LGVeh7z/x6hxGCtr1BfgCSRva691ChX+1bs4ecJE71QwsDNJwknqmblZm7hFSTkq7msSapSDV5P9sgr6fsmmHuY3311Vl04sneRpz8ge1ZUIbmMODI+tZAasxyvyjZJdOrTFZr89BWN6e/SddDxDKNF4n0O1DgUF4irrT+aUxUE=" matrix: - BUILD="compat" - BUILD="modern" @@ -70,11 +70,11 @@ script: - "([ $SAUCE_LABS != false ] || [ $BUILD == false ]) && true || cd ./test" - "([ $SAUCE_LABS != false ] || [ $BUILD == false ]) && true || $BIN $OPTION ./test.js ../dist/lodash.$BUILD.js" - "([ $SAUCE_LABS != false ] || [ $BUILD == false ]) && true || $BIN $OPTION ./test.js ../dist/lodash.$BUILD.min.js" - - "([ $SAUCE_LABS == false ] || [ $BUILD == 'underscore' ]) && true || node ./test/saucelabs.js \"test/index.html?build=lodash-$BUILD\"" - - "([ $SAUCE_LABS == false ] || [ $BUILD == 'underscore' ]) && true || node ./test/saucelabs.js \"test/index.html?build=../dist/lodash.$BUILD.js\"" - - "[ $SAUCE_LABS == false ] && true || node ./test/saucelabs.js \"test/backbone.html?build=lodash-$BUILD\"" - - "[ $SAUCE_LABS == false ] && true || node ./test/saucelabs.js \"test/backbone.html?build=../dist/lodash.$BUILD.js\"" - - "[ $SAUCE_LABS == false ] && true || node ./test/saucelabs.js \"test/underscore.html?build=lodash-$BUILD\"" - - "[ $SAUCE_LABS == false ] && true || node ./test/saucelabs.js \"test/underscore.html?build=../dist/lodash.$BUILD.js\"" - - "([ $SAUCE_LABS == false ] || [ $COMPAT == false ]) && true || node ./test/saucelabs.js \"test/index.html?build=lodash-$BUILD&compat=7\"" - - "([ $SAUCE_LABS == false ] || [ $COMPAT == false ]) && true || node ./test/saucelabs.js \"test/index.html?build=../dist/lodash.$BUILD.js&compat=7\"" + - "([ $SAUCE_LABS == false ] || [ $BUILD == 'underscore' ]) && true || node ./test/saucelabs.js runner=\"test/index.html?build=lodash-$BUILD\" tags=\"$BUILD,production\"" + - "([ $SAUCE_LABS == false ] || [ $BUILD == 'underscore' ]) && true || node ./test/saucelabs.js runner=\"test/index.html?build=../dist/lodash.$BUILD.js\" tags=\"$BUILD,development\"" + - "[ $SAUCE_LABS == false ] && true || node ./test/saucelabs.js name=\"backbone tests\" runner=\"test/backbone.html?build=lodash-$BUILD\" tags=\"$BUILD,production,backbone\"" + - "[ $SAUCE_LABS == false ] && true || node ./test/saucelabs.js name=\"backbone tests\" runner=\"test/backbone.html?build=../dist/lodash.$BUILD.js\" tags=\"$BUILD,development,backbone\"" + - "[ $SAUCE_LABS == false ] && true || node ./test/saucelabs.js name=\"underscore tests\" runner=\"test/underscore.html?build=lodash-$BUILD\" tags=\"$BUILD,production,underscore\"" + - "[ $SAUCE_LABS == false ] && true || node ./test/saucelabs.js name=\"underscore tests\" runner=\"test/underscore.html?build=../dist/lodash.$BUILD.js\" tags=\"$BUILD,development,underscore\"" + - "([ $SAUCE_LABS == false ] || [ $COMPAT == false ]) && true || node ./test/saucelabs.js runner=\"test/index.html?build=lodash-$BUILD&compat=7\" tags=\"$BUILD,production,ie-compat-mode\"" + - "([ $SAUCE_LABS == false ] || [ $COMPAT == false ]) && true || node ./test/saucelabs.js runner=\"test/index.html?build=../dist/lodash.$BUILD.js&compat=7\" tags=\"$BUILD,development,ie-compat-mode\"" diff --git a/test/saucelabs.js b/test/saucelabs.js index 63b4209366..729bb1930f 100644 --- a/test/saucelabs.js +++ b/test/saucelabs.js @@ -1,38 +1,45 @@ ;(function() { 'use strict'; - var ecstatic = require('ecstatic'), - http = require('http'), + if (isFinite(process.env.TRAVIS_PULL_REQUEST)) { + console.error('Testing skipped for pull requests'); + process.exit(0); + } + + /** Load Node.js modules */ + var http = require('http'), path = require('path'), - request = require('request'), - SauceTunnel = require('sauce-tunnel'), url = require('url'); + /** Load other modules */ + var _ = require('../lodash'), + ecstatic = require('ecstatic'), + request = require('request'), + SauceTunnel = require('sauce-tunnel'); + + /** Used by `logInline` */ var attempts = -1, prevLine = ''; + /** Used as request `auth` and `options` values */ var port = 8081, username = process.env.SAUCE_USERNAME, accessKey = process.env.SAUCE_ACCESS_KEY, tunnelId = 'lodash_' + process.env.TRAVIS_JOB_NUMBER; - if (isFinite(process.env.TRAVIS_PULL_REQUEST)) { - console.error('Testing skipped for pull requests'); - process.exit(0); - } + var runner = process.argv.reduce(function(result, value) { + return optionToValue('runner', value) || result; + }, '/test/index.html'); - var runnerPathname = (function() { - var args = process.argv; - return args.length > 2 - ? '/' + args[args.length - 1].replace(/^\W+/, '') - : '/test/index.html'; - }()); + var sessionName = process.argv.reduce(function(result, value) { + return optionToValue('name', value) || result; + }, 'lodash tests'); - var runnerQuery = url.parse(runnerPathname, true).query, - isBackbone = /\bbackbone\b/i.test(runnerPathname), - isMobile = /\bmobile\b/i.test(runnerQuery.build), - isModern = /\bmodern\b/i.test(runnerQuery.build); + var tags = process.argv.reduce(function(result, value) { + return optionToArray('tags', value) || result; + }, []); + /** List of platforms to load the runner on */ var platforms = [ ['Windows 7', 'chrome', ''], ['Windows 7', 'firefox', '25'], @@ -53,6 +60,12 @@ ['Windows 7', 'safari', '5'] ]; + /** Used to tailor the `platforms` array */ + var runnerQuery = url.parse(runner, true).query, + isBackbone = /\bbackbone\b/i.test(runner), + isMobile = /\bmobile\b/i.test(runnerQuery.build), + isModern = /\bmodern\b/i.test(runnerQuery.build); + // platforms to test IE compat mode if (runnerQuery.compat) { platforms = [ @@ -91,39 +104,14 @@ }); } - // create a web server for the local dir - var mount = ecstatic({ - 'root': process.cwd(), - 'cache': false - }); - - http.createServer(function(req, res) { - var compat = url.parse(req.url, true).query.compat; - if (compat) { - // see http://msdn.microsoft.com/en-us/library/ff955275(v=vs.85).aspx - res.setHeader('X-UA-Compatible', 'IE=' + compat); - } - mount(req, res); - }).listen(port); - - // set up Sauce Connect so we can use this server from Sauce Labs - var tunnelTimeout = 10000, - tunnel = new SauceTunnel(username, accessKey, tunnelId, true, tunnelTimeout); - - console.log('Opening Sauce Connect tunnel...'); - - tunnel.start(function(success) { - if (success) { - console.log('Sauce Connect tunnel opened'); - runTests(); - } else { - console.error('Failed to open Sauce Connect tunnel'); - process.exit(2); - } - }); - /*--------------------------------------------------------------------------*/ + /** + * Logs an inline message to standard output. + * + * @private + * @param {string} text The text to log. + */ function logInline(text) { var blankLine = repeat(' ', prevLine.length); if (text.length > 40) { @@ -133,25 +121,113 @@ process.stdout.write(text + blankLine.slice(text.length) + '\r'); } - function repeat(text, times) { - return Array(times + 1).join(text); + /** + * Converts a comma separated option value into an array. + * + * @private + * @param {string} name The name of the option to inspect. + * @param {string} string The options string. + * @returns {Array} Returns the new converted array. + */ + function optionToArray(name, string) { + return _.compact(_.isArray(string) + ? string + : _.invoke((optionToValue(name, string) || '').split(/, */), 'trim') + ); + } + + /** + * Extracts the option value from an option string. + * + * @private + * @param {string} name The name of the option to inspect. + * @param {string} string The options string. + * @returns {string|undefined} Returns the option value, else `undefined`. + */ + function optionToValue(name, string) { + var result = (result = string.match(RegExp('^' + name + '=([\\s\\S]+)$'))) && result[1].trim(); + return result || undefined; + } + + /** + * Creates a string with `text` repeated `n` number of times. + * + * @private + * @param {string} text The text to repeat. + * @param {number} n The number of times to repeat `text`. + * @returns {string} The created string. + */ + function repeat(text, n) { + return Array(n + 1).join(text); } /*--------------------------------------------------------------------------*/ + /** + * Processes the result object of the test session. + * + * @private + * @param {Object} results The result object to process. + */ + function handleTestResults(results) { + var failingTests = results.filter(function(test) { + var result = test.result; + return !result || result.failed || /\berror\b/i.test(result.message); + }); + + var failingPlatforms = failingTests.map(function(test) { + return test.platform; + }); + + if (!failingTests.length) { + console.log('Tests passed'); + } + else { + console.error('Tests failed on platforms: ' + JSON.stringify(failingPlatforms)); + + failingTests.forEach(function(test) { + var details = 'See ' + test.url + ' for details.', + platform = JSON.stringify(test.platform), + result = test.result; + + if (result && result.failed) { + console.error(result.failed + ' failures on ' + platform + '. ' + details); + } else { + console.error('Testing on ' + platform + ' failed; no results available. ' + details); + } + }); + } + + console.log('Shutting down Sauce Connect tunnel...'); + + tunnel.stop(function() { + process.exit(failingTests.length ? 1 : 0); + }); + } + + /** + * Makes a request for Sauce Labs to start the test session. + * + * @private + */ function runTests() { - var testDefinition = { + var options = { 'framework': 'qunit', + 'name': sessionName, + 'public': 'public', 'platforms': platforms, + 'record-screenshots': false, + 'tags': tags, 'tunnel': 'tunnel-identifier:' + tunnelId, - 'url': 'http://localhost:' + port + runnerPathname + 'url': 'http://localhost:' + port + runner, + 'video-upload-on-pass': false }; - console.log('Starting saucelabs tests: ' + JSON.stringify(testDefinition)); + console.log('Starting saucelabs tests: ' + JSON.stringify(options)); request.post('https://saucelabs.com/rest/v1/' + username + '/js-tests', { 'auth': { 'user': username, 'pass': accessKey }, - 'json': testDefinition + 'json': options }, function(error, response, body) { var statusCode = response && response.statusCode; if (statusCode == 200) { @@ -166,6 +242,14 @@ }); } + /** + * Checks the status of the test session. If the session has completed it + * passes the result object to `handleTestResults`, else it checks the status + * again in five seconds. + * + * @private + * @param {Object} testIdentifier The object used to identify the session. + */ function waitForTestCompletion(testIdentifier) { request.post('https://saucelabs.com/rest/v1/' + username + '/js-tests/status', { 'auth': { 'user': username, 'pass': accessKey }, @@ -194,39 +278,36 @@ }); } - function handleTestResults(results) { - var failingTests = results.filter(function(test) { - var result = test.result; - return !result || result.failed || /\berror\b/i.test(result.message); - }); + /*--------------------------------------------------------------------------*/ - var failingPlatforms = failingTests.map(function(test) { - return test.platform; - }); + // create a web server for the local dir + var mount = ecstatic({ + 'root': process.cwd(), + 'cache': false + }); - if (!failingTests.length) { - console.log('Tests passed'); + http.createServer(function(req, res) { + var compat = url.parse(req.url, true).query.compat; + if (compat) { + // see http://msdn.microsoft.com/en-us/library/ff955275(v=vs.85).aspx + res.setHeader('X-UA-Compatible', 'IE=' + compat); } - else { - console.error('Tests failed on platforms: ' + JSON.stringify(failingPlatforms)); - - failingTests.forEach(function(test) { - var details = 'See ' + test.url + ' for details.', - platform = JSON.stringify(test.platform), - result = test.result; + mount(req, res); + }).listen(port); - if (result && result.failed) { - console.error(result.failed + ' failures on ' + platform + '. ' + details); - } else { - console.error('Testing on ' + platform + ' failed; no results available. ' + details); - } - }); - } + // set up Sauce Connect so we can use this server from Sauce Labs + var tunnelTimeout = 10000, + tunnel = new SauceTunnel(username, accessKey, tunnelId, true, tunnelTimeout); - console.log('Shutting down Sauce Connect tunnel...'); + console.log('Opening Sauce Connect tunnel...'); - tunnel.stop(function() { - process.exit(failingTests.length ? 1 : 0); - }); - } + tunnel.start(function(success) { + if (success) { + console.log('Sauce Connect tunnel opened'); + runTests(); + } else { + console.error('Failed to open Sauce Connect tunnel'); + process.exit(2); + } + }); }()); From 04df06404f4a998f8c60e26c41b09d0c78c17cb6 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 13 Nov 2013 01:11:50 -0800 Subject: [PATCH 08/57] Bump tested Chrome version in readme. [ci skip] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 954c46c9ed..faef05b82d 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ A list of upcoming features is available on our [roadmap](https://github.com/lod ## Support -Tested in Chrome 5~30, Firefox 2~25, IE 6-11, Opera 9.25~17, Safari 3-7, Node.js 0.6.21~0.10.21, Narwhal 0.3.2, PhantomJS 1.9.2, RingoJS 0.9, & Rhino 1.7RC5. +Tested in Chrome 5~31, Firefox 2~25, IE 6-11, Opera 9.25~17, Safari 3-7, Node.js 0.6.21~0.10.21, Narwhal 0.3.2, PhantomJS 1.9.2, RingoJS 0.9, & Rhino 1.7RC5. Special thanks to [Sauce Labs](https://saucelabs.com/) for providing automated browser testing.
    [![Sauce Labs](http://lodash.com/_img/sauce.png)](https://saucelabs.com/ "Sauce Labs: Selenium Testing & More") From 82e4cc9951e87574c44692c6296cd7bd38c3e797 Mon Sep 17 00:00:00 2001 From: Delapouite Date: Wed, 13 Nov 2013 17:04:49 +0100 Subject: [PATCH 09/57] Update README link to literals string spec [ci skip] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index faef05b82d..2d18c582d1 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ A list of upcoming features is available on our [roadmap](https://github.com/lod * [_.random](http://lodash.com/docs#random) supports returning floating-point numbers * [_.runInContext](http://lodash.com/docs#runInContext) for easier mocking * [_.support](http://lodash.com/docs#support) for flagging environment features - * [_.template](http://lodash.com/docs#template) supports [*“imports”*](http://lodash.com/docs#templateSettings_imports) options & [ES6 template delimiters](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6) + * [_.template](http://lodash.com/docs#template) supports [*“imports”*](http://lodash.com/docs#templateSettings_imports) options & [ES6 template delimiters](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-literals-string-literals) * [_.transform](http://lodash.com/docs#transform) as a powerful alternative to [_.reduce](http://lodash.com/docs#reduce) for transforming objects * [_.where](http://lodash.com/docs#where) supports deep object comparisons * [_.zip](http://lodash.com/docs#zip) is capable of unzipping values From 2c8c96149f0da5fffd56019b7b837d4cd853eaa6 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 13 Nov 2013 08:00:02 -0800 Subject: [PATCH 10/57] Fix how sauce runner and tags are parsed. --- .travis.yml | 2 +- test/saucelabs.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1e371d4b1f..8148fa783c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ env: global: - BIN="node" BUILD=false COMPAT=false MAKE=false OPTION="" SAUCE_LABS=false - SAUCE_USERNAME="lodash" - - secure: "LGVeh7z/x6hxGCtr1BfgCSRva691ChX+1bs4ecJE71QwsDNJwknqmblZm7hFSTkq7msSapSDV5P9sgr6fsmmHuY3311Vl04sneRpz8ge1ZUIbmMODI+tZAasxyvyjZJdOrTFZr89BWN6e/SddDxDKNF4n0O1DgUF4irrT+aUxUE=" + - secure: "aFxaPI4NvlZHgXvfmNtUlYCIeiVpC4QzkdevGHc2FK27BJLnNTKNno9sBhaygURbQ83bYzfQ+fe8SMIzE7aLramAGILrT4DiWqfO+ihuB3EK1cahCbB6OionbIUI27Xzy+YukO+5lQmMP/dpVlwhIfR3qxmN4m7wXI+ExEemjZg=" matrix: - BUILD="compat" - BUILD="modern" diff --git a/test/saucelabs.js b/test/saucelabs.js index 729bb1930f..b9d34834a3 100644 --- a/test/saucelabs.js +++ b/test/saucelabs.js @@ -28,7 +28,10 @@ tunnelId = 'lodash_' + process.env.TRAVIS_JOB_NUMBER; var runner = process.argv.reduce(function(result, value) { - return optionToValue('runner', value) || result; + value = optionToValue('runner', value); + return value == null + ? result + : '/' + value.replace(/^\W+/, ''); }, '/test/index.html'); var sessionName = process.argv.reduce(function(result, value) { @@ -36,7 +39,10 @@ }, 'lodash tests'); var tags = process.argv.reduce(function(result, value) { - return optionToArray('tags', value) || result; + value = optionToArray('tags', value); + return value.length + ? _.union(result, value) + : result; }, []); /** List of platforms to load the runner on */ From deb124f64588530f30d2568f28802cd2ba0cbaf3 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 13 Nov 2013 23:28:14 -0800 Subject: [PATCH 11/57] Update ES6 spec link in lodash source too. [ci skip] --- dist/lodash.compat.js | 2 +- dist/lodash.js | 2 +- lodash.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 392d3f0db8..e28fd8fc5d 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -50,7 +50,7 @@ /** * Used to match ES6 template delimiters - * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6 + * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-literals-string-literals */ var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; diff --git a/dist/lodash.js b/dist/lodash.js index 5026d40a95..af3d9ceee2 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -47,7 +47,7 @@ /** * Used to match ES6 template delimiters - * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6 + * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-literals-string-literals */ var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; diff --git a/lodash.js b/lodash.js index 41b1a966ae..7b31d34f25 100644 --- a/lodash.js +++ b/lodash.js @@ -49,7 +49,7 @@ /** * Used to match ES6 template delimiters - * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6 + * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-literals-string-literals */ var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; From 919166212fdbb8c7010319330b1b8e9d0b45e525 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 14 Nov 2013 00:25:00 -0800 Subject: [PATCH 12/57] Fix istanbul report in travis.yml and tweak async tests. --- .travis.yml | 2 +- test/test.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8148fa783c..dfca6c30a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,7 +66,7 @@ before_install: - "[ $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" script: - - "[ $BIN == 'istanbul' ] && $BIN cover ./test/test.js || true" + - "[ $BIN == 'istanbul' ] && $BIN cover -x \"**/vendor/**\" ./test/test.js -- ./dist/lodash.js || true" - "([ $SAUCE_LABS != false ] || [ $BUILD == false ]) && true || cd ./test" - "([ $SAUCE_LABS != false ] || [ $BUILD == false ]) && true || $BIN $OPTION ./test.js ../dist/lodash.$BUILD.js" - "([ $SAUCE_LABS != false ] || [ $BUILD == false ]) && true || $BIN $OPTION ./test.js ../dist/lodash.$BUILD.min.js" diff --git a/test/test.js b/test/test.js index 1ee7e8de25..b0fe13cf65 100644 --- a/test/test.js +++ b/test/test.js @@ -1459,7 +1459,7 @@ equal(counts[1], 2); QUnit.start(); - }, 256); + }, 512); } else { skipTest(7); @@ -1647,7 +1647,7 @@ asyncTest('should delay `func` execution', 2, function() { if (!(isRhino && isModularize)) { var pass = false; - _.delay(function(){ pass = true; }, 100); + _.delay(function(){ pass = true; }, 128); setTimeout(function() { ok(!pass); @@ -1656,7 +1656,7 @@ setTimeout(function() { ok(pass); QUnit.start(); - }, 256); + }, 512); } else { skipTest(2); @@ -7041,7 +7041,7 @@ setTimeout(function() { throttled(); throttled(); - }, 100); + }, 96); setTimeout(function() { ok(count > 1); From e7ffb808775861d16fadb886623e1dfca3c3ade4 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 14 Nov 2013 08:30:34 -0800 Subject: [PATCH 13/57] Enable other realm tests for Node too. --- test/test.js | 111 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 67 insertions(+), 44 deletions(-) diff --git a/test/test.js b/test/test.js index b0fe13cf65..2a7dc3dcae 100644 --- a/test/test.js +++ b/test/test.js @@ -183,34 +183,52 @@ /*--------------------------------------------------------------------------*/ - // add object from iframe + // add values from other realms (function() { - if (!document) { - return; + try { + _.extend(_, require('vm').runInNewContext([ + '({', + "'_arguments': (function() { return arguments; }(1, 2, 3)),", + "'_array': [1, 2, 3],", + "'_boolean': new Boolean(false),", + "'_date': new Date,", + "'_function': function() {},", + "'_nan': NaN,", + "'_null': null,", + "'_number': new Number(0),", + "'_object': { 'a': 1, 'b': 2, 'c': 3 },", + "'_regexp': /x/,", + "'_string': new String('a'),", + "'_undefined': undefined,", + '})' + ].join('\n'))); + } catch(e) { } + + if (!_._object && document) { + var iframe = document.createElement('iframe'); + iframe.frameBorder = iframe.height = iframe.width = 0; + body.appendChild(iframe); + + var idoc = (idoc = iframe.contentDocument || iframe.contentWindow).document || idoc; + idoc.write([ + ' + diff --git a/test/index.html b/test/index.html index 70c74330da..963e4c6841 100644 --- a/test/index.html +++ b/test/index.html @@ -13,6 +13,7 @@ +
    @@ -72,6 +73,7 @@ delete Object._defineProperty; delete Object._keys; + QUnit.config.asyncRetries = 3; QUnit.config.hidepassed = true; // assign results to `global_test_results` for Sauce Labs diff --git a/test/underscore.html b/test/underscore.html index d740219986..35d5e6eda6 100644 --- a/test/underscore.html +++ b/test/underscore.html @@ -22,150 +22,94 @@ + @@ -161,8 +157,8 @@ underscoreModule = underscore.noConflict(); underscoreModule.moduleName = 'underscore'; } - if (lodash && lodash.noConflict) { - lodashModule = lodash.noConflict(); + if (lodash) { + lodashModule = lodash; lodashModule.moduleName = 'lodash'; } if (ui.isModularize) { diff --git a/test/underscore.html b/test/underscore.html index 9e162b3dd0..1eb61bcfa6 100644 --- a/test/underscore.html +++ b/test/underscore.html @@ -110,14 +110,11 @@ global_test_results = results; }); - // load the non-modularized build of Lo-Dash - if (!ui.isModularize) { - document.write('