From 56b6d5047956ac7be538ff43a1b0e914750c3918 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 14 Feb 2013 09:03:06 -0800 Subject: [PATCH 01/22] Tweak `_.at` docs. Former-commit-id: 505e34b0a151287d78da73a1140d4aefdf45b43b --- dist/lodash.compat.js | 4 ++-- dist/lodash.js | 4 ++-- doc/README.md | 4 ++-- lodash.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 7fcf2b3999..cb0e197b7f 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -2127,7 +2127,7 @@ /*--------------------------------------------------------------------------*/ /** - * Creates an array of elements from the specified index(es), or keys, of the + * 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. * @@ -2135,7 +2135,7 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Array|Number|String} [index1, index2, ...] The index(es) of + * @param {Array|Number|String} [index1, index2, ...] The indexes of * `collection` to retrieve, either as individual arguments or arrays. * @returns {Array} Returns a new array of elements corresponding to the * provided indexes. diff --git a/dist/lodash.js b/dist/lodash.js index 97aed0a765..b2ce626d6b 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -1984,7 +1984,7 @@ /*--------------------------------------------------------------------------*/ /** - * Creates an array of elements from the specified index(es), or keys, of the + * 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. * @@ -1992,7 +1992,7 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Array|Number|String} [index1, index2, ...] The index(es) of + * @param {Array|Number|String} [index1, index2, ...] The indexes of * `collection` to retrieve, either as individual arguments or arrays. * @returns {Array} Returns a new array of elements corresponding to the * provided indexes. diff --git a/doc/README.md b/doc/README.md index a61bb0c1b5..26a825054d 100644 --- a/doc/README.md +++ b/doc/README.md @@ -945,11 +945,11 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` # [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2157 "View in source") [Ⓣ][1] -Creates an array of elements from the specified index(es), or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. +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. #### Arguments 1. `collection` *(Array|Object|String)*: The collection to iterate over. -2. `[index1, index2, ...]` *(Array|Number|String)*: The index(es) of `collection` to retrieve, either as individual arguments or arrays. +2. `[index1, index2, ...]` *(Array|Number|String)*: The indexes of `collection` to retrieve, either as individual arguments or arrays. #### Returns *(Array)*: Returns a new array of elements corresponding to the provided indexes. diff --git a/lodash.js b/lodash.js index c7c0c4c543..fb491b484d 100644 --- a/lodash.js +++ b/lodash.js @@ -2134,7 +2134,7 @@ /*--------------------------------------------------------------------------*/ /** - * Creates an array of elements from the specified index(es), or keys, of the + * 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. * @@ -2142,7 +2142,7 @@ * @memberOf _ * @category Collections * @param {Array|Object|String} collection The collection to iterate over. - * @param {Array|Number|String} [index1, index2, ...] The index(es) of + * @param {Array|Number|String} [index1, index2, ...] The indexes of * `collection` to retrieve, either as individual arguments or arrays. * @returns {Array} Returns a new array of elements corresponding to the * provided indexes. From 4101b8e937eeebfb7e6fb7f09ec81c45f8165a58 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 14 Feb 2013 09:03:47 -0800 Subject: [PATCH 02/22] Remove `reInsertVariable` cleanup in build/pre-compile.js. Former-commit-id: 1fa75107e8c43362b57021292e26397145e62e39 --- build/pre-compile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pre-compile.js b/build/pre-compile.js index 67097afc3a..5db74035d5 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -247,7 +247,7 @@ }); // remove whitespace from `_.template` related regexes - source = source.replace(/(?:reEmptyString\w+|reInsertVariable) *=.+/g, function(match) { + source = source.replace(/reEmptyString\w+ *=.+/g, function(match) { return match.replace(/ |\\n/g, ''); }); From 5ddbb8bc568116777787502f9656c5e2c30b419b Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 14 Feb 2013 09:21:06 -0800 Subject: [PATCH 03/22] Remove unneeded `__d` variable from `_.template`. Former-commit-id: 4ff32444d7e96f8b9cc39e61c1ce17fb34fa357c --- dist/lodash.compat.js | 2 +- dist/lodash.compat.min.js | 2 +- dist/lodash.js | 2 +- dist/lodash.min.js | 4 ++-- lodash.js | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index cb0e197b7f..98a0540fdc 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -4726,7 +4726,7 @@ (isEvaluating ? ', __j = Array.prototype.join;\n' + "function print() { __p += __j.call(arguments, '') }\n" - : (hasVariable ? '' : ', __d = ' + variable + '.' + variable + ' || ' + variable) + ';\n' + : ';\n' ) + source + 'return __p\n}'; diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index e6c8de36fa..a65967e617 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -35,7 +35,7 @@ return e=arguments,o=this,0r?Ft(0,e+r):qt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=G,r.noConflict=function(){return n._=ft,this},r.random=function(n,t){return n==Q&&t==Q&&(t=1),n=+n||0,t==Q&&(t=n,n=0),n+wt(Dt()*((+t||0)-n+1))},r.reduce=I,r.reduceRight=T,r.result=function(n,r){var e=n?n[r]:t;return w(e)?n[r]():e},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:pr(n).length -},r.some=B,r.sortedIndex=K,r.template=function(n,e,u){var o=r.templateSettings;n||(n=""),u=yr({},u,o);var i,f=yr({},u.imports,o.imports),o=pr(f),f=E(f),a=0,l=u.interpolate||ht,p="__p+='";n.replace(RegExp((u.escape||ht).source+"|"+l.source+"|"+(l===yt?gt:ht).source+"|"+(u.evaluate||ht).source+"|$","g"),function(t,r,e,u,o,f){return e||(e=u),p+=n.slice(a,f).replace(dt,c),r&&(p+="'+__e("+r+")+'"),o&&(i=J,p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),a=f+t.length,t}),p+="';\n",l=u=u.variable,l||(u="obj",p="with("+u+"){"+p+"}"),p=(i?p.replace(ct,""):p).replace(lt,"$1").replace(pt,"$1;"),p="function("+u+"){"+(l?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(l?"":",__d="+u+"."+u+"||"+u)+";")+p+"return __p}"; +},r.some=B,r.sortedIndex=K,r.template=function(n,e,u){var o=r.templateSettings;n||(n=""),u=yr({},u,o);var i,f=yr({},u.imports,o.imports),o=pr(f),f=E(f),a=0,l=u.interpolate||ht,p="__p+='";n.replace(RegExp((u.escape||ht).source+"|"+l.source+"|"+(l===yt?gt:ht).source+"|"+(u.evaluate||ht).source+"|$","g"),function(t,r,e,u,o,f){return e||(e=u),p+=n.slice(a,f).replace(dt,c),r&&(p+="'+__e("+r+")+'"),o&&(i=J,p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),a=f+t.length,t}),p+="';\n",l=u=u.variable,l||(u="obj",p="with("+u+"){"+p+"}"),p=(i?p.replace(ct,""):p).replace(lt,"$1").replace(pt,"$1;"),p="function("+u+"){"+(l?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+p+"return __p}"; try{var s=Function(o,"return "+p).apply(t,f)}catch(v){throw v.source=p,v}return e?s(e):(s.source=p,s)},r.unescape=function(n){return n==Q?"":(n+"").replace(at,g)},r.uniqueId=function(n){var t=++ut;return(n==Q?"":n+"")+t},r.all=N,r.any=B,r.detect=$,r.foldl=I,r.foldr=T,r.include=k,r.inject=I,cr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return At.apply(t,arguments),n.apply(r,t)})}),r.first=M,r.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=Q){var o=u; for(t=f(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==Q||r)return n[u-1];return v(n,Ft(0,u-e))}},r.take=M,r.head=M,cr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==Q||e&&typeof t!="function"?u:new r(u)})}),r.VERSION="1.0.0",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=H,r.prototype.valueOf=H,fr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),fr(["push","reverse","sort","unshift"],function(n){var t=rt[n]; r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),fr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments))}}),Ht&&fr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r diff --git a/dist/lodash.js b/dist/lodash.js index b2ce626d6b..3fb7ef6e17 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -4576,7 +4576,7 @@ (isEvaluating ? ', __j = Array.prototype.join;\n' + "function print() { __p += __j.call(arguments, '') }\n" - : (hasVariable ? '' : ', __d = ' + variable + '.' + variable + ' || ' + variable) + ';\n' + : ';\n' ) + source + 'return __p\n}'; diff --git a/dist/lodash.min.js b/dist/lodash.min.js index a7ea6ed129..019a5943b5 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -34,7 +34,7 @@ e(i)||o.push(i)}return o},e.wrap=function(n,t){return function(){var r=[n];retur },e.identity=V,e.indexOf=z,e.isArguments=h,e.isArray=Yt,e.isBoolean=function(n){return n===J||n===Q||jt.call(n)==kt},e.isDate=function(n){return n instanceof Date||jt.call(n)==qt},e.isElement=function(n){return n?1===n.nodeType:Q},e.isEmpty=function(n){var t=J;if(!n)return t;var r=jt.call(n),e=n.length;return r==Ft||r==It||r==$t||r==Tt&&typeof e=="number"&&j(n.splice)?!e:(Xt(n,function(){return t=Q}),t)},e.isEqual=b,e.isFinite=function(n){return At(n)&&!Ot(parseFloat(n))},e.isFunction=j,e.isNaN=function(n){return x(n)&&n!=+n },e.isNull=function(n){return n===L},e.isNumber=x,e.isObject=w,e.isPlainObject=r,e.isRegExp=function(n){return n instanceof RegExp||jt.call(n)==Bt},e.isString=A,e.isUndefined=function(n){return typeof n=="undefined"},e.lastIndexOf=function(n,t,r){var e=n?n.length:0;for(typeof r=="number"&&(e=(0>r?St(0,e+r):Nt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},e.mixin=G,e.noConflict=function(){return n._=et,this},e.random=function(n,t){return n==L&&t==L&&(t=1),n=+n||0,t==L&&(t=n,n=0),n+mt(Rt()*((+t||0)-n+1)) },e.reduce=D,e.reduceRight=T,e.result=function(n,r){var e=n?n[r]:t;return j(e)?n[r]():e},e.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Zt(n).length},e.some=B,e.sortedIndex=C,e.template=function(n,r,u){var o=e.templateSettings;n||(n=""),u=er({},u,o);var i,f=er({},u.imports,o.imports),o=Zt(f),f=E(f),a=0,c=u.interpolate||st,p="__p+='";n.replace(RegExp((u.escape||st).source+"|"+c.source+"|"+(c===pt?lt:st).source+"|"+(u.evaluate||st).source+"|$","g"),function(t,r,e,u,o,f){return e||(e=u),p+=n.slice(a,f).replace(gt,l),r&&(p+="'+__e("+r+")+'"),o&&(i=J,p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),a=f+t.length,t -}),p+="';\n",c=u=u.variable,c||(u="obj",p="with("+u+"){"+p+"}"),p=(i?p.replace(ot,""):p).replace(it,"$1").replace(ft,"$1;"),p="function("+u+"){"+(c?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(c?"":",__d="+u+"."+u+"||"+u)+";")+p+"return __p}";try{var s=Function(o,"return "+p).apply(t,f)}catch(v){throw v.source=p,v}return r?s(r):(s.source=p,s)},e.unescape=function(n){return n==L?"":(n+"").replace(ut,g)},e.uniqueId=function(n){var t=++nt; -return(n==L?"":n+"")+t},e.all=N,e.any=B,e.detect=$,e.foldl=D,e.foldr=T,e.include=S,e.inject=D,Xt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(){var t=[this.__wrapped__];return bt.apply(t,arguments),n.apply(e,t)})}),e.first=I,e.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=L){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==L||r)return n[u-1];return v(n,St(0,u-e))}},e.take=I,e.head=I,Xt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(t,r){var u=n(this.__wrapped__,t,r); +}),p+="';\n",c=u=u.variable,c||(u="obj",p="with("+u+"){"+p+"}"),p=(i?p.replace(ot,""):p).replace(it,"$1").replace(ft,"$1;"),p="function("+u+"){"+(c?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+p+"return __p}";try{var s=Function(o,"return "+p).apply(t,f)}catch(v){throw v.source=p,v}return r?s(r):(s.source=p,s)},e.unescape=function(n){return n==L?"":(n+"").replace(ut,g)},e.uniqueId=function(n){var t=++nt;return(n==L?"":n+"")+t +},e.all=N,e.any=B,e.detect=$,e.foldl=D,e.foldr=T,e.include=S,e.inject=D,Xt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(){var t=[this.__wrapped__];return bt.apply(t,arguments),n.apply(e,t)})}),e.first=I,e.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=L){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==L||r)return n[u-1];return v(n,St(0,u-e))}},e.take=I,e.head=I,Xt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(t,r){var u=n(this.__wrapped__,t,r); return t==L||r&&typeof t!="function"?u:new e(u)})}),e.VERSION="1.0.0",e.prototype.toString=function(){return this.__wrapped__+""},e.prototype.value=H,e.prototype.valueOf=H,Qt(["join","pop","shift"],function(n){var t=Y[n];e.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),Qt(["push","reverse","sort","unshift"],function(n){var t=Y[n];e.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Qt(["concat","slice","splice"],function(n){var t=Y[n];e.prototype[n]=function(){return new e(t.apply(this.__wrapped__,arguments)) }}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=e,define(function(){return e})):W?typeof module=="object"&&module&&module.exports==W?(module.exports=e)._=e:W._=e:n._=e})(this); \ No newline at end of file diff --git a/lodash.js b/lodash.js index fb491b484d..f393e64f6a 100644 --- a/lodash.js +++ b/lodash.js @@ -4733,7 +4733,7 @@ (isEvaluating ? ', __j = Array.prototype.join;\n' + "function print() { __p += __j.call(arguments, '') }\n" - : (hasVariable ? '' : ', __d = ' + variable + '.' + variable + ' || ' + variable) + ';\n' + : ';\n' ) + source + 'return __p\n}'; From 265dedfae1e50ad28506b7383005f91ea36b7724 Mon Sep 17 00:00:00 2001 From: Kit Cambridge Date: Thu, 14 Feb 2013 17:36:43 -0800 Subject: [PATCH 04/22] Fix typo that caused `sourceMappingURL` to be `undefined` in source map builds. Former-commit-id: ff3b22a7965c15a1ae072f8e9d51009e095ec443 --- build/minify.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/minify.js b/build/minify.js index becc7fca6e..79ad25c753 100755 --- a/build/minify.js +++ b/build/minify.js @@ -304,10 +304,10 @@ function closureCompile(source, mode, callback) { var filePath = this.filePath, isAdvanced = mode == 'advanced', + outputPath = this.outputPath, isMapped = this.isMapped, mapPath = getMapPath(outputPath), - options = closureOptions.slice(), - outputPath = this.outputPath; + options = closureOptions.slice(); // remove copyright header to make other modifications easier var license = (/^(?:\s*\/\/.*\s*|\s*\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/\s*)*/.exec(source) || [''])[0]; From a15a28fe5b26e64d7bd7f6c773c1440ab024e0f5 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 14 Feb 2013 20:47:23 -0800 Subject: [PATCH 05/22] Add `-p` and `--source-map` unit tests. Former-commit-id: c7416ca507ce9376adb31e91a294e2e40073788c --- test/test-build.js | 48 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/test/test-build.js b/test/test-build.js index 62f4d3ebd1..e7ece69954 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -537,7 +537,7 @@ commands.forEach(function(command) { var expectedId = /underscore/.test(command) ? 'underscore' : 'lodash'; - asyncTest('`lodash template=*.jst` exports=amd' + (command ? ' ' + command : ''), function() { + asyncTest('`lodash template=*.jst exports=amd' + (command ? ' ' + command : '') + '`', function() { var start = _.after(2, _.once(QUnit.start)); build(['-s', 'template=' + templatePath + '/*.jst', 'exports=amd'].concat(command || []), function(data) { @@ -562,7 +562,7 @@ }); }); - asyncTest('`lodash settings=...`' + (command ? ' ' + command : ''), function() { + asyncTest('`lodash settings=...' + (command ? ' ' + command : '') + '`', function() { var start = _.after(2, _.once(QUnit.start)); build(['-s', 'template=' + templatePath + '/*.tpl', 'settings={interpolate:/{{([\\s\\S]+?)}}/}'].concat(command || []), function(data) { @@ -640,6 +640,43 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('source maps'); + + (function() { + var commands = [ + '-p', + '--source-map' + ]; + + var outputPaths = [ + '', + '-o foo.js' + ]; + + commands.forEach(function(command) { + outputPaths.forEach(function(outputPath) { + asyncTest('`lodash ' + command + (outputPath ? ' ' + outputPath : '') + '`', function() { + var start = _.once(QUnit.start); + outputPath = outputPath ? outputPath.split(' ') : []; + + build(['-s', '-m', command].concat(outputPath), function(data) { + var basename = path.basename(data.outputPath, '.js'), + comment = (/(\s*\/\/.*\s*|\s*\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/\s*)$/.exec(data.source) || [])[0], + sourceMap = JSON.parse(data.sourceMap); + + ok(RegExp('/\\*\\n//@ sourceMappingURL=' + basename + '.map\\n\\*/').test(comment), basename); + equal(sourceMap.file, basename + '.js', basename); + deepEqual(sourceMap.sources, ['lodash.js'], basename); + + start(); + }); + }); + }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('strict modifier'); (function() { @@ -648,7 +685,12 @@ 'b': undefined }); - ['non-strict', 'strict'].forEach(function(strictMode, index) { + var modes = [ + 'non-strict', + 'strict' + ]; + + modes.forEach(function(strictMode, index) { asyncTest(strictMode + ' should ' + (index ? 'error': 'silently fail') + ' attempting to overwrite read-only properties', function() { var commands = ['-s', 'include=bindAll,defaults,extend'], start = _.after(2, _.once(QUnit.start)); From 7ea7a6cbb191adeacb0aaf3511b95d53241f52ca Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 15 Feb 2013 00:23:03 -0800 Subject: [PATCH 06/22] Automatically set a source map's "sources" key based on the build performed. Former-commit-id: c02c88dfd1db097a3f98113ee57c3da850da5abb --- build.js | 3 ++- test/test-build.js | 29 +++++++++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/build.js b/build.js index e38a3f1aa5..cd1cfe9a06 100755 --- a/build.js +++ b/build.js @@ -2414,9 +2414,10 @@ } else if (!isStdOut) { outputUsed = true; + filePath = outputPath || path.join(cwd, basename + '.js'); callback({ 'source': debugSource, - 'outputPath': outputPath || path.join(cwd, basename + '.js') + 'outputPath': filePath }); } } diff --git a/test/test-build.js b/test/test-build.js index e7ece69954..64a4dba3d6 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -643,33 +643,38 @@ QUnit.module('source maps'); (function() { - var commands = [ + var mapCommands = [ '-p', '--source-map' ]; - var outputPaths = [ + var outputCommands = [ '', - '-o foo.js' + '-o foo.js', + '-m -o bar.js' ]; - commands.forEach(function(command) { - outputPaths.forEach(function(outputPath) { - asyncTest('`lodash ' + command + (outputPath ? ' ' + outputPath : '') + '`', function() { - var start = _.once(QUnit.start); - outputPath = outputPath ? outputPath.split(' ') : []; - - build(['-s', '-m', command].concat(outputPath), function(data) { + mapCommands.forEach(function(mapCommand) { + outputCommands.forEach(function(outputCommand) { + asyncTest('`lodash ' + mapCommand + (outputCommand ? ' ' + outputCommand : '') + '`', function() { + var callback = _.once(function(data) { var basename = path.basename(data.outputPath, '.js'), comment = (/(\s*\/\/.*\s*|\s*\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/\s*)$/.exec(data.source) || [])[0], + sources = /foo.js/.test(outputCommand) ? ['foo.js'] : ['lodash' + (outputCommand.length ? '' : '.custom') + '.js'], sourceMap = JSON.parse(data.sourceMap); ok(RegExp('/\\*\\n//@ sourceMappingURL=' + basename + '.map\\n\\*/').test(comment), basename); equal(sourceMap.file, basename + '.js', basename); - deepEqual(sourceMap.sources, ['lodash.js'], basename); + deepEqual(sourceMap.sources, sources, basename); - start(); + QUnit.start(); }); + + outputCommand = outputCommand ? outputCommand.split(' ') : []; + if (outputCommand.indexOf('-m') < 0) { + callback = _.after(2, callback); + } + build(['-s', mapCommand].concat(outputCommand), callback); }); }); }); From 02687f3c785f360add7b29ed59de5dbb912b9c08 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 15 Feb 2013 08:11:19 -0800 Subject: [PATCH 07/22] Ensure the second argument passed to `_.assign` is not treated as a `callback`. [closes #184] Former-commit-id: 1254e11ab02d1d5055c08400cd0a4786ed71aef2 --- dist/lodash.compat.js | 20 ++++++++------------ dist/lodash.compat.min.js | 4 ++-- dist/lodash.js | 20 ++++++++------------ dist/lodash.min.js | 4 ++-- lodash.js | 20 ++++++++------------ test/test.js | 5 ++++- 6 files changed, 32 insertions(+), 41 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 98a0540fdc..e51695b8b8 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -1053,12 +1053,10 @@ 'top': defaultsIteratorOptions.top.replace(';', ';\n' + - 'if (argsLength > 2) {\n' + - " if (typeof args[argsLength - 2] == 'function') {\n" + - ' var callback = createCallback(args[--argsLength - 1], args[argsLength--], 2);\n' + - " } else if (typeof args[argsLength - 1] == 'function') {\n" + - ' callback = args[--argsLength];\n' + - ' }\n' + + "if (argsLength > 3 && typeof args[argsLength - 2] == 'function') {\n" + + ' var callback = createCallback(args[--argsLength - 1], args[argsLength--], 2);\n' + + "} else if (argsLength > 2 && typeof args[argsLength - 1] == 'function') {\n" + + ' callback = args[--argsLength];\n' + '}' ), 'loop': 'result[index] = callback ? callback(result[index], iterable[index]) : iterable[index]' @@ -1915,12 +1913,10 @@ if (typeof deepIndicator != 'number') { length = args.length; } - if (length > 2) { - if (typeof args[length - 2] == 'function') { - callback = createCallback(args[--length - 1], args[length--], 2); - } else if (typeof args[length - 1] == 'function') { - callback = args[--length]; - } + if (length > 3 && typeof args[length - 2] == 'function') { + callback = createCallback(args[--length - 1], args[length--], 2); + } else if (length > 2 && typeof args[length - 1] == 'function') { + callback = args[--length]; } } while (++index < length) { diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index a65967e617..7a31104457 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -12,7 +12,7 @@ var r=n.constructor;return!w(r)&&(!Yt||!p(n))||r instanceof r?tt?(ar(n,function( switch(u=tr[l],l){case Bt:case Mt:return c?a:new u(+a);case Pt:case Kt:return c?a:new u(a);case Ct:return c?a:u(a.source,st.exec(a))}for(o||(o=[]),i||(i=[]),l=o.length;l--;)if(o[l]==n)return i[l];return c||(a=s?u(a.length):{},s&&(Ot.call(n,"index")&&(a.index=n.index),Ot.call(n,"input")&&(a.input=n.input))),o.push(n),i.push(a),(s?F:cr)(c?a:n,function(n,u){a[u]=d(n,r,e,t,o,i)}),a}function _(n){var t=[];return ar(n,function(n,r){w(n)&&t.push(r)}),t.sort()}function b(n){for(var t=-1,r=pr(n),e=r.length,u={};++tr?Ft(0,u+r):r)||0,typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):z(n,t,r)):fr(n,function(n){return++eo&&(o=a)}}else t=!t&&A(n)?u:f(t,r),fr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t,r,e){var u=3>arguments.length;if(t=f(t,e,4),lr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++o>>1,r(n[e])/g,ht=/($^)/,mt=/[&<>"']/g,dt=/['\n\r\t\u2028\u2029\\]/g,_t="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),bt=Math.ceil,jt=rt.concat,wt=Math.floor,xt=vt.test(xt=Object.getPrototypeOf)&&xt,Ot=et.hasOwnProperty,At=rt.push,St=et.toString,Et=vt.test(Et=v.bind)&&Et,kt=vt.test(kt=Array.isArray)&&kt,Nt=n.isFinite,Rt=n.isNaN,$t=vt.test($t=Object.keys)&&$t,Ft=Math.max,qt=Math.min,Dt=Math.random,It="[object Arguments]",Tt="[object Array]",Bt="[object Boolean]",Mt="[object Date]",Pt="[object Number]",zt="[object Object]",Ct="[object RegExp]",Kt="[object String]",Lt=!!n.attachEvent,Ut=Et&&!/\n|true/.test(Et+Lt),Vt=Et&&!Ut,Gt=$t&&(Lt||Ut),Ht=(Ht={0:1,length:1},rt.splice.call(Ht,0,1),Ht[0]),Jt=J; (function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Jt=!r;Z=!/valueOf/.test(t),nt=n.propertyIsEnumerable("prototype"),tt="x"!=t[0]})(1);var Qt=arguments.constructor==Object,Wt=!y(arguments),Xt="xx"!="x"[0]+Object("x")[0];try{var Yt=St.call(document)==zt&&!({toString:0}+"")}catch(Zt){}var nr={"[object Function]":W};nr[It]=nr[Tt]=nr[Bt]=nr[Mt]=nr[Pt]=nr[zt]=nr[Ct]=nr[Kt]=J;var tr={};tr[Tt]=Array,tr[Bt]=Boolean,tr[Mt]=Date,tr[zt]=Object,tr[Pt]=Number,tr[Ct]=RegExp,tr[Kt]=String; var rr={"boolean":W,"function":J,object:J,number:W,string:W,undefined:W},er={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:yt,variable:"",imports:{_:r}};var ur={a:"q,w,h",l:"var a=arguments,b=0,c=typeof h=='number'?2:a.length;while(++b":">",'"':""","'":"'"},vr=b(sr),gr=a(ur,{l:ur.l.replace(";",";if(c>2){if(typeof a[c-2]=='function'){var d=f(a[--c-1],a[c--],2);}else if(typeof a[c-1]=='function'){d=a[--c];}}"),h:"u[j]=d?d(u[j],n[j]):n[j]"}),yr=a(ur); +Wt&&(y=function(n){return n?Ot.call(n,"callee"):W});var ar=a(or,ir,{m:W}),cr=a(or,ir),lr=kt||function(n){return Qt&&n instanceof Array||St.call(n)==Tt},pr=$t?function(n){return x(n)?nt&&typeof n=="function"||Jt&&n.length&&y(n)?m(n):$t(n):[]}:m,sr={"&":"&","<":"<",">":">",'"':""","'":"'"},vr=b(sr),gr=a(ur,{l:ur.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=f(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[j]=d?d(u[j],n[j]):n[j]"}),yr=a(ur); w(/x/)&&(w=function(n){return n instanceof Function||"[object Function]"==St.call(n)});var hr=xt?function(n){if(!n||typeof n!="object")return W;var t=n.valueOf,r=typeof t=="function"&&(r=xt(t))&&xt(r);return r?n==r||xt(n)==r&&!y(n):h(n)}:h,mr=q,dr=R;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},r.assign=gr,r.at=function(n){var t=-1,r=jt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(Xt&&A(n)&&(n=n.split(""));++t 2) {\n' + - " if (typeof args[argsLength - 2] == 'function') {\n" + - ' var callback = createCallback(args[--argsLength - 1], args[argsLength--], 2);\n' + - " } else if (typeof args[argsLength - 1] == 'function') {\n" + - ' callback = args[--argsLength];\n' + - ' }\n' + + "if (argsLength > 3 && typeof args[argsLength - 2] == 'function') {\n" + + ' var callback = createCallback(args[--argsLength - 1], args[argsLength--], 2);\n' + + "} else if (argsLength > 2 && typeof args[argsLength - 1] == 'function') {\n" + + ' callback = args[--argsLength];\n' + '}' ), 'loop': 'result[index] = callback ? callback(result[index], iterable[index]) : iterable[index]' @@ -1772,12 +1770,10 @@ if (typeof deepIndicator != 'number') { length = args.length; } - if (length > 2) { - if (typeof args[length - 2] == 'function') { - callback = createCallback(args[--length - 1], args[length--], 2); - } else if (typeof args[length - 1] == 'function') { - callback = args[--length]; - } + if (length > 3 && typeof args[length - 2] == 'function') { + callback = createCallback(args[--length - 1], args[length--], 2); + } else if (length > 2 && typeof args[length - 1] == 'function') { + callback = args[--length]; } } while (++index < length) { diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 019a5943b5..dbff0cc1eb 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -12,7 +12,7 @@ return n=t.a,t.d=/^[^,]+/.exec(n)[0],r="var j,n="+t.d+",u=n;if(!n)return u;"+t.l }if(!u||!r)return u&&!c?p?v(f):rr({},f):f;switch(u=Ut[l],l){case kt:case qt:return c?f:new u(+f);case Dt:case It:return c?f:new u(f);case Bt:return c?f:u(f.source,at.exec(f))}for(o||(o=[]),i||(i=[]),l=o.length;l--;)if(o[l]==n)return i[l];return c||(f=p?u(f.length):{},p&&(_t.call(n,"index")&&(f.index=n.index),_t.call(n,"input")&&(f.input=n.input))),o.push(n),i.push(f),(p?F:Xt)(c?f:n,function(n,u){f[u]=m(n,r,e,t,o,i)}),f}function d(n){var t=[];return Wt(n,function(n,r){j(n)&&t.push(r)}),t.sort()}function _(n){for(var t=-1,r=Zt(n),e=r.length,u={};++tr?St(0,u+r):r)||0,typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):z(n,t,r)):Qt(n,function(n){return++eu&&(u=f)}}else t=!t&&A(n)?o:a(t,r),Qt(n,function(n,r,o){r=t(n,r,o),r>e&&(e=r,u=n)});return u}function D(n,t,r,e){var u=3>arguments.length;if(t=a(t,e,4),Yt(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++o>>1,r(n[e])z(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function U(n,t){return Pt||wt&&2/g,st=/($^)/,vt=/[&<>"']/g,gt=/['\n\r\t\u2028\u2029\\]/g,ht=Math.ceil,yt=Y.concat,mt=Math.floor,dt=ct.test(dt=Object.getPrototypeOf)&&dt,_t=Z.hasOwnProperty,bt=Y.push,jt=Z.toString,wt=ct.test(wt=v.bind)&&wt,xt=ct.test(xt=Array.isArray)&&xt,At=n.isFinite,Ot=n.isNaN,Et=ct.test(Et=Object.keys)&&Et,St=Math.max,Nt=Math.min,Rt=Math.random,$t="[object Arguments]",Ft="[object Array]",kt="[object Boolean]",qt="[object Date]",Dt="[object Number]",Tt="[object Object]",Bt="[object RegExp]",It="[object String]",Mt=!!n.attachEvent,zt=wt&&!/\n|true/.test(wt+Mt),Pt=wt&&!zt,Ct=Et&&(Mt||zt),Kt={"[object Function]":Q}; Kt[$t]=Kt[Ft]=Kt[kt]=Kt[qt]=Kt[Dt]=Kt[Tt]=Kt[Bt]=Kt[It]=J;var Ut={};Ut[Ft]=Array,Ut[kt]=Boolean,Ut[qt]=Date,Ut[Tt]=Object,Ut[Dt]=Number,Ut[Bt]=RegExp,Ut[It]=String;var Vt={"boolean":Q,"function":J,object:J,number:Q,string:Q,undefined:Q},Gt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};e.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:pt,variable:"",imports:{_:e}};var Ht={a:"q,w,h",l:"var a=arguments,b=0,c=typeof h=='number'?2:a.length;while(++b":">",'"':""","'":"'"},tr=_(nr),rr=c(Ht,{l:Ht.l.replace(";",";if(c>2){if(typeof a[c-2]=='function'){var d=f(a[--c-1],a[c--],2);}else if(typeof a[c-1]=='function'){d=a[--c];}}"),h:"u[j]=d?d(u[j],n[j]):n[j]"}),er=c(Ht);j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==jt.call(n)}),e.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},e.assign=rr,e.at=function(n){for(var t=-1,r=yt.apply(Y,v(arguments,1)),e=r.length,u=Array(e);++t":">",'"':""","'":"'"},tr=_(nr),rr=c(Ht,{l:Ht.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=f(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[j]=d?d(u[j],n[j]):n[j]"}),er=c(Ht);j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==jt.call(n)}),e.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},e.assign=rr,e.at=function(n){for(var t=-1,r=yt.apply(Y,v(arguments,1)),e=r.length,u=Array(e);++t 2) {\n' + - " if (typeof args[argsLength - 2] == 'function') {\n" + - ' var callback = createCallback(args[--argsLength - 1], args[argsLength--], 2);\n' + - " } else if (typeof args[argsLength - 1] == 'function') {\n" + - ' callback = args[--argsLength];\n' + - ' }\n' + + "if (argsLength > 3 && typeof args[argsLength - 2] == 'function') {\n" + + ' var callback = createCallback(args[--argsLength - 1], args[argsLength--], 2);\n' + + "} else if (argsLength > 2 && typeof args[argsLength - 1] == 'function') {\n" + + ' callback = args[--argsLength];\n' + '}' ), 'loop': 'result[index] = callback ? callback(result[index], iterable[index]) : iterable[index]' @@ -1922,12 +1920,10 @@ if (typeof deepIndicator != 'number') { length = args.length; } - if (length > 2) { - if (typeof args[length - 2] == 'function') { - callback = createCallback(args[--length - 1], args[length--], 2); - } else if (typeof args[length - 1] == 'function') { - callback = args[--length]; - } + if (length > 3 && typeof args[length - 2] == 'function') { + callback = createCallback(args[--length - 1], args[length--], 2); + } else if (length > 2 && typeof args[length - 1] == 'function') { + callback = args[--length]; } } while (++index < length) { diff --git a/test/test.js b/test/test.js index 9a8164deb1..f9422353cb 100644 --- a/test/test.js +++ b/test/test.js @@ -952,12 +952,15 @@ deepEqual(actual, { 'a': 2 }); }); - test('lodash.' + methodName + ' should not treat a function as a `callback` if less than two arguments are passed', function() { + test('lodash.' + methodName + ' should not treat the second argument as a `callback`', function() { function callback() {} callback.b = 2; var actual = func({ 'a': 1 }, callback); deepEqual(actual, { 'a': 1, 'b': 2 }); + + actual = func({ 'a': 1 }, callback, { 'c': 3 }); + deepEqual(actual, { 'a': 1, 'b': 2, 'c': 3 }); }); }); From 9ccfa5cec9244580403d4a791de3a5efaab36ad0 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 15 Feb 2013 08:58:20 -0800 Subject: [PATCH 08/22] Convert map files via `JSON.parse` instead of using string manipulation in minify.js. Former-commit-id: 185b77d45995f17c586f35d6ad447074d677a6ae --- build/minify.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/build/minify.js b/build/minify.js index 79ad25c753..81e4d295dd 100755 --- a/build/minify.js +++ b/build/minify.js @@ -369,13 +369,12 @@ if (isMapped) { var mapOutput = fs.readFileSync(mapPath, 'utf8'); fs.unlinkSync(mapPath); + output = output.replace(/[\s;]*$/, '\n/*\n//@ sourceMappingURL=' + path.basename(mapPath)) + '\n*/'; - output = output - .replace(/[\s;]*$/, '\n/*\n//@ sourceMappingURL=' + path.basename(mapPath)) + '\n*/'; - - mapOutput = mapOutput - .replace(/("file":)""/, '$1"' + path.basename(outputPath) + '"') - .replace(/("sources":)\["stdin"\]/, '$1["' + path.basename(filePath) + '"]'); + mapOutput = JSON.parse(mapOutput); + mapOutput.file = path.basename(outputPath); + mapOutput.sources = [path.basename(filePath)]; + mapOutput = JSON.stringify(mapOutput, null, 2); } callback(exception, output, mapOutput); }); From 2a2bc44f43507e4aaa49cedfcfb2e0139216c079 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 16 Feb 2013 00:39:45 -0800 Subject: [PATCH 09/22] Make `_.where` search arrays for values. Former-commit-id: b942c6a44680c78fae1a41f2cf994be09ffcfbb9 --- dist/lodash.compat.js | 25 +++-- dist/lodash.compat.min.js | 6 +- dist/lodash.js | 25 +++-- dist/lodash.min.js | 46 +++++----- doc/README.md | 186 +++++++++++++++++++------------------- lodash.js | 25 +++-- test/test.js | 8 ++ 7 files changed, 181 insertions(+), 140 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index e51695b8b8..7029cce357 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -1561,16 +1561,27 @@ // recursively compare objects and arrays (susceptible to call stack limits) if (isArr) { - // compare lengths to determine if a deep comparison is necessary + length = a.length; size = b.length; - result = whereIndicator || size == a.length; - if (result) { - // deep compare the contents, ignoring non-numeric properties - while (size--) { - if (!(result = isEqual(a[size], b[size], callback, thisArg, stackA, stackB))) { - break; + // compare lengths to determine if a deep comparison is necessary + result = size == a.length; + if (!result && !whereIndicator) { + return result; + } + // deep compare the contents, ignoring non-numeric properties + while (size--) { + var index = length, + value = b[size]; + + if (whereIndicator) { + while (index--) { + if ((result = isEqual(a[index], value, callback, thisArg, stackA, stackB))) { + break; + } } + } else if (!(result = isEqual(a[size], value, callback, thisArg, stackA, stackB))) { + break; } } return result; diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 7a31104457..92fe0f40a1 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -11,9 +11,9 @@ return(t.b||t.i)&&(r+="}"),r+=t.c+";return u",Function("f,i,k,l,m,r,p","return f var r=n.constructor;return!w(r)&&(!Yt||!p(n))||r instanceof r?tt?(ar(n,function(n,r,e){return t=!Ot.call(e,r),W}),t===W):(ar(n,function(n,r){t=r}),t===W||Ot.call(n,t)):t}function m(n){var t=[];return cr(n,function(n,r){t.push(r)}),t}function d(n,r,e,u,o,i){var a=n;if(typeof r=="function"&&(u=e,e=r,r=W),typeof e=="function"){e=typeof u=="undefined"?e:f(e,u,1);var a=e(a),c=typeof a!="undefined";c||(a=n)}if(u=x(a)){var l=St.call(a);if(!nr[l]||Yt&&p(a))return a;var s=lr(a)}if(!u||!r)return u&&!c?s?v(a):gr({},a):a; switch(u=tr[l],l){case Bt:case Mt:return c?a:new u(+a);case Pt:case Kt:return c?a:new u(a);case Ct:return c?a:u(a.source,st.exec(a))}for(o||(o=[]),i||(i=[]),l=o.length;l--;)if(o[l]==n)return i[l];return c||(a=s?u(a.length):{},s&&(Ot.call(n,"index")&&(a.index=n.index),Ot.call(n,"input")&&(a.input=n.input))),o.push(n),i.push(a),(s?F:cr)(c?a:n,function(n,u){a[u]=d(n,r,e,t,o,i)}),a}function _(n){var t=[];return ar(n,function(n,r){w(n)&&t.push(r)}),t.sort()}function b(n){for(var t=-1,r=pr(n),e=r.length,u={};++tr?Ft(0,u+r):r)||0,typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):z(n,t,r)):fr(n,function(n){return++er?Ft(0,u+r):r)||0,typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):z(n,t,r)):fr(n,function(n){return++eo&&(o=a)}}else t=!t&&A(n)?u:f(t,r),fr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t,r,e){var u=3>arguments.length;if(t=f(t,e,4),lr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var a=pr(n),o=a.length;else Xt&&A(n)&&(u=n.split(""));return t=f(t,e,4),F(n,function(n,e,f){e=a?a[--o]:--o,r=i?(i=W,u[e]):t(r,u[e],e,f)}),r}function B(n,t,r){var e;if(t=f(t,r),lr(n)){r=-1;for(var u=n.length;++rt||typeof n=="undefined")return 1;if(nr?0:r);++er?St(0,u+r):r)||0,typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):z(n,t,r)):Qt(n,function(n){return++eu&&(u=f)}}else t=!t&&A(n)?o:a(t,r),Qt(n,function(n,r,o){r=t(n,r,o),r>e&&(e=r,u=n)});return u}function D(n,t,r,e){var u=3>arguments.length;if(t=a(t,e,4),Yt(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof u!="number")var i=Zt(n),u=i.length;return t=a(t,e,4),F(n,function(e,f,a){f=i?i[--u]:--u,r=o?(o=Q,n[f]):t(r,n[f],f,a)}),r}function B(n,t,r){var e;if(t=a(t,r),Yt(n)){r=-1;for(var u=n.length;++rr?St(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])z(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function U(n,t){return Pt||wt&&2/g,st=/($^)/,vt=/[&<>"']/g,gt=/['\n\r\t\u2028\u2029\\]/g,ht=Math.ceil,yt=Y.concat,mt=Math.floor,dt=ct.test(dt=Object.getPrototypeOf)&&dt,_t=Z.hasOwnProperty,bt=Y.push,jt=Z.toString,wt=ct.test(wt=v.bind)&&wt,xt=ct.test(xt=Array.isArray)&&xt,At=n.isFinite,Ot=n.isNaN,Et=ct.test(Et=Object.keys)&&Et,St=Math.max,Nt=Math.min,Rt=Math.random,$t="[object Arguments]",Ft="[object Array]",kt="[object Boolean]",qt="[object Date]",Dt="[object Number]",Tt="[object Object]",Bt="[object RegExp]",It="[object String]",Mt=!!n.attachEvent,zt=wt&&!/\n|true/.test(wt+Mt),Pt=wt&&!zt,Ct=Et&&(Mt||zt),Kt={"[object Function]":Q}; -Kt[$t]=Kt[Ft]=Kt[kt]=Kt[qt]=Kt[Dt]=Kt[Tt]=Kt[Bt]=Kt[It]=J;var Ut={};Ut[Ft]=Array,Ut[kt]=Boolean,Ut[qt]=Date,Ut[Tt]=Object,Ut[Dt]=Number,Ut[Bt]=RegExp,Ut[It]=String;var Vt={"boolean":Q,"function":J,object:J,number:Q,string:Q,undefined:Q},Gt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};e.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:pt,variable:"",imports:{_:e}};var Ht={a:"q,w,h",l:"var a=arguments,b=0,c=typeof h=='number'?2:a.length;while(++br?0:r);++er?St(0,u+r):r)||0,typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):z(n,t,r)):Qt(n,function(n){return++eu&&(u=f)}}else t=!t&&A(n)?o:a(t,r),Qt(n,function(n,r,o){r=t(n,r,o),r>e&&(e=r,u=n)});return u}function D(n,t,r,e){var u=3>arguments.length;if(t=a(t,e,4),Yt(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof u!="number")var i=Zt(n),u=i.length;return t=a(t,e,4),$(n,function(e,f,a){f=i?i[--u]:--u,r=o?(o=Q,n[f]):t(r,n[f],f,a)}),r}function B(n,t,r){var e;if(t=a(t,r),Yt(n)){r=-1;for(var u=n.length;++rr?St(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])z(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function U(n,t){return Pt||wt&&2/g,st=/($^)/,vt=/[&<>"']/g,gt=/['\n\r\t\u2028\u2029\\]/g,ht=Math.ceil,yt=Y.concat,mt=Math.floor,dt=ct.test(dt=Object.getPrototypeOf)&&dt,_t=Z.hasOwnProperty,bt=Y.push,jt=Z.toString,wt=ct.test(wt=v.bind)&&wt,xt=ct.test(xt=Array.isArray)&&xt,At=n.isFinite,Ot=n.isNaN,Et=ct.test(Et=Object.keys)&&Et,St=Math.max,kt=Math.min,Nt=Math.random,Rt="[object Arguments]",$t="[object Array]",Ft="[object Boolean]",qt="[object Date]",Dt="[object Number]",Tt="[object Object]",Bt="[object RegExp]",It="[object String]",Mt=!!n.attachEvent,zt=wt&&!/\n|true/.test(wt+Mt),Pt=wt&&!zt,Ct=Et&&(Mt||zt),Kt={"[object Function]":Q}; +Kt[Rt]=Kt[$t]=Kt[Ft]=Kt[qt]=Kt[Dt]=Kt[Tt]=Kt[Bt]=Kt[It]=J;var Ut={};Ut[$t]=Array,Ut[Ft]=Boolean,Ut[qt]=Date,Ut[Tt]=Object,Ut[Dt]=Number,Ut[Bt]=RegExp,Ut[It]=String;var Vt={"boolean":Q,"function":J,object:J,number:Q,string:Q,undefined:Q},Gt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};e.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:pt,variable:"",imports:{_:e}};var Ht={a:"q,w,h",l:"var a=arguments,b=0,c=typeof h=='number'?2:a.length;while(++b":">",'"':""","'":"'"},tr=_(nr),rr=c(Ht,{l:Ht.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=f(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[j]=d?d(u[j],n[j]):n[j]"}),er=c(Ht);j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==jt.call(n)}),e.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},e.assign=rr,e.at=function(n){for(var t=-1,r=yt.apply(Y,v(arguments,1)),e=r.length,u=Array(e);++tz(c,l)){f&&c.push(l);for(var s=r;--s;)if(!(e[s]||(e[s]=u(t[s],0,100)))(l))continue n;a.push(l)}}return a},e.invert=_,e.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return F(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},e.keys=Zt,e.map=k,e.max=q,e.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return _t.call(r,e)?r[e]:r[e]=n.apply(this,arguments) +}return o},e.filter=N,e.flatten=M,e.forEach=$,e.forIn=Wt,e.forOwn=Xt,e.functions=d,e.groupBy=function(n,t,r){var e={};return t=a(t,r),$(n,function(n,r,u){r=t(n,r,u)+"",(_t.call(e,r)?e[r]:e[r]=[]).push(n)}),e},e.initial=function(n,t,r){if(!n)return[];var e=0,u=n.length;if(typeof t!="number"&&t!=L){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else e=t==L||r?1:t||e;return v(n,0,kt(St(0,u-e),u))},e.intersection=function(n){var t=arguments,r=t.length,e={0:{}},o=-1,i=n?n.length:0,f=100<=i,a=[],c=a;n:for(;++oz(c,l)){f&&c.push(l);for(var s=r;--s;)if(!(e[s]||(e[s]=u(t[s],0,100)))(l))continue n;a.push(l)}}return a},e.invert=_,e.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return $(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},e.keys=Zt,e.map=F,e.max=q,e.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return _t.call(r,e)?r[e]:r[e]=n.apply(this,arguments) }},e.merge=O,e.min=function(n,t,r){var e=1/0,u=e;if(!t&&Yt(n)){r=-1;for(var i=n.length;++rz(o,r,1))&&(u[r]=n)}),u},e.once=function(n){var t,r; -return function(){return t?r:(t=J,r=n.apply(this,arguments),n=L,r)}},e.pairs=function(n){for(var t=-1,r=Zt(n),e=r.length,u=Array(e);++tr?St(0,e+r):Nt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},e.mixin=G,e.noConflict=function(){return n._=et,this},e.random=function(n,t){return n==L&&t==L&&(t=1),n=+n||0,t==L&&(t=n,n=0),n+mt(Rt()*((+t||0)-n+1)) +return function(){return t?r:(t=J,r=n.apply(this,arguments),n=L,r)}},e.pairs=function(n){for(var t=-1,r=Zt(n),e=r.length,u=Array(e);++tr?St(0,e+r):kt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},e.mixin=G,e.noConflict=function(){return n._=et,this},e.random=function(n,t){return n==L&&t==L&&(t=1),n=+n||0,t==L&&(t=n,n=0),n+mt(Nt()*((+t||0)-n+1)) },e.reduce=D,e.reduceRight=T,e.result=function(n,r){var e=n?n[r]:t;return j(e)?n[r]():e},e.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Zt(n).length},e.some=B,e.sortedIndex=C,e.template=function(n,r,u){var o=e.templateSettings;n||(n=""),u=er({},u,o);var i,f=er({},u.imports,o.imports),o=Zt(f),f=E(f),a=0,c=u.interpolate||st,p="__p+='";n.replace(RegExp((u.escape||st).source+"|"+c.source+"|"+(c===pt?lt:st).source+"|"+(u.evaluate||st).source+"|$","g"),function(t,r,e,u,o,f){return e||(e=u),p+=n.slice(a,f).replace(gt,l),r&&(p+="'+__e("+r+")+'"),o&&(i=J,p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),a=f+t.length,t }),p+="';\n",c=u=u.variable,c||(u="obj",p="with("+u+"){"+p+"}"),p=(i?p.replace(ot,""):p).replace(it,"$1").replace(ft,"$1;"),p="function("+u+"){"+(c?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+p+"return __p}";try{var s=Function(o,"return "+p).apply(t,f)}catch(v){throw v.source=p,v}return r?s(r):(s.source=p,s)},e.unescape=function(n){return n==L?"":(n+"").replace(ut,g)},e.uniqueId=function(n){var t=++nt;return(n==L?"":n+"")+t -},e.all=N,e.any=B,e.detect=$,e.foldl=D,e.foldr=T,e.include=S,e.inject=D,Xt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(){var t=[this.__wrapped__];return bt.apply(t,arguments),n.apply(e,t)})}),e.first=I,e.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=L){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==L||r)return n[u-1];return v(n,St(0,u-e))}},e.take=I,e.head=I,Xt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(t,r){var u=n(this.__wrapped__,t,r); +},e.all=k,e.any=B,e.detect=R,e.foldl=D,e.foldr=T,e.include=S,e.inject=D,Xt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(){var t=[this.__wrapped__];return bt.apply(t,arguments),n.apply(e,t)})}),e.first=I,e.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=L){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==L||r)return n[u-1];return v(n,St(0,u-e))}},e.take=I,e.head=I,Xt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(t,r){var u=n(this.__wrapped__,t,r); return t==L||r&&typeof t!="function"?u:new e(u)})}),e.VERSION="1.0.0",e.prototype.toString=function(){return this.__wrapped__+""},e.prototype.value=H,e.prototype.valueOf=H,Qt(["join","pop","shift"],function(n){var t=Y[n];e.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),Qt(["push","reverse","sort","unshift"],function(n){var t=Y[n];e.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Qt(["concat","slice","splice"],function(n){var t=Y[n];e.prototype[n]=function(){return new e(t.apply(this.__wrapped__,arguments)) }}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=e,define(function(){return e})):W?typeof module=="object"&&module&&module.exports==W?(module.exports=e)._=e:W._=e:n._=e})(this); \ No newline at end of file diff --git a/doc/README.md b/doc/README.md index 26a825054d..5176250d2f 100644 --- a/doc/README.md +++ b/doc/README.md @@ -197,7 +197,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3156 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3163 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -221,7 +221,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3186 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3193 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -246,7 +246,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3258 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3265 "View in source") [Ⓣ][1] Gets the first element of the `array`. If a number `n` is passed, the first `n` elements of the `array` are returned. If a `callback` function is passed, the first elements the `callback` returns truthy for are returned. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -306,7 +306,7 @@ _.first(food, { 'type': 'fruit' }); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3297 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3304 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -334,7 +334,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3339 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3346 "View in source") [Ⓣ][1] Gets the index at which the first occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `fromIndex` will run a faster binary search. @@ -366,7 +366,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3413 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3420 "View in source") [Ⓣ][1] Gets all but the last element of `array`. If a number `n` is passed, the last `n` elements are excluded from the result. If a `callback` function is passed, the last elements the `callback` returns truthy for are excluded from the result. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -423,7 +423,7 @@ _.initial(food, { 'type': 'vegetable' }); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3447 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3454 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -447,7 +447,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3538 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3545 "View in source") [Ⓣ][1] Gets the last element of the `array`. If a number `n` is passed, the last `n` elements of the `array` are returned. If a `callback` function is passed, the last elements the `callback` returns truthy for are returned. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -504,7 +504,7 @@ _.last(food, { 'type': 'vegetable' }); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3579 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3586 "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. @@ -533,7 +533,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3609 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3616 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -558,7 +558,7 @@ _.object(['moe', 'larry'], [30, 40]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3653 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3660 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. @@ -596,7 +596,7 @@ _.range(0); ### `_.rest(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3731 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3738 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. If a number `n` is passed, the first `n` values are excluded from the result. If a `callback` function is passed, the first elements the `callback` returns truthy for are excluded from the result. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -656,7 +656,7 @@ _.rest(food, { 'type': 'fruit' }); ### `_.sortedIndex(array, value [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3795 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3802 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. @@ -705,7 +705,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3827 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3834 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -729,7 +729,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3874 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3881 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -776,7 +776,7 @@ _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3933 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3940 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -801,7 +801,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3964 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3971 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -861,7 +861,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4860 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4867 "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. @@ -891,7 +891,7 @@ _([1, 2, 3, 4]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4877 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4884 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -912,7 +912,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4894 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4901 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -943,7 +943,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2157 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2164 "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. @@ -971,7 +971,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2199 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2206 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -1009,7 +1009,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2253 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2260 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of the `collection` through the given `callback`. The corresponding value of each key is the number of times the key was returned by the `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1045,7 +1045,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2305 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2312 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1091,7 +1091,7 @@ _.every(stooges, { 'age': 50 }); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2366 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2373 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1137,7 +1137,7 @@ _.filter(food, { 'type': 'fruit' }); ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2433 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2440 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first that the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1185,7 +1185,7 @@ var healthy = _.find(food, 'organic'); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2468 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2475 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1217,7 +1217,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2518 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2525 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of the `collection` through the `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1254,7 +1254,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2551 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2558 "View in source") [Ⓣ][1] Invokes the method named by `methodName` on each element in the `collection`, returning an array of the results of each invoked method. Additional arguments will be passed to each invoked method. If `methodName` is a function, it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1283,7 +1283,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2603 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2610 "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)*. @@ -1328,7 +1328,7 @@ _.map(stooges, 'name'); ### `_.max(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2660 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2667 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1370,7 +1370,7 @@ _.max(stooges, 'age'); ### `_.min(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2729 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2736 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1412,7 +1412,7 @@ _.min(stooges, 'age'); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2779 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2786 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1442,7 +1442,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2811 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2818 "View in source") [Ⓣ][1] Reduces a `collection` to a value that is the accumulated result of running each element in the `collection` through the `callback`, where each successive `callback` execution consumes the return value of the previous execution. If `accumulator` is not passed, the first element of the `collection` will be used as the initial `accumulator` value. The `callback` is bound to `thisArg` and invoked with four arguments; *(accumulator, value, index|key, collection)*. @@ -1480,7 +1480,7 @@ var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2854 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2861 "View in source") [Ⓣ][1] This method is similar to `_.reduce`, except that it iterates over a `collection` from right to left. @@ -1511,7 +1511,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2914 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2921 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1554,7 +1554,7 @@ _.reject(food, { 'type': 'fruit' }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2935 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2942 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1578,7 +1578,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2968 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2975 "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. @@ -1608,7 +1608,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3015 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3022 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1654,7 +1654,7 @@ _.some(food, { 'type': 'meat' }); ### `_.sortBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3071 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3078 "View in source") [Ⓣ][1] Creates an array of elements, sorted in ascending order by the results of running each element in the `collection` through the `callback`. This method performs a stable sort, that is, it will preserve the original sort order of equal elements. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1691,7 +1691,7 @@ _.sortBy(['banana', 'strawberry', 'apple'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3106 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3113 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1715,7 +1715,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3138 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3145 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that have the given `properties`. When checking `properties`, this method performs a deep comparison between values to determine if they are equivalent to each other. @@ -1752,7 +1752,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3997 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4004 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1780,7 +1780,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4030 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4037 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1811,7 +1811,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4061 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4068 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. Method names may be specified as individual arguments or as arrays of method names. If no method names are provided, all the function properties of `object` will be bound. @@ -1842,7 +1842,7 @@ jQuery('#docs').on('click', view.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4107 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4114 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed to the bound function. This method differs from `_.bind` by allowing bound functions to reference methods that will be redefined or don't yet exist. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1883,7 +1883,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4130 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4137 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1910,7 +1910,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4163 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4170 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1936,7 +1936,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4227 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4234 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1961,7 +1961,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4207 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4214 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1988,7 +1988,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4251 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4258 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -2014,7 +2014,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4278 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4285 "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. @@ -2040,7 +2040,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4313 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4320 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `_.bind`, except it does **not** alter the `this` binding. @@ -2067,7 +2067,7 @@ hi('moe'); ### `_.partialRight(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4344 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4351 "View in source") [Ⓣ][1] This method is similar to `_.partial`, except that `partial` arguments are appended to those passed to the new function. @@ -2104,7 +2104,7 @@ options.imports ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4366 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4373 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -2129,7 +2129,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4419 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4426 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -2203,7 +2203,7 @@ defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.clone(value [, deep=false, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1116 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1114 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. If a `callback` function is passed, it will be executed to produce the cloned values. If `callback` returns `undefined`, cloning will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. @@ -2250,7 +2250,7 @@ clone.childNodes.length; ### `_.cloneDeep(value [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1241 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1239 "View in source") [Ⓣ][1] Creates a deep clone of `value`. If a `callback` function is passed, it will be executed to produce the cloned values. If `callback` returns the value it was passed, cloning will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. @@ -2296,7 +2296,7 @@ clone.node == view.node; ### `_.defaults(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1265 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1263 "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. @@ -2386,7 +2386,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1282 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1280 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2413,7 +2413,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1307 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1305 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2438,7 +2438,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1324 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1322 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2516,7 +2516,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1350 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1348 "View in source") [Ⓣ][1] Checks if `value` is a boolean value. @@ -2540,7 +2540,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1367 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1365 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2564,7 +2564,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1384 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1382 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2588,7 +2588,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1409 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1407 "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". @@ -2618,7 +2618,7 @@ _.isEmpty(''); ### `_.isEqual(a, b [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1468 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1466 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. If `callback` is passed, it will be executed to compare values. If `callback` returns `undefined`, comparisons will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with two arguments; *(a, b)*. @@ -2663,7 +2663,7 @@ _.isEqual(words, otherWords, function(a, b) { ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1638 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1647 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2701,7 +2701,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1655 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1664 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2725,7 +2725,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1718 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1727 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -2760,7 +2760,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1740 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1749 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2787,7 +2787,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1757 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1766 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2811,7 +2811,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1685 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1694 "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('')`)* @@ -2841,7 +2841,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1785 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1794 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2876,7 +2876,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1810 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1819 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2900,7 +2900,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1827 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1836 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -2924,7 +2924,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1844 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1853 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -2972,7 +2972,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1904 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1913 "View in source") [Ⓣ][1] Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the destination object. Subsequent sources will overwrite propery assignments of previous sources. If a `callback` function is passed, it will be executed to produce the merged values of the destination and source properties. If `callback` returns `undefined`, merging will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. @@ -3028,7 +3028,7 @@ _.merge(food, otherFood, function(a, b) { ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2013 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2020 "View in source") [Ⓣ][1] Creates a shallow clone of `object` excluding the specified properties. Property names may be specified as individual arguments or as arrays of property names. If a `callback` function is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -3059,7 +3059,7 @@ _.omit({ 'name': 'moe', 'age': 40 }, function(value) { ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2047 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2054 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -3083,7 +3083,7 @@ _.pairs({ 'moe': 30, 'larry': 40 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2085 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2092 "View in source") [Ⓣ][1] Creates a shallow clone of `object` composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. If `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -3114,7 +3114,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2122 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2129 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -3145,7 +3145,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4443 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4450 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -3169,7 +3169,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4461 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4468 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -3194,7 +3194,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4487 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4494 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -3224,7 +3224,7 @@ _('moe').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4511 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4518 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -3244,7 +3244,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4534 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4541 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -3272,7 +3272,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4572 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4579 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function, it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -3307,7 +3307,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4660 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4667 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -3391,7 +3391,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4786 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4793 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3423,7 +3423,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4812 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4819 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3447,7 +3447,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4832 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4839 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3500,7 +3500,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5062 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5069 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index 7e2190550a..03c6002cef 100644 --- a/lodash.js +++ b/lodash.js @@ -1568,16 +1568,27 @@ // recursively compare objects and arrays (susceptible to call stack limits) if (isArr) { - // compare lengths to determine if a deep comparison is necessary + length = a.length; size = b.length; - result = whereIndicator || size == a.length; - if (result) { - // deep compare the contents, ignoring non-numeric properties - while (size--) { - if (!(result = isEqual(a[size], b[size], callback, thisArg, stackA, stackB))) { - break; + // compare lengths to determine if a deep comparison is necessary + result = size == a.length; + if (!result && !whereIndicator) { + return result; + } + // deep compare the contents, ignoring non-numeric properties + while (size--) { + var index = length, + value = b[size]; + + if (whereIndicator) { + while (index--) { + if ((result = isEqual(a[index], value, callback, thisArg, stackA, stackB))) { + break; + } } + } else if (!(result = isEqual(a[size], value, callback, thisArg, stackA, stackB))) { + break; } } return result; diff --git a/test/test.js b/test/test.js index f9422353cb..39c4080ecd 100644 --- a/test/test.js +++ b/test/test.js @@ -2607,6 +2607,14 @@ deepEqual(_.where(collection, { 'a': { 'b': { 'c': 1 } } }), expected); }); + + test('should search of arrays for values', function() { + var collection = [{ 'a': [1, 2] }], + expected = _.cloneDeep(collection); + + deepEqual(_.where(collection, { 'a': [] }), []); + deepEqual(_.where(collection, { 'a': [2] }), expected); + }); }()); /*--------------------------------------------------------------------------*/ From 7eadf111456d1ba8587458e0c3e167ef7503d466 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 16 Feb 2013 23:17:17 -0800 Subject: [PATCH 10/22] Optimize the ES6 template delimiter regexp and regexp to detect strings. Former-commit-id: 6177f2b32f27515cf8edcac6036d0adb58ebfcd0 --- build.js | 2 +- build/pre-compile.js | 2 +- lodash.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.js b/build.js index cd1cfe9a06..c6f540df44 100755 --- a/build.js +++ b/build.js @@ -2413,8 +2413,8 @@ }); } else if (!isStdOut) { - outputUsed = true; filePath = outputPath || path.join(cwd, basename + '.js'); + outputUsed = true; callback({ 'source': debugSource, 'outputPath': filePath diff --git a/build/pre-compile.js b/build/pre-compile.js index 5db74035d5..020801c5dc 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -233,7 +233,7 @@ source = source.replace("result[length]['value']", 'result[length].value'); // remove whitespace from string literals - source = source.replace(/^([ "'\w]+:)? *"(?:(?=(\\?))\2.)*?"|'(?:(?=(\\?))\3.)*?'/gm, function(string, captured) { + source = source.replace(/^([ "'\w]+:)? *"[^"\\\n]*(?:\\.[^"\\\n]*)*"|'[^'\\\n]*(?:\\.[^'\\\n]*)*'/gm, function(string, captured) { // remove object literal property name if (/:$/.test(captured)) { string = string.slice(captured.length); diff --git a/lodash.js b/lodash.js index 03c6002cef..ba6dec4208 100644 --- a/lodash.js +++ b/lodash.js @@ -55,7 +55,7 @@ * Used to match ES6 template delimiters * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6 */ - var reEsTemplate = /\$\{((?:(?=\\?)\\?[\s\S])*?)\}/g; + var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; /** Used to match "interpolate" template delimiters */ var reInterpolate = /<%=([\s\S]+?)%>/g; From 9829a2f3b4f910d769018e9d048b1888efe0a760 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 16 Feb 2013 23:18:05 -0800 Subject: [PATCH 11/22] Rebuild files. Former-commit-id: c381088f55093f25067d0284319975c868e6e3bf --- dist/lodash.compat.js | 2 +- dist/lodash.compat.min.js | 2 +- dist/lodash.js | 2 +- dist/lodash.min.js | 2 +- dist/lodash.underscore.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 7029cce357..65af551075 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -56,7 +56,7 @@ * Used to match ES6 template delimiters * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6 */ - var reEsTemplate = /\$\{((?:(?=\\?)\\?[\s\S])*?)\}/g; + var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; /** Used to match "interpolate" template delimiters */ var reInterpolate = /<%=([\s\S]+?)%>/g; diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 92fe0f40a1..75159bc5b7 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -19,7 +19,7 @@ return n}function q(n,t,r){var e=-1,u=n?n.length:0,o=Array(typeof u=="number"?u: });return r}function T(n,t,r,e){var u=n,o=n?n.length:0,i=3>arguments.length;if(typeof o!="number")var a=pr(n),o=a.length;else Xt&&A(n)&&(u=n.split(""));return t=f(t,e,4),F(n,function(n,e,f){e=a?a[--o]:--o,r=i?(i=W,u[e]):t(r,u[e],e,f)}),r}function B(n,t,r){var e;if(t=f(t,r),lr(n)){r=-1;for(var u=n.length;++rr?Ft(0,u+r):r||0)-1;else if(r)return e=K(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])z(a,p))&&((r||c)&&a.push(p),i.push(e))}return i}function U(n,t){return Vt||Et&&2/g,ht=/($^)/,mt=/[&<>"']/g,dt=/['\n\r\t\u2028\u2029\\]/g,_t="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),bt=Math.ceil,jt=rt.concat,wt=Math.floor,xt=vt.test(xt=Object.getPrototypeOf)&&xt,Ot=et.hasOwnProperty,At=rt.push,St=et.toString,Et=vt.test(Et=v.bind)&&Et,kt=vt.test(kt=Array.isArray)&&kt,Nt=n.isFinite,Rt=n.isNaN,$t=vt.test($t=Object.keys)&&$t,Ft=Math.max,qt=Math.min,Dt=Math.random,It="[object Arguments]",Tt="[object Array]",Bt="[object Boolean]",Mt="[object Date]",Pt="[object Number]",zt="[object Object]",Ct="[object RegExp]",Kt="[object String]",Lt=!!n.attachEvent,Ut=Et&&!/\n|true/.test(Et+Lt),Vt=Et&&!Ut,Gt=$t&&(Lt||Ut),Ht=(Ht={0:1,length:1},rt.splice.call(Ht,0,1),Ht[0]),Jt=J; +r.prototype[t]=function(){var n=[this.__wrapped__];return At.apply(n,arguments),new r(e.apply(r,n))}})}function H(){return this.__wrapped__}var J=!0,Q=null,W=!1,X=typeof exports=="object"&&exports,Y=typeof global=="object"&&global;Y.global===Y&&(n=Y);var Z,nt,tt,rt=[],et={},ut=0,ot=et,it=30,ft=n._,at=/&(?:amp|lt|gt|quot|#39);/g,ct=/\b__p\+='';/g,lt=/\b(__p\+=)''\+/g,pt=/(__e\(.*?\)|\b__t\))\+'';/g,st=/\w*$/,vt=RegExp("^"+(et.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),gt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,yt=/<%=([\s\S]+?)%>/g,ht=/($^)/,mt=/[&<>"']/g,dt=/['\n\r\t\u2028\u2029\\]/g,_t="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),bt=Math.ceil,jt=rt.concat,wt=Math.floor,xt=vt.test(xt=Object.getPrototypeOf)&&xt,Ot=et.hasOwnProperty,At=rt.push,St=et.toString,Et=vt.test(Et=v.bind)&&Et,kt=vt.test(kt=Array.isArray)&&kt,Nt=n.isFinite,Rt=n.isNaN,$t=vt.test($t=Object.keys)&&$t,Ft=Math.max,qt=Math.min,Dt=Math.random,It="[object Arguments]",Tt="[object Array]",Bt="[object Boolean]",Mt="[object Date]",Pt="[object Number]",zt="[object Object]",Ct="[object RegExp]",Kt="[object String]",Lt=!!n.attachEvent,Ut=Et&&!/\n|true/.test(Et+Lt),Vt=Et&&!Ut,Gt=$t&&(Lt||Ut),Ht=(Ht={0:1,length:1},rt.splice.call(Ht,0,1),Ht[0]),Jt=J; (function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Jt=!r;Z=!/valueOf/.test(t),nt=n.propertyIsEnumerable("prototype"),tt="x"!=t[0]})(1);var Qt=arguments.constructor==Object,Wt=!y(arguments),Xt="xx"!="x"[0]+Object("x")[0];try{var Yt=St.call(document)==zt&&!({toString:0}+"")}catch(Zt){}var nr={"[object Function]":W};nr[It]=nr[Tt]=nr[Bt]=nr[Mt]=nr[Pt]=nr[zt]=nr[Ct]=nr[Kt]=J;var tr={};tr[Tt]=Array,tr[Bt]=Boolean,tr[Mt]=Date,tr[zt]=Object,tr[Pt]=Number,tr[Ct]=RegExp,tr[Kt]=String; var rr={"boolean":W,"function":J,object:J,number:W,string:W,undefined:W},er={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:yt,variable:"",imports:{_:r}};var ur={a:"q,w,h",l:"var a=arguments,b=0,c=typeof h=='number'?2:a.length;while(++b":">",'"':""","'":"'"},vr=b(sr),gr=a(ur,{l:ur.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=f(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[j]=d?d(u[j],n[j]):n[j]"}),yr=a(ur); diff --git a/dist/lodash.js b/dist/lodash.js index 323e278cb6..71c6ec792e 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -56,7 +56,7 @@ * Used to match ES6 template delimiters * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6 */ - var reEsTemplate = /\$\{((?:(?=\\?)\\?[\s\S])*?)\}/g; + var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; /** Used to match "interpolate" template delimiters */ var reInterpolate = /<%=([\s\S]+?)%>/g; diff --git a/dist/lodash.min.js b/dist/lodash.min.js index b9ec1a3dcd..13924df1bd 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -19,7 +19,7 @@ return n}function F(n,t,r){var e=-1,u=n?n.length:0,o=Array(typeof u=="number"?u: });return r}function T(n,t,r,e){var u=n?n.length:0,o=3>arguments.length;if(typeof u!="number")var i=Zt(n),u=i.length;return t=a(t,e,4),$(n,function(e,f,a){f=i?i[--u]:--u,r=o?(o=Q,n[f]):t(r,n[f],f,a)}),r}function B(n,t,r){var e;if(t=a(t,r),Yt(n)){r=-1;for(var u=n.length;++rr?St(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])z(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function U(n,t){return Pt||wt&&2/g,st=/($^)/,vt=/[&<>"']/g,gt=/['\n\r\t\u2028\u2029\\]/g,ht=Math.ceil,yt=Y.concat,mt=Math.floor,dt=ct.test(dt=Object.getPrototypeOf)&&dt,_t=Z.hasOwnProperty,bt=Y.push,jt=Z.toString,wt=ct.test(wt=v.bind)&&wt,xt=ct.test(xt=Array.isArray)&&xt,At=n.isFinite,Ot=n.isNaN,Et=ct.test(Et=Object.keys)&&Et,St=Math.max,kt=Math.min,Nt=Math.random,Rt="[object Arguments]",$t="[object Array]",Ft="[object Boolean]",qt="[object Date]",Dt="[object Number]",Tt="[object Object]",Bt="[object RegExp]",It="[object String]",Mt=!!n.attachEvent,zt=wt&&!/\n|true/.test(wt+Mt),Pt=wt&&!zt,Ct=Et&&(Mt||zt),Kt={"[object Function]":Q}; +e.prototype[t]=function(){var n=[this.__wrapped__];return bt.apply(n,arguments),new e(r.apply(e,n))}})}function H(){return this.__wrapped__}var J=!0,L=null,Q=!1,W=typeof exports=="object"&&exports,X=typeof global=="object"&&global;X.global===X&&(n=X);var Y=[],Z={},nt=0,tt=Z,rt=30,et=n._,ut=/&(?:amp|lt|gt|quot|#39);/g,ot=/\b__p\+='';/g,it=/\b(__p\+=)''\+/g,ft=/(__e\(.*?\)|\b__t\))\+'';/g,at=/\w*$/,ct=RegExp("^"+(Z.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),lt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,pt=/<%=([\s\S]+?)%>/g,st=/($^)/,vt=/[&<>"']/g,gt=/['\n\r\t\u2028\u2029\\]/g,ht=Math.ceil,yt=Y.concat,mt=Math.floor,dt=ct.test(dt=Object.getPrototypeOf)&&dt,_t=Z.hasOwnProperty,bt=Y.push,jt=Z.toString,wt=ct.test(wt=v.bind)&&wt,xt=ct.test(xt=Array.isArray)&&xt,At=n.isFinite,Ot=n.isNaN,Et=ct.test(Et=Object.keys)&&Et,St=Math.max,kt=Math.min,Nt=Math.random,Rt="[object Arguments]",$t="[object Array]",Ft="[object Boolean]",qt="[object Date]",Dt="[object Number]",Tt="[object Object]",Bt="[object RegExp]",It="[object String]",Mt=!!n.attachEvent,zt=wt&&!/\n|true/.test(wt+Mt),Pt=wt&&!zt,Ct=Et&&(Mt||zt),Kt={"[object Function]":Q}; Kt[Rt]=Kt[$t]=Kt[Ft]=Kt[qt]=Kt[Dt]=Kt[Tt]=Kt[Bt]=Kt[It]=J;var Ut={};Ut[$t]=Array,Ut[Ft]=Boolean,Ut[qt]=Date,Ut[Tt]=Object,Ut[Dt]=Number,Ut[Bt]=RegExp,Ut[It]=String;var Vt={"boolean":Q,"function":J,object:J,number:Q,string:Q,undefined:Q},Gt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};e.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:pt,variable:"",imports:{_:e}};var Ht={a:"q,w,h",l:"var a=arguments,b=0,c=typeof h=='number'?2:a.length;while(++b":">",'"':""","'":"'"},tr=_(nr),rr=c(Ht,{l:Ht.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=f(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[j]=d?d(u[j],n[j]):n[j]"}),er=c(Ht);j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==jt.call(n)}),e.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},e.assign=rr,e.at=function(n){for(var t=-1,r=yt.apply(Y,v(arguments,1)),e=r.length,u=Array(e);++t/g; From cb3b4e446eebc1475f50eb3da6eb2eb917508463 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 17 Feb 2013 10:41:05 -0800 Subject: [PATCH 12/22] Ensure `_.isEqual` returns boolean values even if `callback` doesn't. Former-commit-id: b2c31ee1711a436e5400c8e80c9f54a9680301b7 --- test/test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/test.js b/test/test.js index 39c4080ecd..35ddaddcde 100644 --- a/test/test.js +++ b/test/test.js @@ -1262,6 +1262,16 @@ var actual = _.isEqual('a', 'a', function() { }); strictEqual(actual, true); }); + + test('should return a boolean value even if `callback` does not', function() { + var actual = _.isEqual('a', 'a', function() { return 'a'; }); + strictEqual(actual, true); + + _.each(falsey, function(value) { + var actual = _.isEqual('a', 'b', function() { return value; }); + strictEqual(actual, false); + }); + }); }()); /*--------------------------------------------------------------------------*/ From 5133e39d459a33126e859c5d033622ba4e2379c8 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 17 Feb 2013 14:29:40 -0800 Subject: [PATCH 13/22] Make `_.defer` use `setImmediate` if available. Former-commit-id: b3898d78725a4b203856916b1b071ab9c6f40b83 --- dist/lodash.compat.js | 4 +-- dist/lodash.compat.min.js | 56 +++++++++++++++++------------------ dist/lodash.js | 8 ++--- dist/lodash.min.js | 40 ++++++++++++------------- dist/lodash.underscore.js | 4 +-- dist/lodash.underscore.min.js | 56 +++++++++++++++++------------------ lodash.js | 4 +-- test/test.js | 13 ++++++++ 8 files changed, 99 insertions(+), 86 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 65af551075..edd4e1cf8f 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -4224,10 +4224,10 @@ * _.defer(function() { alert('deferred'); }); * // returns from the function before `alert` is called */ - function defer(func) { + var defer = reNative.test(window.setImmediate) && bind(setImmediate, window) || function(func) { var args = slice(arguments, 1); return setTimeout(function() { func.apply(undefined, args); }, 1); - } + }; /** * Creates a function that memoizes the result of `func`. If `resolver` is diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 75159bc5b7..1e19845b8f 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -7,36 +7,36 @@ ;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||it);if(u){var o={};for(r=t-1;++rt||typeof n=="undefined")return 1;if(ne;e++)r+="j='"+t.k[e]+"';if(","constructor"==t.k[e]&&(r+="!(g&&g.prototype===n)&&"),r+="i.call(n,j)){"+t.h+"}"; -return(t.b||t.i)&&(r+="}"),r+=t.c+";return u",Function("f,i,k,l,m,r,p","return function("+n+"){"+r+"}")(f,Ot,y,lr,A,rr,$t)}function c(n){return"\\"+er[n]}function l(n){return sr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);var e=-1;r=r-t||0;for(var u=Array(0>r?0:r);++er?0:r);++er?Ft(0,u+r):r)||0,typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):z(n,t,r)):fr(n,function(n){return++eo&&(o=a)}}else t=!t&&A(n)?u:f(t,r),fr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t,r,e){var u=3>arguments.length;if(t=f(t,e,4),lr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var a=pr(n),o=a.length;else Xt&&A(n)&&(u=n.split(""));return t=f(t,e,4),F(n,function(n,e,f){e=a?a[--o]:--o,r=i?(i=W,u[e]):t(r,u[e],e,f)}),r}function B(n,t,r){var e;if(t=f(t,r),lr(n)){r=-1;for(var u=n.length;++rr?Ft(0,u+r):r||0)-1;else if(r)return e=K(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])z(a,p))&&((r||c)&&a.push(p),i.push(e))}return i}function U(n,t){return Vt||Et&&2/g,ht=/($^)/,mt=/[&<>"']/g,dt=/['\n\r\t\u2028\u2029\\]/g,_t="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),bt=Math.ceil,jt=rt.concat,wt=Math.floor,xt=vt.test(xt=Object.getPrototypeOf)&&xt,Ot=et.hasOwnProperty,At=rt.push,St=et.toString,Et=vt.test(Et=v.bind)&&Et,kt=vt.test(kt=Array.isArray)&&kt,Nt=n.isFinite,Rt=n.isNaN,$t=vt.test($t=Object.keys)&&$t,Ft=Math.max,qt=Math.min,Dt=Math.random,It="[object Arguments]",Tt="[object Array]",Bt="[object Boolean]",Mt="[object Date]",Pt="[object Number]",zt="[object Object]",Ct="[object RegExp]",Kt="[object String]",Lt=!!n.attachEvent,Ut=Et&&!/\n|true/.test(Et+Lt),Vt=Et&&!Ut,Gt=$t&&(Lt||Ut),Ht=(Ht={0:1,length:1},rt.splice.call(Ht,0,1),Ht[0]),Jt=J; -(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Jt=!r;Z=!/valueOf/.test(t),nt=n.propertyIsEnumerable("prototype"),tt="x"!=t[0]})(1);var Qt=arguments.constructor==Object,Wt=!y(arguments),Xt="xx"!="x"[0]+Object("x")[0];try{var Yt=St.call(document)==zt&&!({toString:0}+"")}catch(Zt){}var nr={"[object Function]":W};nr[It]=nr[Tt]=nr[Bt]=nr[Mt]=nr[Pt]=nr[zt]=nr[Ct]=nr[Kt]=J;var tr={};tr[Tt]=Array,tr[Bt]=Boolean,tr[Mt]=Date,tr[zt]=Object,tr[Pt]=Number,tr[Ct]=RegExp,tr[Kt]=String; +for(;++ur?It(0,u+r):r)||0,typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):z(n,t,r)):fr(n,function(n){return++eo&&(o=a)}}else t=!t&&A(n)?u:f(t,r),fr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function D(n,t,r,e){var u=3>arguments.length;if(t=f(t,e,4),lr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var a=pr(n),o=a.length;else Xt&&A(n)&&(u=n.split(""));return t=f(t,e,4),I(n,function(n,e,f){e=a?a[--o]:--o,r=i?(i=W,u[e]):t(r,u[e],e,f)}),r}function B(n,t,r){var e;if(t=f(t,r),lr(n)){r=-1;for(var u=n.length;++rr?It(0,u+r):r||0)-1;else if(r)return e=K(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])z(a,p))&&((r||c)&&a.push(p),i.push(e))}return i}function U(n,t){return Vt||Et&&2/g,ht=/($^)/,mt=/[&<>"']/g,dt=/['\n\r\t\u2028\u2029\\]/g,_t="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),bt=Math.ceil,jt=rt.concat,wt=Math.floor,xt=vt.test(xt=Object.getPrototypeOf)&&xt,Ot=et.hasOwnProperty,At=rt.push,St=et.toString,Et=vt.test(Et=v.bind)&&Et,kt=vt.test(kt=Array.isArray)&&kt,Nt=n.isFinite,Rt=n.isNaN,$t=vt.test($t=Object.keys)&&$t,It=Math.max,Ft=Math.min,qt=Math.random,Dt="[object Arguments]",Tt="[object Array]",Bt="[object Boolean]",Mt="[object Date]",Pt="[object Number]",zt="[object Object]",Ct="[object RegExp]",Kt="[object String]",Lt=!!n.attachEvent,Ut=Et&&!/\n|true/.test(Et+Lt),Vt=Et&&!Ut,Gt=$t&&(Lt||Ut),Ht=(Ht={0:1,length:1},rt.splice.call(Ht,0,1),Ht[0]),Jt=J; +(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Jt=!r;Z=!/valueOf/.test(t),nt=n.propertyIsEnumerable("prototype"),tt="x"!=t[0]})(1);var Qt=arguments.constructor==Object,Wt=!y(arguments),Xt="xx"!="x"[0]+Object("x")[0];try{var Yt=St.call(document)==zt&&!({toString:0}+"")}catch(Zt){}var nr={"[object Function]":W};nr[Dt]=nr[Tt]=nr[Bt]=nr[Mt]=nr[Pt]=nr[zt]=nr[Ct]=nr[Kt]=J;var tr={};tr[Tt]=Array,tr[Bt]=Boolean,tr[Mt]=Date,tr[zt]=Object,tr[Pt]=Number,tr[Ct]=RegExp,tr[Kt]=String; var rr={"boolean":W,"function":J,object:J,number:W,string:W,undefined:W},er={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:yt,variable:"",imports:{_:r}};var ur={a:"q,w,h",l:"var a=arguments,b=0,c=typeof h=='number'?2:a.length;while(++b":">",'"':""","'":"'"},vr=b(sr),gr=a(ur,{l:ur.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=f(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[j]=d?d(u[j],n[j]):n[j]"}),yr=a(ur); -w(/x/)&&(w=function(n){return n instanceof Function||"[object Function]"==St.call(n)});var hr=xt?function(n){if(!n||typeof n!="object")return W;var t=n.valueOf,r=typeof t=="function"&&(r=xt(t))&&xt(r);return r?n==r||xt(n)==r&&!y(n):h(n)}:h,mr=q,dr=R;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},r.assign=gr,r.at=function(n){var t=-1,r=jt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(Xt&&A(n)&&(n=n.split(""));++tz(c,l)){f&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n; -a.push(l)}}return a},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return F(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=pr,r.map=q,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return Ot.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=S,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&lr(n)){r=-1;for(var i=n.length;++rz(o,r,1))&&(u[r]=n)}),u},r.once=function(n){var t,r;return function(){return t?r:(t=J,r=n.apply(this,arguments),n=Q,r)}},r.pairs=function(n){for(var t=-1,r=pr(n),e=r.length,u=Array(e);++tr?Ft(0,e+r):qt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=G,r.noConflict=function(){return n._=ft,this},r.random=function(n,t){return n==Q&&t==Q&&(t=1),n=+n||0,t==Q&&(t=n,n=0),n+wt(Dt()*((+t||0)-n+1))},r.reduce=I,r.reduceRight=T,r.result=function(n,r){var e=n?n[r]:t;return w(e)?n[r]():e},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:pr(n).length -},r.some=B,r.sortedIndex=K,r.template=function(n,e,u){var o=r.templateSettings;n||(n=""),u=yr({},u,o);var i,f=yr({},u.imports,o.imports),o=pr(f),f=E(f),a=0,l=u.interpolate||ht,p="__p+='";n.replace(RegExp((u.escape||ht).source+"|"+l.source+"|"+(l===yt?gt:ht).source+"|"+(u.evaluate||ht).source+"|$","g"),function(t,r,e,u,o,f){return e||(e=u),p+=n.slice(a,f).replace(dt,c),r&&(p+="'+__e("+r+")+'"),o&&(i=J,p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),a=f+t.length,t}),p+="';\n",l=u=u.variable,l||(u="obj",p="with("+u+"){"+p+"}"),p=(i?p.replace(ct,""):p).replace(lt,"$1").replace(pt,"$1;"),p="function("+u+"){"+(l?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+p+"return __p}"; -try{var s=Function(o,"return "+p).apply(t,f)}catch(v){throw v.source=p,v}return e?s(e):(s.source=p,s)},r.unescape=function(n){return n==Q?"":(n+"").replace(at,g)},r.uniqueId=function(n){var t=++ut;return(n==Q?"":n+"")+t},r.all=N,r.any=B,r.detect=$,r.foldl=I,r.foldr=T,r.include=k,r.inject=I,cr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return At.apply(t,arguments),n.apply(r,t)})}),r.first=M,r.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=Q){var o=u; -for(t=f(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==Q||r)return n[u-1];return v(n,Ft(0,u-e))}},r.take=M,r.head=M,cr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==Q||e&&typeof t!="function"?u:new r(u)})}),r.VERSION="1.0.0",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=H,r.prototype.valueOf=H,fr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),fr(["push","reverse","sort","unshift"],function(n){var t=rt[n]; -r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),fr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments))}}),Ht&&fr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r -})):X?typeof module=="object"&&module&&module.exports==X?(module.exports=r)._=r:X._=r:n._=r})(this); \ No newline at end of file +w(/x/)&&(w=function(n){return n instanceof Function||"[object Function]"==St.call(n)});var hr=xt?function(n){if(!n||typeof n!="object")return W;var t=n.valueOf,r=typeof t=="function"&&(r=xt(t))&&xt(r);return r?n==r||xt(n)==r&&!y(n):h(n)}:h,mr=F,dr=R,_r=vt.test(n.n)&&U(setImmediate,n)||function(n){var r=v(arguments,1);return setTimeout(function(){n.apply(t,r)},1)};r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},r.assign=gr,r.at=function(n){var t=-1,r=jt.apply(rt,v(arguments,1)),e=r.length,u=Array(e); +for(Xt&&A(n)&&(n=n.split(""));++tz(c,l)){f&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;a.push(l)}}return a},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return I(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=pr,r.map=F,r.max=q,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return Ot.call(r,e)?r[e]:r[e]=n.apply(this,arguments) +}},r.merge=S,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&lr(n)){r=-1;for(var i=n.length;++rz(o,r,1))&&(u[r]=n)}),u},r.once=function(n){var t,r; +return function(){return t?r:(t=J,r=n.apply(this,arguments),n=Q,r)}},r.pairs=function(n){for(var t=-1,r=pr(n),e=r.length,u=Array(e);++tr?It(0,e+r):Ft(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=G,r.noConflict=function(){return n._=ft,this},r.random=function(n,t){return n==Q&&t==Q&&(t=1),n=+n||0,t==Q&&(t=n,n=0),n+wt(qt()*((+t||0)-n+1)) +},r.reduce=D,r.reduceRight=T,r.result=function(n,r){var e=n?n[r]:t;return w(e)?n[r]():e},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:pr(n).length},r.some=B,r.sortedIndex=K,r.template=function(n,e,u){var o=r.templateSettings;n||(n=""),u=yr({},u,o);var i,f=yr({},u.imports,o.imports),o=pr(f),f=E(f),a=0,l=u.interpolate||ht,p="__p+='";n.replace(RegExp((u.escape||ht).source+"|"+l.source+"|"+(l===yt?gt:ht).source+"|"+(u.evaluate||ht).source+"|$","g"),function(t,r,e,u,o,f){return e||(e=u),p+=n.slice(a,f).replace(dt,c),r&&(p+="'+__e("+r+")+'"),o&&(i=J,p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),a=f+t.length,t +}),p+="';\n",l=u=u.variable,l||(u="obj",p="with("+u+"){"+p+"}"),p=(i?p.replace(ct,""):p).replace(lt,"$1").replace(pt,"$1;"),p="function("+u+"){"+(l?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+p+"return __p}";try{var s=Function(o,"return "+p).apply(t,f)}catch(v){throw v.source=p,v}return e?s(e):(s.source=p,s)},r.unescape=function(n){return n==Q?"":(n+"").replace(at,g)},r.uniqueId=function(n){var t=++ut;return(n==Q?"":n+"")+t +},r.all=N,r.any=B,r.detect=$,r.foldl=D,r.foldr=T,r.include=k,r.inject=D,cr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return At.apply(t,arguments),n.apply(r,t)})}),r.first=M,r.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=Q){var o=u;for(t=f(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==Q||r)return n[u-1];return v(n,It(0,u-e))}},r.take=M,r.head=M,cr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e); +return t==Q||e&&typeof t!="function"?u:new r(u)})}),r.VERSION="1.0.0",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=H,r.prototype.valueOf=H,fr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),fr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),fr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments)) +}}),Ht&&fr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):X?typeof module=="object"&&module&&module.exports==X?(module.exports=r)._=r:X._=r:n._=r})(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index 71c6ec792e..09c2830cc0 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -292,7 +292,7 @@ '\n } '; } else { __p += '\n for (index in iterable) {'; - if ( obj.useHas) { + if (obj.useHas) { __p += '\n if ('; if (obj.useHas) { __p += 'hasOwnProperty.call(iterable, index)'; @@ -302,7 +302,7 @@ __p += (obj.loop ) + '; '; - if ( obj.useHas) { + if (obj.useHas) { __p += '\n }'; } ; __p += '\n } '; @@ -4074,10 +4074,10 @@ * _.defer(function() { alert('deferred'); }); * // returns from the function before `alert` is called */ - function defer(func) { + var defer = reNative.test(window.setImmediate) && bind(setImmediate, window) || function(func) { var args = slice(arguments, 1); return setTimeout(function() { func.apply(undefined, args); }, 1); - } + }; /** * Creates a function that memoizes the result of `func`. If `resolver` is diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 13924df1bd..67a185a2ed 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -9,32 +9,32 @@ }var o=j(n),i=!r,f=t;return i&&(r=t),o||(t=n),u}function a(n,t,r){if(n==L)return V;var e=typeof n;if("function"!=e){if("object"!=e)return function(t){return t[n]};var u=Zt(n);return function(t){for(var r=u.length,e=Q;r--&&(e=b(t[u[r]],n[u[r]],tt)););return e}}return typeof t!="undefined"?1===r?function(r){return n.call(t,r)}:2===r?function(r,e){return n.call(t,r,e)}:4===r?function(r,e,u,o){return n.call(t,r,e,u,o)}:function(r,e,u){return n.call(t,r,e,u)}:n}function c(){for(var n,t={g:Ct,b:"l(n)",c:"",h:"",l:"",m:J},r=0;n=arguments[r];r++)for(var e in n)t[e]=n[e]; return n=t.a,t.d=/^[^,]+/.exec(n)[0],r="var j,n="+t.d+",u=n;if(!n)return u;"+t.l+";",t.b&&(r+="var o=n.length;j=-1;if("+t.b+"){while(++jr?0:r);++er?St(0,u+r):r)||0,typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):z(n,t,r)):Qt(n,function(n){return++eu&&(u=f)}}else t=!t&&A(n)?o:a(t,r),Qt(n,function(n,r,o){r=t(n,r,o),r>e&&(e=r,u=n)});return u}function D(n,t,r,e){var u=3>arguments.length;if(t=a(t,e,4),Yt(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof u!="number")var i=Zt(n),u=i.length;return t=a(t,e,4),$(n,function(e,f,a){f=i?i[--u]:--u,r=o?(o=Q,n[f]):t(r,n[f],f,a)}),r}function B(n,t,r){var e;if(t=a(t,r),Yt(n)){r=-1;for(var u=n.length;++rarguments.length;if(typeof u!="number")var i=Zt(n),u=i.length;return t=a(t,e,4),$(n,function(e,f,a){f=i?i[--u]:--u,r=o?(o=Q,n[f]):t(r,n[f],f,a)}),r}function I(n,t,r){var e;if(t=a(t,r),Yt(n)){r=-1;for(var u=n.length;++rr?St(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])z(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function U(n,t){return Pt||wt&&2/g,st=/($^)/,vt=/[&<>"']/g,gt=/['\n\r\t\u2028\u2029\\]/g,ht=Math.ceil,yt=Y.concat,mt=Math.floor,dt=ct.test(dt=Object.getPrototypeOf)&&dt,_t=Z.hasOwnProperty,bt=Y.push,jt=Z.toString,wt=ct.test(wt=v.bind)&&wt,xt=ct.test(xt=Array.isArray)&&xt,At=n.isFinite,Ot=n.isNaN,Et=ct.test(Et=Object.keys)&&Et,St=Math.max,kt=Math.min,Nt=Math.random,Rt="[object Arguments]",$t="[object Array]",Ft="[object Boolean]",qt="[object Date]",Dt="[object Number]",Tt="[object Object]",Bt="[object RegExp]",It="[object String]",Mt=!!n.attachEvent,zt=wt&&!/\n|true/.test(wt+Mt),Pt=wt&&!zt,Ct=Et&&(Mt||zt),Kt={"[object Function]":Q}; -Kt[Rt]=Kt[$t]=Kt[Ft]=Kt[qt]=Kt[Dt]=Kt[Tt]=Kt[Bt]=Kt[It]=J;var Ut={};Ut[$t]=Array,Ut[Ft]=Boolean,Ut[qt]=Date,Ut[Tt]=Object,Ut[Dt]=Number,Ut[Bt]=RegExp,Ut[It]=String;var Vt={"boolean":Q,"function":J,object:J,number:Q,string:Q,undefined:Q},Gt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};e.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:pt,variable:"",imports:{_:e}};var Ht={a:"q,w,h",l:"var a=arguments,b=0,c=typeof h=='number'?2:a.length;while(++b":">",'"':""","'":"'"},tr=_(nr),rr=c(Ht,{l:Ht.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=f(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[j]=d?d(u[j],n[j]):n[j]"}),er=c(Ht);j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==jt.call(n)}),e.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},e.assign=rr,e.at=function(n){for(var t=-1,r=yt.apply(Y,v(arguments,1)),e=r.length,u=Array(e);++tz(c,l)){f&&c.push(l);for(var s=r;--s;)if(!(e[s]||(e[s]=u(t[s],0,100)))(l))continue n;a.push(l)}}return a},e.invert=_,e.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return $(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},e.keys=Zt,e.map=F,e.max=q,e.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return _t.call(r,e)?r[e]:r[e]=n.apply(this,arguments) -}},e.merge=O,e.min=function(n,t,r){var e=1/0,u=e;if(!t&&Yt(n)){r=-1;for(var i=n.length;++rz(o,r,1))&&(u[r]=n)}),u},e.once=function(n){var t,r; -return function(){return t?r:(t=J,r=n.apply(this,arguments),n=L,r)}},e.pairs=function(n){for(var t=-1,r=Zt(n),e=r.length,u=Array(e);++tr?St(0,e+r):kt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},e.mixin=G,e.noConflict=function(){return n._=et,this},e.random=function(n,t){return n==L&&t==L&&(t=1),n=+n||0,t==L&&(t=n,n=0),n+mt(Nt()*((+t||0)-n+1)) -},e.reduce=D,e.reduceRight=T,e.result=function(n,r){var e=n?n[r]:t;return j(e)?n[r]():e},e.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Zt(n).length},e.some=B,e.sortedIndex=C,e.template=function(n,r,u){var o=e.templateSettings;n||(n=""),u=er({},u,o);var i,f=er({},u.imports,o.imports),o=Zt(f),f=E(f),a=0,c=u.interpolate||st,p="__p+='";n.replace(RegExp((u.escape||st).source+"|"+c.source+"|"+(c===pt?lt:st).source+"|"+(u.evaluate||st).source+"|$","g"),function(t,r,e,u,o,f){return e||(e=u),p+=n.slice(a,f).replace(gt,l),r&&(p+="'+__e("+r+")+'"),o&&(i=J,p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),a=f+t.length,t +e.prototype[t]=function(){var n=[this.__wrapped__];return bt.apply(n,arguments),new e(r.apply(e,n))}})}function H(){return this.__wrapped__}var J=!0,L=null,Q=!1,W=typeof exports=="object"&&exports,X=typeof global=="object"&&global;X.global===X&&(n=X);var Y=[],Z={},nt=0,tt=Z,rt=30,et=n._,ut=/&(?:amp|lt|gt|quot|#39);/g,ot=/\b__p\+='';/g,it=/\b(__p\+=)''\+/g,ft=/(__e\(.*?\)|\b__t\))\+'';/g,at=/\w*$/,ct=RegExp("^"+(Z.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),lt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,pt=/<%=([\s\S]+?)%>/g,st=/($^)/,vt=/[&<>"']/g,gt=/['\n\r\t\u2028\u2029\\]/g,ht=Math.ceil,yt=Y.concat,mt=Math.floor,dt=ct.test(dt=Object.getPrototypeOf)&&dt,_t=Z.hasOwnProperty,bt=Y.push,jt=Z.toString,wt=ct.test(wt=v.bind)&&wt,xt=ct.test(xt=Array.isArray)&&xt,At=n.isFinite,Ot=n.isNaN,Et=ct.test(Et=Object.keys)&&Et,St=Math.max,kt=Math.min,Nt=Math.random,Rt="[object Arguments]",$t="[object Array]",Ft="[object Boolean]",qt="[object Date]",Dt="[object Number]",Tt="[object Object]",It="[object RegExp]",Bt="[object String]",Mt=!!n.attachEvent,zt=wt&&!/\n|true/.test(wt+Mt),Pt=wt&&!zt,Ct=Et&&(Mt||zt),Kt={"[object Function]":Q}; +Kt[Rt]=Kt[$t]=Kt[Ft]=Kt[qt]=Kt[Dt]=Kt[Tt]=Kt[It]=Kt[Bt]=J;var Ut={};Ut[$t]=Array,Ut[Ft]=Boolean,Ut[qt]=Date,Ut[Tt]=Object,Ut[Dt]=Number,Ut[It]=RegExp,Ut[Bt]=String;var Vt={"boolean":Q,"function":J,object:J,number:Q,string:Q,undefined:Q},Gt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};e.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:pt,variable:"",imports:{_:e}};var Ht={a:"q,w,h",l:"var a=arguments,b=0,c=typeof h=='number'?2:a.length;while(++b":">",'"':""","'":"'"},tr=_(nr),rr=c(Ht,{l:Ht.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=f(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[j]=d?d(u[j],n[j]):n[j]"}),er=c(Ht);j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==jt.call(n)});var ur=ct.test(n.e)&&U(setImmediate,n)||function(n){var r=v(arguments,1);return setTimeout(function(){n.apply(t,r) +},1)};e.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},e.assign=rr,e.at=function(n){for(var t=-1,r=yt.apply(Y,v(arguments,1)),e=r.length,u=Array(e);++tz(c,l)){f&&c.push(l);for(var s=r;--s;)if(!(e[s]||(e[s]=u(t[s],0,100)))(l))continue n;a.push(l)}}return a},e.invert=_,e.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return $(n,function(n){i[++e]=(u?t:n[t]).apply(n,r) +}),i},e.keys=Zt,e.map=F,e.max=q,e.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return _t.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},e.merge=O,e.min=function(n,t,r){var e=1/0,u=e;if(!t&&Yt(n)){r=-1;for(var i=n.length;++rz(o,r,1))&&(u[r]=n)}),u},e.once=function(n){var t,r;return function(){return t?r:(t=J,r=n.apply(this,arguments),n=L,r)}},e.pairs=function(n){for(var t=-1,r=Zt(n),e=r.length,u=Array(e);++tr?St(0,e+r):kt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},e.mixin=G,e.noConflict=function(){return n._=et,this +},e.random=function(n,t){return n==L&&t==L&&(t=1),n=+n||0,t==L&&(t=n,n=0),n+mt(Nt()*((+t||0)-n+1))},e.reduce=D,e.reduceRight=T,e.result=function(n,r){var e=n?n[r]:t;return j(e)?n[r]():e},e.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Zt(n).length},e.some=I,e.sortedIndex=C,e.template=function(n,r,u){var o=e.templateSettings;n||(n=""),u=er({},u,o);var i,f=er({},u.imports,o.imports),o=Zt(f),f=E(f),a=0,c=u.interpolate||st,p="__p+='";n.replace(RegExp((u.escape||st).source+"|"+c.source+"|"+(c===pt?lt:st).source+"|"+(u.evaluate||st).source+"|$","g"),function(t,r,e,u,o,f){return e||(e=u),p+=n.slice(a,f).replace(gt,l),r&&(p+="'+__e("+r+")+'"),o&&(i=J,p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),a=f+t.length,t }),p+="';\n",c=u=u.variable,c||(u="obj",p="with("+u+"){"+p+"}"),p=(i?p.replace(ot,""):p).replace(it,"$1").replace(ft,"$1;"),p="function("+u+"){"+(c?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+p+"return __p}";try{var s=Function(o,"return "+p).apply(t,f)}catch(v){throw v.source=p,v}return r?s(r):(s.source=p,s)},e.unescape=function(n){return n==L?"":(n+"").replace(ut,g)},e.uniqueId=function(n){var t=++nt;return(n==L?"":n+"")+t -},e.all=k,e.any=B,e.detect=R,e.foldl=D,e.foldr=T,e.include=S,e.inject=D,Xt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(){var t=[this.__wrapped__];return bt.apply(t,arguments),n.apply(e,t)})}),e.first=I,e.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=L){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==L||r)return n[u-1];return v(n,St(0,u-e))}},e.take=I,e.head=I,Xt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(t,r){var u=n(this.__wrapped__,t,r); +},e.all=k,e.any=I,e.detect=R,e.foldl=D,e.foldr=T,e.include=S,e.inject=D,Xt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(){var t=[this.__wrapped__];return bt.apply(t,arguments),n.apply(e,t)})}),e.first=B,e.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=L){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==L||r)return n[u-1];return v(n,St(0,u-e))}},e.take=B,e.head=B,Xt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(t,r){var u=n(this.__wrapped__,t,r); return t==L||r&&typeof t!="function"?u:new e(u)})}),e.VERSION="1.0.0",e.prototype.toString=function(){return this.__wrapped__+""},e.prototype.value=H,e.prototype.valueOf=H,Qt(["join","pop","shift"],function(n){var t=Y[n];e.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),Qt(["push","reverse","sort","unshift"],function(n){var t=Y[n];e.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Qt(["concat","slice","splice"],function(n){var t=Y[n];e.prototype[n]=function(){return new e(t.apply(this.__wrapped__,arguments)) }}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=e,define(function(){return e})):W?typeof module=="object"&&module&&module.exports==W?(module.exports=e)._=e:W._=e:n._=e})(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index c556ef1c0c..8f526f028d 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -3463,10 +3463,10 @@ * _.defer(function() { alert('deferred'); }); * // returns from the function before `alert` is called */ - function defer(func) { + var defer = reNative.test(window.setImmediate) && bind(setImmediate, window) || function(func) { var args = slice(arguments, 1); return setTimeout(function() { func.apply(undefined, args); }, 1); - } + }; /** * Creates a function that memoizes the result of `func`. If `resolver` is diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index 1c9cd67e15..7a92f955dc 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -4,31 +4,31 @@ * Build: `lodash underscore -o ./dist/lodash.underscore.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ -;(function(n,r){function t(n,r){var t;if(n&&Rr[typeof n])for(t in r||(r=W),n)if(r(n[t],t,n)===Z)break}function e(n,r,t){if(n){r=r&&typeof t=="undefined"?r:a(r,t);var e=n.length;if(t=-1,typeof e=="number")for(;++tr||typeof n=="undefined")return 1;if(nt?0:t);++eo&&(o=f)}}else r=a(r,t),e(n,function(n,t,e){t=r(n,t,e),t>u&&(u=t,o=n)});return o}function q(n,r,t,u){var o=3>arguments.length;if(r=a(r,u,4),qr(n)){var i=-1,f=n.length;for(o&&(t=n[++i]);++iarguments.length;if(typeof u!="number")var i=Br(n),u=i.length;return r=a(r,e,4),F(n,function(e,a,f){a=i?i[--u]:--u,t=o?(o=K,n[a]):r(t,n[a],a,f)}),t}function D(n,r,t){var u; -if(r=a(r,t),qr(n)){t=-1;for(var o=n.length;++tt?mr(0,u+t):t||0)-1;else if(t)return e=P(n,r),n[e]===r?e:-1;for(;++e>>1,t(n[e])z(f,c))&&(t&&f.push(c),i.push(e))}return i}function V(n,r){return Nr||sr&&2"']/g,or=/['\n\r\t\u2028\u2029\\]/g,ir=Math.ceil,ar=X.concat,fr=Math.floor,cr=Q.hasOwnProperty,lr=X.push,pr=Q.toString,sr=tr.test(sr=p.bind)&&sr,vr=tr.test(vr=Array.isArray)&&vr,hr=n.isFinite,gr=n.isNaN,yr=tr.test(yr=Object.keys)&&yr,mr=Math.max,_r=Math.min,dr=Math.random,br="[object Arguments]",jr="[object Array]",wr="[object Boolean]",Ar="[object Date]",xr="[object Number]",Er="[object Object]",Or="[object RegExp]",Sr="[object String]",Q=!!n.attachEvent,Q=sr&&!/\n|true/.test(sr+Q),Nr=sr&&!Q,kr=(kr={0:1,length:1},X.splice.call(kr,0,1),kr[0]),Fr=arguments.constructor==Object,Rr={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Tr={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; -u.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},v(arguments)||(v=function(n){return n?cr.call(n,"callee"):K});var qr=vr||function(n){return Fr&&n instanceof Array||pr.call(n)==jr},Br=yr?function(n){return w(n)?yr(n):[]}:h,Dr={"&":"&","<":"<",">":">",'"':""","'":"'"},Mr=_(Dr);j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==pr.call(n)});var $r=R;u.after=function(n,r){return 1>n?r():function(){return 1>--n?r.apply(this,arguments):void 0 -}},u.bind=V,u.bindAll=function(n){for(var r=ar.apply(X,arguments),t=1z(e,o,t)&&u.push(o)}return u},u.filter=N,u.flatten=I,u.forEach=F,u.functions=m,u.groupBy=function(n,r,t){var e={}; -return r=a(r,t),F(n,function(n,t,u){t=r(n,t,u)+"",(cr.call(e,t)?e[t]:e[t]=[]).push(n)}),e},u.initial=function(n,r,t){if(!n)return[];var e=0,u=n.length;if(typeof r!="number"&&r!=J){var o=u;for(r=a(r,t);o--&&r(n[o],o,n);)e++}else e=r==J||t?1:r||e;return p(n,0,_r(mr(0,u-e),u))},u.intersection=function(n){var r=arguments,t=r.length,e=-1,u=n?n.length:0,o=[];n:for(;++ez(o,i)){for(var a=t;--a;)if(0>z(r[a],i))continue n;o.push(i)}}return o},u.invert=_,u.invoke=function(n,r){var t=p(arguments,2),e=-1,u=typeof r=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0); -return F(n,function(n){i[++e]=(u?r:n[r]).apply(n,t)}),i},u.keys=Br,u.map=R,u.max=T,u.memoize=function(n,r){var t={};return function(){var e=(r?r.apply(this,arguments):arguments[0])+"";return cr.call(t,e)?t[e]:t[e]=n.apply(this,arguments)}},u.min=function(n,r,t){var u=1/0,o=u;if(!r&&qr(n)){t=-1;for(var i=n.length;++tz(r,t,1)&&(e[t]=n)}),e},u.once=function(n){var r,t;return function(){return r?t:(r=H,t=n.apply(this,arguments),n=J,t)}},u.pairs=function(n){for(var r=-1,t=Br(n),e=t.length,u=Array(e);++rz(arguments,u,1)&&e.push(u)}return e},u.wrap=function(n,r){return function(){var t=[n];return lr.apply(t,arguments),r.apply(this,t)}},u.zip=function(n){for(var r=-1,t=n?T($r(arguments,"length")):0,e=Array(t);++rt?mr(0,e+t):_r(t,e-1))+1);e--;)if(n[e]===r)return e;return-1},u.mixin=G,u.noConflict=function(){return n._=nr,this},u.random=function(n,r){return n==J&&r==J&&(r=1),n=+n||0,r==J&&(r=n,n=0),n+fr(dr()*((+r||0)-n+1))},u.reduce=q,u.reduceRight=B,u.result=function(n,r){var t=n?n[r]:J;return j(t)?n[r]():t},u.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:Br(n).length -},u.some=D,u.sortedIndex=P,u.template=function(n,r,t){n||(n=""),t=y({},t,u.templateSettings);var e=0,o="__p+='",i=t.variable;n.replace(RegExp((t.escape||er).source+"|"+(t.interpolate||er).source+"|"+(t.evaluate||er).source+"|$","g"),function(r,t,u,i,a){return o+=n.slice(e,a).replace(or,f),t&&(o+="'+_['escape']("+t+")+'"),i&&(o+="';"+i+";__p+='"),u&&(o+="'+((__t=("+u+"))==null?'':__t)+'"),e=a+r.length,r}),o+="';\n",i||(i="obj",o="with("+i+"||{}){"+o+"}"),o="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+o+"return __p}"; -try{var a=Function("_","return "+o)(u)}catch(c){throw c.source=o,c}return r?a(r):(a.source=o,a)},u.unescape=function(n){return n==J?"":(n+"").replace(rr,s)},u.uniqueId=function(n){var r=++Y+"";return n?n+r:r},u.all=S,u.any=D,u.detect=k,u.foldl=q,u.foldr=B,u.include=O,u.inject=q,u.first=$,u.last=function(n,r,t){if(n){var e=0,u=n.length;if(typeof r!="number"&&r!=J){var o=u;for(r=a(r,t);o--&&r(n[o],o,n);)e++}else if(e=r,e==J||t)return n[u-1];return p(n,mr(0,u-e))}},u.take=$,u.head=$,u.chain=function(n){return n=new u(n),n.__chain__=H,n -},u.VERSION="1.0.0",G(u),u.prototype.chain=function(){return this.__chain__=H,this},u.prototype.value=function(){return this.__wrapped__},e("pop push reverse shift sort splice unshift".split(" "),function(n){var r=X[n];u.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),kr&&0===n.length&&delete n[0],this}}),e(["concat","join","slice"],function(n){var r=X[n];u.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new u(n),n.__chain__=H),n -}}),L?typeof module=="object"&&module&&module.exports==L?(module.exports=u)._=u:L._=u:n._=u})(this); \ No newline at end of file +;(function(n,t){function r(n,t){var r;if(n&&Rt[typeof n])for(r in t||(t=W),n)if(t(n[r],r,n)===nt)break}function e(n,t,r){if(n){t=t&&typeof r=="undefined"?t:a(t,r);var e=n.length;if(r=-1,typeof e=="number")for(;++rt||typeof n=="undefined")return 1;if(nr?0:r);++eo&&(o=f)}}else t=a(t,r),e(n,function(n,r,e){r=t(n,r,e),r>u&&(u=r,o=n)});return o}function q(n,t,r,u){var o=3>arguments.length;if(t=a(t,u,4),qt(n)){var i=-1,f=n.length;for(o&&(r=n[++i]);++iarguments.length;if(typeof u!="number")var i=It(n),u=i.length;return t=a(t,e,4),F(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=K,n[a]):t(r,n[a],a,f)}),r}function B(n,t,r){var u; +if(t=a(t,r),qt(n)){r=-1;for(var o=n.length;++rr?mt(0,u+r):r||0)-1;else if(r)return e=P(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])z(f,c))&&(r&&f.push(c),i.push(e))}return i}function V(n,t){return Nt||st&&2"']/g,ot=/['\n\r\t\u2028\u2029\\]/g,it=Math.ceil,at=X.concat,ft=Math.floor,ct=Y.hasOwnProperty,lt=X.push,pt=Y.toString,st=Q.test(st=p.bind)&&st,vt=Q.test(vt=Array.isArray)&&vt,ht=n.isFinite,gt=n.isNaN,yt=Q.test(yt=Object.keys)&&yt,mt=Math.max,_t=Math.min,dt=Math.random,bt="[object Arguments]",jt="[object Array]",wt="[object Boolean]",At="[object Date]",xt="[object Number]",Et="[object Object]",Ot="[object RegExp]",St="[object String]",Y=!!n.attachEvent,Y=st&&!/\n|true/.test(st+Y),Nt=st&&!Y,kt=(kt={0:1,length:1},X.splice.call(kt,0,1),kt[0]),Ft=arguments.constructor==Object,Rt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Tt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +u.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},v(arguments)||(v=function(n){return n?ct.call(n,"callee"):K});var qt=vt||function(n){return Ft&&n instanceof Array||pt.call(n)==jt},It=yt?function(n){return w(n)?yt(n):[]}:h,Bt={"&":"&","<":"<",">":">",'"':""","'":"'"},Dt=_(Bt);j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==pt.call(n)});var Mt=R,vt=Q.test(n.d)&&V(setImmediate,n)||function(n){var r=p(arguments,1); +return setTimeout(function(){n.apply(t,r)},1)};u.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},u.bind=V,u.bindAll=function(n){for(var t=at.apply(X,arguments),r=1z(e,o,r)&&u.push(o)}return u},u.filter=N,u.flatten=$,u.forEach=F,u.functions=m,u.groupBy=function(n,t,r){var e={};return t=a(t,r),F(n,function(n,r,u){r=t(n,r,u)+"",(ct.call(e,r)?e[r]:e[r]=[]).push(n)}),e},u.initial=function(n,t,r){if(!n)return[];var e=0,u=n.length;if(typeof t!="number"&&t!=J){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else e=t==J||r?1:t||e;return p(n,0,_t(mt(0,u-e),u))},u.intersection=function(n){var t=arguments,r=t.length,e=-1,u=n?n.length:0,o=[];n:for(;++ez(o,i)){for(var a=r;--a;)if(0>z(t[a],i))continue n; +o.push(i)}}return o},u.invert=_,u.invoke=function(n,t){var r=p(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return F(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},u.keys=It,u.map=R,u.max=T,u.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return ct.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},u.min=function(n,t,r){var u=1/0,o=u;if(!t&&qt(n)){r=-1;for(var i=n.length;++rz(t,r,1)&&(e[r]=n)}),e},u.once=function(n){var t,r;return function(){return t?r:(t=H,r=n.apply(this,arguments),n=J,r)}},u.pairs=function(n){for(var t=-1,r=It(n),e=r.length,u=Array(e);++tz(arguments,u,1)&&e.push(u)}return e},u.wrap=function(n,t){return function(){var r=[n];return lt.apply(r,arguments),t.apply(this,r)}},u.zip=function(n){for(var t=-1,r=n?T(Mt(arguments,"length")):0,e=Array(r);++tr?mt(0,e+r):_t(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},u.mixin=G,u.noConflict=function(){return n._=tt,this},u.random=function(n,t){return n==J&&t==J&&(t=1),n=+n||0,t==J&&(t=n,n=0),n+ft(dt()*((+t||0)-n+1))},u.reduce=q,u.reduceRight=I,u.result=function(n,t){var r=n?n[t]:J; +return j(r)?n[t]():r},u.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:It(n).length},u.some=B,u.sortedIndex=P,u.template=function(n,t,r){n||(n=""),r=y({},r,u.templateSettings);var e=0,o="__p+='",i=r.variable;n.replace(RegExp((r.escape||et).source+"|"+(r.interpolate||et).source+"|"+(r.evaluate||et).source+"|$","g"),function(t,r,u,i,a){return o+=n.slice(e,a).replace(ot,f),r&&(o+="'+_['escape']("+r+")+'"),i&&(o+="';"+i+";__p+='"),u&&(o+="'+((__t=("+u+"))==null?'':__t)+'"),e=a+t.length,t +}),o+="';\n",i||(i="obj",o="with("+i+"||{}){"+o+"}"),o="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+o+"return __p}";try{var a=Function("_","return "+o)(u)}catch(c){throw c.source=o,c}return t?a(t):(a.source=o,a)},u.unescape=function(n){return n==J?"":(n+"").replace(rt,s)},u.uniqueId=function(n){var t=++Z+"";return n?n+t:t},u.all=S,u.any=B,u.detect=k,u.foldl=q,u.foldr=I,u.include=O,u.inject=q,u.first=M,u.last=function(n,t,r){if(n){var e=0,u=n.length; +if(typeof t!="number"&&t!=J){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==J||r)return n[u-1];return p(n,mt(0,u-e))}},u.take=M,u.head=M,u.chain=function(n){return n=new u(n),n.__chain__=H,n},u.VERSION="1.0.0",G(u),u.prototype.chain=function(){return this.__chain__=H,this},u.prototype.value=function(){return this.__wrapped__},e("pop push reverse shift sort splice unshift".split(" "),function(n){var t=X[n];u.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),kt&&0===n.length&&delete n[0],this +}}),e(["concat","join","slice"],function(n){var t=X[n];u.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new u(n),n.__chain__=H),n}}),L?typeof module=="object"&&module&&module.exports==L?(module.exports=u)._=u:L._=u:n._=u})(this); \ No newline at end of file diff --git a/lodash.js b/lodash.js index ba6dec4208..fe0ac0cce9 100644 --- a/lodash.js +++ b/lodash.js @@ -4231,10 +4231,10 @@ * _.defer(function() { alert('deferred'); }); * // returns from the function before `alert` is called */ - function defer(func) { + var defer = reNative.test(window.setImmediate) && bind(setImmediate, window) || function(func) { var args = slice(arguments, 1); return setTimeout(function() { func.apply(undefined, args); }, 1); - } + }; /** * Creates a function that memoizes the result of `func`. If `resolver` is diff --git a/test/test.js b/test/test.js index 35ddaddcde..632af43abf 100644 --- a/test/test.js +++ b/test/test.js @@ -545,6 +545,19 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.defer'); + + (function() { + asyncTest('should accept additional arguments', function() { + _.defer(function() { + deepEqual(slice.call(arguments), [1, 2, 3]); + QUnit.start(); + }, 1, 2, 3); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.difference'); (function() { From 45bec0c44066ca120858ddae173876e3aedd17aa Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 17 Feb 2013 14:30:22 -0800 Subject: [PATCH 14/22] Remove `setImmediate` use in the `lodash legacy` build and cleanup patterns. Former-commit-id: a3c942e3545c278b7cac2112ed1a5417212048d9 --- build.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/build.js b/build.js index c6f540df44..d9b2553272 100755 --- a/build.js +++ b/build.js @@ -989,7 +989,7 @@ source = source.replace(getIteratorTemplate(source), function(match) { return match .replace(/(?: *\/\/.*\n)* *["'] *(?:<% *)?if *\(hasEnumPrototype *(?:&&|\))[\s\S]+?<% *} *(?:%>|["']).+/g, '') - .replace(/hasEnumPrototype *\|\|/g, ''); + .replace(/hasEnumPrototype *\|\|\s*/g, ''); }); return source; @@ -1071,7 +1071,7 @@ // remove `noArgsClass` from `_.isEmpty` source = source.replace(matchFunction(source, 'isEmpty'), function(match) { - return match.replace(/ *\|\| *\(noArgsClass *&&[^)]+?\)\)/g, ''); + return match.replace(/ *\|\|\s*\(noArgsClass *&&[^)]+?\)\)/g, ''); }); return source; @@ -1136,7 +1136,7 @@ source = source.replace(getIteratorTemplate(source), function(match) { return match .replace(/(?: *\/\/.*\n)*( *["'] *)<% *} *else *if *\(nonEnumArgs[\s\S]+?(\1<% *} *%>.+)/, '$2') - .replace(/ *\|\| *nonEnumArgs/, ''); + .replace(/ *\|\|\s*nonEnumArgs/, ''); }); return source; @@ -1160,12 +1160,12 @@ // remove `noNodeClass` from `_.clone` source = source.replace(matchFunction(source, 'clone'), function(match) { - return match.replace(/ *\|\| *\(noNodeClass[\s\S]+?\)\)/, ''); + return match.replace(/ *\|\|\s*\(noNodeClass[\s\S]+?\)\)/, ''); }); // remove `noNodeClass` from `_.isEqual` source = source.replace(matchFunction(source, 'isEqual'), function(match) { - return match.replace(/ *\|\| *\(noNodeClass[\s\S]+?\)\)\)/, ''); + return match.replace(/ *\|\|\s*\(noNodeClass[\s\S]+?\)\)\)/, ''); }); return source; @@ -2107,9 +2107,14 @@ return match.replace(/(?:\s*\/\/.*)*\s*return isBindFast[^:]+:\s*/, 'return '); }); + // remove native `setImmediate` branch in `_.defer` + source = source.replace(matchFunction(source, 'defer'), function(match) { + return match.replace(/reNative.*?\|\|\s*/, ''); + }); + // remove native `Array.isArray` branch in `_.isArray` source = source.replace(matchFunction(source, 'isArray'), function(match) { - return match.replace(/nativeIsArray * \|\|/, ''); + return match.replace(/nativeIsArray * \|\|\s*/, ''); }); // replace `_.keys` with `shimKeys` @@ -2245,7 +2250,7 @@ // minor cleanup snippet = snippet - .replace(/obj *\|\| *\(obj *= *{}\);/, '') + .replace(/obj *\|\|\s*\(obj *= *{}\);/, '') .replace(/var __p = '';\s*__p \+=/, 'var __p ='); // remove comments, including sourceURLs From 3ed9e0e905163383c4412b9552567da7c02d21c5 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 17 Feb 2013 16:02:53 -0800 Subject: [PATCH 15/22] Add support for specifying a source map URL in the to the `-p`/`--source-map` build options. Former-commit-id: 2098da69d7902497e2e67210d778b8f99a5ff8f0 --- README.md | 2 +- build.js | 14 ++++++++++++-- build/minify.js | 48 +++++++++++++++++++++++++++++++++++++++++----- test/test-build.js | 11 +++++++---- 4 files changed, 63 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 28d4dfc1fd..494ab29032 100644 --- a/README.md +++ b/README.md @@ -176,7 +176,7 @@ The following options are also supported: * `-h`, `--help` ............. Display help information * `-m`, `--minify` ......... Write only the minified production output * `-o`, `--output` ......... Write output to a given path/filename - * `-p`, `--source-map` .. Generate a source map for the minified output + * `-p`, `--source-map` .. Generate a source map for the minified output, using an optional source map URL * `-s`, `--silent` ......... Skip status updates normally logged to the console * `-V`, `--version` ....... Output current version of Lo-Dash diff --git a/build.js b/build.js index d9b2553272..d87c45dfd2 100755 --- a/build.js +++ b/build.js @@ -594,7 +594,7 @@ ' -h, --help Display help information', ' -m, --minify Write only the minified production output', ' -o, --output Write output to a given path/filename', - ' -p, --source-map Generate a source map for the minified output', + ' -p, --source-map Generate a source map for the minified output, using an optional source map URL', ' -s, --silent Skip status updates normally logged to the console', ' -V, --version Output current version of Lo-Dash', '' @@ -1304,13 +1304,16 @@ // the debug version of `source` var debugSource; + // used to specify the source map URL + var sourceMapURL; + // used to report invalid command-line arguments var invalidArgs = _.reject(options.slice(options[0] == 'node' ? 2 : 0), function(value, index, options) { if (/^(?:-o|--output)$/.test(options[index - 1]) || /^(?:category|exclude|exports|iife|include|moduleId|minus|plus|settings|template)=.*$/.test(value)) { return true; } - return [ + var result = [ 'backbone', 'csp', 'legacy', @@ -1328,6 +1331,12 @@ '-s', '--silent', '-V', '--version' ].indexOf(value) > -1; + + if (!result && /^(?:-p|--source-map)$/.test(options[index - 1])) { + result = true; + sourceMapURL = value; + } + return result; }); // report invalid arguments @@ -2440,6 +2449,7 @@ 'isTemplate': isTemplate, 'modes': isIIFE && ['simple', 'hybrid'], 'outputPath': outputPath, + 'sourceMapURL': sourceMapURL, 'onComplete': function(data) { if (isCustom) { data.source = addCommandsToHeader(data.source, options); diff --git a/build/minify.js b/build/minify.js index 81e4d295dd..743fe3e90a 100755 --- a/build/minify.js +++ b/build/minify.js @@ -7,8 +7,9 @@ https = require('https'), path = require('path'), spawn = require('child_process').spawn, + zlib = require('zlib'), tar = require('../vendor/tar/tar.js'), - zlib = require('zlib'); + _ = require('../lodash.js'); /** Load other modules */ var preprocess = require('./pre-compile.js'), @@ -80,7 +81,12 @@ * onComplete - The function called once minification has finished. */ function minify(source, options) { + // used to specify the source map URL + var sourceMapURL; + + // used to specify the default minifer modes var modes = ['simple', 'advanced', 'hybrid']; + source || (source = ''); options || (options = {}); @@ -89,6 +95,35 @@ // convert commands to an options object options = source; + // used to report invalid command-line arguments + var invalidArgs = _.reject(options.slice(options[0] == 'node' ? 2 : 0), function(value, index, options) { + if (/^(?:-o|--output)$/.test(options[index - 1]) || + /^modes=.*$/.test(value)) { + return true; + } + var result = [ + '-o', '--output', + '-p', '--source-map', + '-s', '--silent', + '-t', '--template' + ].indexOf(value) > -1; + + if (!result && /^(?:-p|--source-map)$/.test(options[index - 1])) { + result = true; + sourceMapURL = value; + } + return result; + }); + + // report invalid arguments + if (invalidArgs.length) { + console.log( + '\n' + + 'Invalid argument' + (invalidArgs.length > 1 ? 's' : '') + + ' passed: ' + invalidArgs.join(', ') + ); + return; + } var filePath = options[options.length - 1], isMapped = options.indexOf('-p') > -1 || options.indexOf('--source-map') > -1, isSilent = options.indexOf('-s') > -1 || options.indexOf('--silent') > -1, @@ -114,7 +149,8 @@ 'isSilent': isSilent, 'isTemplate': isTemplate, 'modes': modes, - 'outputPath': outputPath + 'outputPath': outputPath, + 'sourceMapURL': sourceMapURL }; source = fs.readFileSync(filePath, 'utf8'); @@ -186,6 +222,7 @@ this.isSilent = !!options.isSilent; this.isTemplate = !!options.isTemplate; this.outputPath = options.outputPath; + this.sourceMapURL = options.sourceMapURL; var modes = this.modes = options.modes; source = this.source = preprocess(source, options); @@ -304,10 +341,11 @@ function closureCompile(source, mode, callback) { var filePath = this.filePath, isAdvanced = mode == 'advanced', - outputPath = this.outputPath, isMapped = this.isMapped, + options = closureOptions.slice(), + outputPath = this.outputPath, mapPath = getMapPath(outputPath), - options = closureOptions.slice(); + sourceMapURL = this.sourceMapURL || path.basename(mapPath); // remove copyright header to make other modifications easier var license = (/^(?:\s*\/\/.*\s*|\s*\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/\s*)*/.exec(source) || [''])[0]; @@ -369,7 +407,7 @@ if (isMapped) { var mapOutput = fs.readFileSync(mapPath, 'utf8'); fs.unlinkSync(mapPath); - output = output.replace(/[\s;]*$/, '\n/*\n//@ sourceMappingURL=' + path.basename(mapPath)) + '\n*/'; + output = output.replace(/[\s;]*$/, '\n/*\n//@ sourceMappingURL=' + sourceMapURL) + '\n*/'; mapOutput = JSON.parse(mapOutput); mapOutput.file = path.basename(outputPath); diff --git a/test/test-build.js b/test/test-build.js index 64a4dba3d6..11f76e73a8 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -645,7 +645,9 @@ (function() { var mapCommands = [ '-p', - '--source-map' + '-p custom.map', + '--source-map', + '--source-map custom.map' ]; var outputCommands = [ @@ -661,9 +663,10 @@ var basename = path.basename(data.outputPath, '.js'), comment = (/(\s*\/\/.*\s*|\s*\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/\s*)$/.exec(data.source) || [])[0], sources = /foo.js/.test(outputCommand) ? ['foo.js'] : ['lodash' + (outputCommand.length ? '' : '.custom') + '.js'], - sourceMap = JSON.parse(data.sourceMap); + sourceMap = JSON.parse(data.sourceMap), + sourceMapURL = (/\w+(?=\.map$)/.exec(mapCommand) || [basename])[0]; - ok(RegExp('/\\*\\n//@ sourceMappingURL=' + basename + '.map\\n\\*/').test(comment), basename); + ok(RegExp('/\\*\\n//@ sourceMappingURL=' + sourceMapURL + '.map\\n\\*/').test(comment), basename); equal(sourceMap.file, basename + '.js', basename); deepEqual(sourceMap.sources, sources, basename); @@ -674,7 +677,7 @@ if (outputCommand.indexOf('-m') < 0) { callback = _.after(2, callback); } - build(['-s', mapCommand].concat(outputCommand), callback); + build(['-s'].concat(mapCommand.split(' '), outputCommand), callback); }); }); }); From 25e4231d7b9153945f165a111564f230a46713ce Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 17 Feb 2013 16:13:42 -0800 Subject: [PATCH 16/22] Update `_.defer` build dependencies. Former-commit-id: 159f541373b01f259c9509e16c3fc0c2018e6d51 --- build.js | 9 ++++++--- test/test-build.js | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/build.js b/build.js index d87c45dfd2..83aff373ff 100755 --- a/build.js +++ b/build.js @@ -79,7 +79,7 @@ 'countBy': ['forEach', 'identity', 'isEqual', 'keys'], 'debounce': [], 'defaults': ['isArray', 'forEach', 'forOwn'], - 'defer': [], + 'defer': ['bind'], 'delay': [], 'difference': ['indexOf'], 'escape': [], @@ -1526,8 +1526,8 @@ useUnderscoreClone = methods.indexOf('clone') < 0; } // update dependencies - if (isModern || isUnderscore) { - dependencyMap.reduceRight = _.without(dependencyMap.reduceRight, 'isEqual', 'isString'); + if (isLegacy) { + dependencyMap.defer = _.without(dependencyMap.defer, 'bind'); } if (isUnderscore) { dependencyMap.contains = _.without(dependencyMap.contains, 'isString'); @@ -1555,6 +1555,9 @@ dependencyMap.clone = _.without(dependencyMap.clone, 'forEach', 'forOwn'); } } + if (isModern || isUnderscore) { + dependencyMap.reduceRight = _.without(dependencyMap.reduceRight, 'isEqual', 'isString'); + } // add method names explicitly if (includeMethods.length) { diff --git a/test/test-build.js b/test/test-build.js index 11f76e73a8..6cc65d19c9 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -1200,6 +1200,7 @@ 'include=once plus=bind,Chaining', 'category=collections,functions', 'backbone legacy category=utilities minus=first,last', + 'legacy include=defer', 'underscore include=debounce,throttle plus=after minus=throttle', 'underscore mobile strict category=functions exports=amd,global plus=pick,uniq', ] @@ -1214,13 +1215,13 @@ var command = origCommand; if (index == 1) { - if (/mobile/.test(command)) { + if (/legacy|mobile/.test(command)) { return; } command = 'mobile ' + command; } if (index == 2) { - if (/modern/.test(command)) { + if (/legacy|modern/.test(command)) { return; } command = 'modern ' + command; From 8183740c043a9d97652961eb6fb40ac295a6bf68 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 17 Feb 2013 16:38:23 -0800 Subject: [PATCH 17/22] Update vendors. Former-commit-id: 6ab66f9ea6fd881e8c5ed18e84b9a24656496e10 --- build/minify.js | 2 +- vendor/backbone/LICENSE | 4 +- vendor/backbone/backbone.js | 179 +++++++++++++---------------- vendor/backbone/test/collection.js | 85 ++++---------- vendor/backbone/test/events.js | 66 ++--------- vendor/backbone/test/model.js | 30 ++--- 6 files changed, 129 insertions(+), 237 deletions(-) diff --git a/build/minify.js b/build/minify.js index 743fe3e90a..2250669eeb 100755 --- a/build/minify.js +++ b/build/minify.js @@ -19,7 +19,7 @@ var closureId = '23cf67d0f0b979d97631fc108a2a43bb82225994'; /** The Git object ID of `uglifyjs.tar.gz` */ - var uglifyId = '326ede8f4a3d8e0ae82cec7b9579d45892836629'; + var uglifyId = 'a934fb18f8fa2768c6a68de44b6e035fe96a268b'; /** The path of the directory that is the base of the repository */ var basePath = fs.realpathSync(path.join(__dirname, '..')); diff --git a/vendor/backbone/LICENSE b/vendor/backbone/LICENSE index dda0a5809d..f79bb00587 100644 --- a/vendor/backbone/LICENSE +++ b/vendor/backbone/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2010-2013 Jeremy Ashkenas, DocumentCloud +Copyright (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation @@ -19,4 +19,4 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. +OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/vendor/backbone/backbone.js b/vendor/backbone/backbone.js index 0a1669d11f..9682be585c 100644 --- a/vendor/backbone/backbone.js +++ b/vendor/backbone/backbone.js @@ -1,6 +1,6 @@ // Backbone.js 0.9.10 -// (c) 2010-2013 Jeremy Ashkenas, DocumentCloud Inc. +// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc. // Backbone may be freely distributed under the MIT license. // For all details and documentation: // http://backbonejs.org @@ -89,15 +89,15 @@ // Optimized internal dispatch function for triggering events. Tries to // keep the usual cases speedy (most Backbone events have 3 arguments). var triggerEvents = function(events, args) { - var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2]; + var ev, i = -1, l = events.length; switch (args.length) { case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx); return; - case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); + case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, args[0]); return; - case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); + case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, args[0], args[1]); return; - case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); + case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, args[0], args[1], args[2]); return; default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); } @@ -119,24 +119,25 @@ // to a `callback` function. Passing `"all"` will bind the callback to // all events fired. on: function(name, callback, context) { - if (!eventsApi(this, 'on', name, [callback, context]) || !callback) return this; + if (!(eventsApi(this, 'on', name, [callback, context]) && callback)) return this; this._events || (this._events = {}); - var events = this._events[name] || (this._events[name] = []); - events.push({callback: callback, context: context, ctx: context || this}); + var list = this._events[name] || (this._events[name] = []); + list.push({callback: callback, context: context, ctx: context || this}); return this; }, // Bind events to only be triggered a single time. After the first time // the callback is invoked, it will be removed. once: function(name, callback, context) { - if (!eventsApi(this, 'once', name, [callback, context]) || !callback) return this; + if (!(eventsApi(this, 'once', name, [callback, context]) && callback)) return this; var self = this; var once = _.once(function() { self.off(name, once); callback.apply(this, arguments); }); once._callback = callback; - return this.on(name, once, context); + this.on(name, once, context); + return this; }, // Remove one or many callbacks. If `context` is null, removes all @@ -144,7 +145,7 @@ // callbacks for the event. If `name` is null, removes all bound // callbacks for all events. off: function(name, callback, context) { - var retain, ev, events, names, i, l, j, k; + var list, ev, events, names, i, l, j, k; if (!this._events || !eventsApi(this, 'off', name, [callback, context])) return this; if (!name && !callback && !context) { this._events = {}; @@ -154,19 +155,19 @@ names = name ? [name] : _.keys(this._events); for (i = 0, l = names.length; i < l; i++) { name = names[i]; - if (events = this._events[name]) { - this._events[name] = retain = []; + if (list = this._events[name]) { + events = []; if (callback || context) { - for (j = 0, k = events.length; j < k; j++) { - ev = events[j]; + for (j = 0, k = list.length; j < k; j++) { + ev = list[j]; if ((callback && callback !== ev.callback && callback !== ev.callback._callback) || (context && context !== ev.context)) { - retain.push(ev); + events.push(ev); } } } - if (!retain.length) delete this._events[name]; + this._events[name] = events; } } @@ -188,37 +189,35 @@ return this; }, + // An inversion-of-control version of `on`. Tell *this* object to listen to + // an event in another object ... keeping track of what it's listening to. + listenTo: function(obj, name, callback) { + var listeners = this._listeners || (this._listeners = {}); + var id = obj._listenerId || (obj._listenerId = _.uniqueId('l')); + listeners[id] = obj; + obj.on(name, typeof name === 'object' ? this : callback, this); + return this; + }, + // Tell this object to stop listening to either specific events ... or // to every object it's currently listening to. stopListening: function(obj, name, callback) { var listeners = this._listeners; - if (!listeners) return this; - var deleteListener = !name && !callback; - if (typeof name === 'object') callback = this; - if (obj) (listeners = {})[obj._listenerId] = obj; - for (var id in listeners) { - listeners[id].off(name, callback, this); - if (deleteListener) delete this._listeners[id]; + if (!listeners) return; + if (obj) { + obj.off(name, typeof name === 'object' ? this : callback, this); + if (!name && !callback) delete listeners[obj._listenerId]; + } else { + if (typeof name === 'object') callback = this; + for (var id in listeners) { + listeners[id].off(name, callback, this); + } + this._listeners = {}; } return this; } }; - var listenMethods = {listenTo: 'on', listenToOnce: 'once'}; - - // An inversion-of-control versions of `on` and `once`. Tell *this* object to listen to - // an event in another object ... keeping track of what it's listening to. - _.each(listenMethods, function(implementation, method) { - Events[method] = function(obj, name, callback) { - var listeners = this._listeners || (this._listeners = {}); - var id = obj._listenerId || (obj._listenerId = _.uniqueId('l')); - listeners[id] = obj; - if (typeof name === 'object') callback = this; - obj[implementation](name, callback, this); - return this; - }; - }); - // Aliases for backwards compatibility. Events.bind = Events.on; Events.unbind = Events.off; @@ -253,9 +252,6 @@ // A hash of attributes whose current and previous value differ. changed: null, - // The value returned during the last failed validation. - validationError: null, - // The default name for the JSON `id` attribute is `"id"`. MongoDB and // CouchDB users may want to set this to `"_id"`. idAttribute: 'id', @@ -418,14 +414,11 @@ fetch: function(options) { options = options ? _.clone(options) : {}; if (options.parse === void 0) options.parse = true; - var model = this; var success = options.success; - options.success = function(resp) { + options.success = function(model, resp, options) { if (!model.set(model.parse(resp, options), options)) return false; if (success) success(model, resp, options); - model.trigger('sync', model, resp, options); }; - wrapError(this, options); return this.sync('read', this, options); }, @@ -433,7 +426,7 @@ // If the server returns an attributes hash that differs, the model's // state will be `set` again. save: function(key, val, options) { - var attrs, method, xhr, attributes = this.attributes; + var attrs, success, method, xhr, attributes = this.attributes; // Handle both `"key", value` and `{key: value}` -style arguments. if (key == null || typeof key === 'object') { @@ -459,9 +452,8 @@ // After a successful server-side save, the client is (optionally) // updated with the server-side state. if (options.parse === void 0) options.parse = true; - var model = this; - var success = options.success; - options.success = function(resp) { + success = options.success; + options.success = function(model, resp, options) { // Ensure attributes are restored during synchronous saves. model.attributes = attributes; var serverAttrs = model.parse(resp, options); @@ -470,10 +462,9 @@ return false; } if (success) success(model, resp, options); - model.trigger('sync', model, resp, options); }; - wrapError(this, options); + // Finish configuring and sending the Ajax request. method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update'); if (method === 'patch') options.attrs = attrs; xhr = this.sync(method, this, options); @@ -496,17 +487,15 @@ model.trigger('destroy', model, model.collection, options); }; - options.success = function(resp) { + options.success = function(model, resp, options) { if (options.wait || model.isNew()) destroy(); if (success) success(model, resp, options); - if (!model.isNew()) model.trigger('sync', model, resp, options); }; if (this.isNew()) { - options.success(); + options.success(this, null, options); return false; } - wrapError(this, options); var xhr = this.sync('delete', this, options); if (!options.wait) destroy(); @@ -544,8 +533,8 @@ }, // Run validation against the next complete set of model attributes, - // returning `true` if all is well. Otherwise, fire an - // `"invalid"` event and call the invalid callback, if specified. + // returning `true` if all is well. Otherwise, fire a general + // `"error"` event and call the error callback, if specified. _validate: function(attrs, options) { if (!options.validate || !this.validate) return true; attrs = _.extend({}, this.attributes, attrs); @@ -567,6 +556,7 @@ options || (options = {}); if (options.model) this.model = options.model; if (options.comparator !== void 0) this.comparator = options.comparator; + this.models = []; this._reset(); this.initialize.apply(this, arguments); if (models) this.reset(models, _.extend({silent: true}, options)); @@ -601,13 +591,16 @@ var i, l, model, attrs, existing, doSort, add, at, sort, sortAttr; add = []; at = options.at; - sort = this.comparator && (at == null) && options.sort !== false; + sort = this.comparator && (at == null) && options.sort != false; sortAttr = _.isString(this.comparator) ? this.comparator : null; // Turn bare objects into model references, and prevent invalid models // from being added. for (i = 0, l = models.length; i < l; i++) { - if (!(model = this._prepareModel(attrs = models[i], options))) continue; + if (!(model = this._prepareModel(attrs = models[i], options))) { + this.trigger('invalid', this, attrs, options); + continue; + } // If a duplicate is found, prevent it from being added and // optionally merge it into the existing model. @@ -714,7 +707,8 @@ // Get a model from the set by id. get: function(obj) { if (obj == null) return void 0; - return this._byId[obj.id || obj.cid || obj]; + this._idAttr || (this._idAttr = this.model.prototype.idAttribute); + return this._byId[obj.id || obj.cid || obj[this._idAttr] || obj]; }, // Get the model at the given index. @@ -722,11 +716,10 @@ return this.models[index]; }, - // Return models with matching attributes. Useful for simple cases of - // `filter`. - where: function(attrs, first) { - if (_.isEmpty(attrs)) return first ? void 0 : []; - return this[first ? 'find' : 'filter'](function(model) { + // Return models with matching attributes. Useful for simple cases of `filter`. + where: function(attrs) { + if (_.isEmpty(attrs)) return []; + return this.filter(function(model) { for (var key in attrs) { if (attrs[key] !== model.get(key)) return false; } @@ -734,12 +727,6 @@ }); }, - // Return the first model with matching attributes. Useful for simple cases - // of `find`. - findWhere: function(attrs) { - return this.where(attrs, true); - }, - // Force the collection to re-sort itself. You don't need to call this under // normal circumstances, as the set will maintain sort order as each item // is added. @@ -770,7 +757,7 @@ update: function(models, options) { options = _.extend({add: true, merge: true, remove: true}, options); if (options.parse) models = this.parse(models, options); - var attrs, model, i, l, existing; + var model, i, l, existing; var add = [], remove = [], modelMap = {}; // Allow a single model (or no argument) to be passed. @@ -781,12 +768,11 @@ // Determine which models to add and merge, and which to remove. for (i = 0, l = models.length; i < l; i++) { - if (!((attrs = models[i]) instanceof Model)) attrs = _.clone(attrs); - if (!(model = this._prepareModel(attrs, options))) continue; + model = models[i]; existing = this.get(model); if (options.remove && existing) modelMap[existing.cid] = true; if ((options.add && !existing) || (options.merge && existing)) { - add.push(models[i]); + add.push(model); } } if (options.remove) { @@ -811,7 +797,7 @@ for (var i = 0, l = this.models.length; i < l; i++) { this._removeReference(this.models[i]); } - options.previousModels = this.models; + options.previousModels = this.models.slice(); this._reset(); if (models) this.add(models, _.extend({silent: true}, options)); if (!options.silent) this.trigger('reset', this, options); @@ -825,14 +811,11 @@ options = options ? _.clone(options) : {}; if (options.parse === void 0) options.parse = true; var success = options.success; - var collection = this; - options.success = function(resp) { + options.success = function(collection, resp, options) { var method = options.update ? 'update' : 'reset'; collection[method](resp, options); if (success) success(collection, resp, options); - collection.trigger('sync', collection, resp, options); }; - wrapError(this, options); return this.sync('read', this, options); }, @@ -845,7 +828,7 @@ if (!options.wait) this.add(model, options); var collection = this; var success = options.success; - options.success = function(resp) { + options.success = function(model, resp, options) { if (options.wait) collection.add(model, options); if (success) success(model, resp, options); }; @@ -867,7 +850,7 @@ // Reset all internal state. Called when the collection is reset. _reset: function() { this.length = 0; - this.models = []; + this.models.length = 0; this._byId = {}; }, @@ -880,10 +863,7 @@ options || (options = {}); options.collection = this; var model = new this.model(attrs, options); - if (!model._validate(attrs, options)) { - this.trigger('invalid', this, attrs, options); - return false; - } + if (!model._validate(attrs, options)) return false; return model; }, @@ -1320,7 +1300,7 @@ // This only works for delegate-able events: not `focus`, `blur`, and // not `change`, `submit`, and `reset` in Internet Explorer. delegateEvents: function(events) { - if (!(events || (events = _.result(this, 'events')))) return this; + if (!(events || (events = _.result(this, 'events')))) return; this.undelegateEvents(); for (var key in events) { var method = events[key]; @@ -1336,7 +1316,6 @@ this.$el.on(eventName, selector, method); } } - return this; }, // Clears all callbacks previously bound to the view with `delegateEvents`. @@ -1344,7 +1323,6 @@ // Backbone views attached to the same DOM element. undelegateEvents: function() { this.$el.off('.delegateEvents' + this.cid); - return this; }, // Performs the initial configuration of a View with a set of options. @@ -1447,6 +1425,18 @@ params.processData = false; } + var success = options.success; + options.success = function(resp) { + if (success) success(model, resp, options); + model.trigger('sync', model, resp, options); + }; + + var error = options.error; + options.error = function(xhr) { + if (error) error(model, xhr, options); + model.trigger('error', model, xhr, options); + }; + // Make the request, allowing the user to override any Ajax options. var xhr = options.xhr = Backbone.ajax(_.extend(params, options)); model.trigger('request', model, xhr, options); @@ -1505,13 +1495,4 @@ throw new Error('A "url" property or function must be specified'); }; - // Wrap an optional error callback with a fallback error event. - var wrapError = function (model, options) { - var error = options.error; - options.error = function(resp) { - if (error) error(model, resp, options); - model.trigger('error', model, resp, options); - }; - }; - }).call(this); diff --git a/vendor/backbone/test/collection.js b/vendor/backbone/test/collection.js index c67600b6d1..64193fdee3 100644 --- a/vendor/backbone/test/collection.js +++ b/vendor/backbone/test/collection.js @@ -70,20 +70,22 @@ $(document).ready(function() { equal(col.get(col.first().cid), col.first()); }); - test("get with non-default ids", 5, function() { + test("get with non-default ids", 4, function() { var col = new Backbone.Collection(); - var MongoModel = Backbone.Model.extend({idAttribute: '_id'}); + var MongoModel = Backbone.Model.extend({ + idAttribute: '_id' + }); var model = new MongoModel({_id: 100}); - col.add(model); + col.push(model); equal(col.get(100), model); - equal(col.get(model.cid), model); - equal(col.get(model), model); - equal(col.get(101), void 0); + model.set({_id: 101}); + equal(col.get(101), model); - var col2 = new Backbone.Collection(); - col2.model = MongoModel; - col2.add(model.attributes); - equal(col2.get(model.clone()), col2.first()); + var Col2 = Backbone.Collection.extend({ model: MongoModel }); + var col2 = new Col2(); + col2.push(model); + equal(col2.get({_id: 101}), model); + equal(col2.get(model.clone()), model); }); test("update index when id changes", 3, function() { @@ -360,7 +362,9 @@ $(document).ready(function() { test("model destroy removes from all collections", 3, function() { var e = new Backbone.Model({id: 5, title: 'Othello'}); - e.sync = function(method, model, options) { options.success(); }; + e.sync = function(method, model, options) { + options.success(model, [], options); + }; var colE = new Backbone.Collection([e]); var colF = new Backbone.Collection([e]); e.destroy(); @@ -392,15 +396,6 @@ $(document).ready(function() { equal(this.syncArgs.options.parse, false); }); - test("fetch with an error response triggers an error event", 1, function () { - var collection = new Backbone.Collection(); - collection.on('error', function () { - ok(true); - }); - collection.sync = function (method, model, options) { options.error(); }; - collection.fetch(); - }); - test("ensure fetch only parses once", 1, function() { var collection = new Backbone.Collection; var counter = 0; @@ -410,7 +405,7 @@ $(document).ready(function() { }; collection.url = '/test'; collection.fetch(); - this.syncArgs.options.success(); + this.syncArgs.options.success([]); equal(counter, 1); }); @@ -466,10 +461,9 @@ $(document).ready(function() { equal(JSON.stringify(col), '[{"id":3,"label":"a"},{"id":2,"label":"b"},{"id":1,"label":"c"},{"id":0,"label":"d"}]'); }); - test("where and findWhere", 8, function() { - var model = new Backbone.Model({a: 1}); + test("where", 6, function() { var coll = new Backbone.Collection([ - model, + {a: 1}, {a: 1}, {a: 1, b: 2}, {a: 2, b: 2}, @@ -481,8 +475,6 @@ $(document).ready(function() { equal(coll.where({b: 1}).length, 0); equal(coll.where({b: 2}).length, 2); equal(coll.where({a: 1, b: 2}).length, 1); - equal(coll.findWhere({a: 1}), model); - equal(coll.findWhere({a: 4}), void 0); }); test("Underscore methods", 13, function() { @@ -492,10 +484,10 @@ $(document).ready(function() { equal(col.indexOf(b), 1); equal(col.size(), 4); equal(col.rest().length, 3); - ok(!_.include(col.rest(), a)); - ok(_.include(col.rest(), d)); + ok(!_.include(col.rest()), a); + ok(!_.include(col.rest()), d); ok(!col.isEmpty()); - ok(!_.include(col.without(d), d)); + ok(!_.include(col.without(d)), d); equal(col.max(function(model){ return model.id; }).id, 3); equal(col.min(function(model){ return model.id; }).id, 0); deepEqual(col.chain() @@ -519,7 +511,7 @@ $(document).ready(function() { test("reset", 10, function() { var resetCount = 0; - var models = col.models; + var models = col.models.slice(); col.on('reset', function() { resetCount += 1; }); col.reset([]); equal(resetCount, 1); @@ -710,7 +702,9 @@ $(document).ready(function() { test("#1447 - create with wait adds model.", 1, function() { var collection = new Backbone.Collection; var model = new Backbone.Model; - model.sync = function(method, model, options){ options.success(); }; + model.sync = function(method, model, options){ + options.success(model, [], options); + }; collection.on('add', function(){ ok(true); }); collection.create(model, {wait: true}); }); @@ -934,35 +928,6 @@ $(document).ready(function() { equal(col.length, 1); }); - test("`update` and model level `parse`", function() { - var Model = Backbone.Model.extend({ - parse: function (res) { return res.model; } - }); - var Collection = Backbone.Collection.extend({ - model: Model, - parse: function (res) { return res.models; } - }); - var model = new Model({id: 1}); - var collection = new Collection(model); - collection.update({models: [ - {model: {id: 1}}, - {model: {id: 2}} - ]}, {parse: true}); - equal(collection.first(), model); - }); - - test("`update` data is only parsed once", function() { - var collection = new Backbone.Collection(); - collection.model = Backbone.Model.extend({ - parse: function (data) { - equal(data.parsed, void 0); - data.parsed = true; - return data; - } - }); - collection.update({}, {parse: true}); - }); - test("#1894 - Push should not trigger a sort", 0, function() { var Collection = Backbone.Collection.extend({ comparator: 'id', diff --git a/vendor/backbone/test/events.js b/vendor/backbone/test/events.js index 920943ad83..f94d32c3d4 100644 --- a/vendor/backbone/test/events.js +++ b/vendor/backbone/test/events.js @@ -99,43 +99,6 @@ $(document).ready(function() { a.listenTo(b, 'event2', cb); a.stopListening(null, {event: cb}); b.trigger('event event2'); - b.off(); - a.listenTo(b, 'event event2', cb); - a.stopListening(null, 'event'); - a.stopListening(); - b.trigger('event2'); - }); - - test("listenToOnce and stopListening", 1, function() { - var a = _.extend({}, Backbone.Events); - var b = _.extend({}, Backbone.Events); - a.listenToOnce(b, 'all', function() { ok(true); }); - b.trigger('anything'); - b.trigger('anything'); - a.listenToOnce(b, 'all', function() { ok(false); }); - a.stopListening(); - b.trigger('anything'); - }); - - test("listenTo, listenToOnce and stopListening", 1, function() { - var a = _.extend({}, Backbone.Events); - var b = _.extend({}, Backbone.Events); - a.listenToOnce(b, 'all', function() { ok(true); }); - b.trigger('anything'); - b.trigger('anything'); - a.listenTo(b, 'all', function() { ok(false); }); - a.stopListening(); - b.trigger('anything'); - }); - - test("listenTo and stopListening with event maps", 1, function() { - var a = _.extend({}, Backbone.Events); - var b = _.extend({}, Backbone.Events); - a.listenTo(b, {change: function(){ ok(true); }}); - b.trigger('change'); - a.listenTo(b, {change: function(){ ok(false); }}); - a.stopListening(); - b.trigger('change'); }); test("listenTo yourself", 1, function(){ @@ -296,6 +259,18 @@ $(document).ready(function() { obj.trigger('x y'); }); + test("off is chainable", 3, function() { + var obj = _.extend({}, Backbone.Events); + // With no events + ok(obj.off() === obj); + // When removing all events + obj.on('event', function(){}, obj); + ok(obj.off() === obj); + // When removing some events + obj.on('event', function(){}, obj); + ok(obj.off('event') === obj); + }); + test("#1310 - off does not skip consecutive events", 0, function() { var obj = _.extend({}, Backbone.Events); obj.on('event', function() { ok(false); }, obj); @@ -425,21 +400,4 @@ $(document).ready(function() { _.extend({}, Backbone.Events).once('event').trigger('event'); }); - test("event functions are chainable", function() { - var obj = _.extend({}, Backbone.Events); - var obj2 = _.extend({}, Backbone.Events); - var fn = function() {}; - equal(obj, obj.trigger('noeventssetyet')); - equal(obj, obj.off('noeventssetyet')); - equal(obj, obj.stopListening('noeventssetyet')); - equal(obj, obj.on('a', fn)); - equal(obj, obj.once('c', fn)); - equal(obj, obj.trigger('a')); - equal(obj, obj.listenTo(obj2, 'a', fn)); - equal(obj, obj.listenToOnce(obj2, 'b', fn)); - equal(obj, obj.off('a c')); - equal(obj, obj.stopListening(obj2, 'a')); - equal(obj, obj.stopListening()); - }); - }); diff --git a/vendor/backbone/test/model.js b/vendor/backbone/test/model.js index 088032d7f6..7bbb8337c7 100644 --- a/vendor/backbone/test/model.js +++ b/vendor/backbone/test/model.js @@ -401,7 +401,7 @@ $(document).ready(function() { if (attrs.admin) return "Can't change admin status."; }; model.sync = function(method, model, options) { - options.success.call(this, {admin: true}); + options.success.call(this, this, {admin: true}, options); }; model.on('invalid', function(model, error) { lastError = error; @@ -418,19 +418,6 @@ $(document).ready(function() { ok(_.isEqual(this.syncArgs.model, doc)); }); - test("save, fetch, destroy triggers error event when an error occurs", 3, function () { - var model = new Backbone.Model(); - model.on('error', function () { - ok(true); - }); - model.sync = function (method, model, options) { - options.error(); - }; - model.save({data: 2, id: 1}); - model.fetch(); - model.destroy(); - }); - test("save with PATCH", function() { doc.clear().set({id: 1, a: 1, b: 2, c: 3, d: 4}); doc.save(); @@ -448,7 +435,7 @@ $(document).ready(function() { test("save in positional style", 1, function() { var model = new Backbone.Model(); model.sync = function(method, model, options) { - options.success(); + options.success(model, {}, options); }; model.save('title', 'Twelfth Night'); equal(model.get('title'), 'Twelfth Night'); @@ -457,8 +444,8 @@ $(document).ready(function() { test("save with non-object success response", 2, function () { var model = new Backbone.Model(); model.sync = function(method, model, options) { - options.success('', options); - options.success(null, options); + options.success(model, '', options); + options.success(model, null, options); }; model.save({testing:'empty'}, { success: function (model) { @@ -733,7 +720,7 @@ $(document).ready(function() { test("#1030 - `save` with `wait` results in correct attributes if success is called during sync", 2, function() { var model = new Backbone.Model({x: 1, y: 2}); model.sync = function(method, model, options) { - options.success(); + options.success(model, {}, options); }; model.on("change:x", function() { ok(true); }); model.save({x: 3}, {wait: true}); @@ -906,7 +893,7 @@ $(document).ready(function() { } }; model.sync = function(method, model, options) { - options.success(); + options.success(model, {}, options); }; model.save({id: 1}, opts); model.fetch(opts); @@ -915,8 +902,9 @@ $(document).ready(function() { test("#1412 - Trigger 'sync' event.", 3, function() { var model = new Backbone.Model({id: 1}); - model.sync = function (method, model, options) { options.success(); }; + model.url = '/test'; model.on('sync', function(){ ok(true); }); + Backbone.ajax = function(settings){ settings.success(); }; model.fetch(); model.save(); model.destroy(); @@ -962,7 +950,7 @@ $(document).ready(function() { var Model = Backbone.Model.extend({ sync: function(method, model, options) { setTimeout(function(){ - options.success(); + options.success(model, {}, options); start(); }, 0); } From 8dcc15f4d3e36025a7c75579931cf996ec9c504d Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 17 Feb 2013 18:15:41 -0800 Subject: [PATCH 18/22] Ensure `setImmediate` is not minified by the Closure Compiler. Former-commit-id: 74c121d45854dba2aaaa65558c3e1ca8effd3096 --- build/pre-compile.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/pre-compile.js b/build/pre-compile.js index 020801c5dc..94e1011b34 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -70,6 +70,7 @@ 'bind', 'bindAll', 'bindKey', + 'clearTimeout', 'clone', 'cloneDeep', 'collect', @@ -164,6 +165,8 @@ 'rest', 'result', 'select', + 'setImmediate', + 'setTimeout', 'shuffle', 'size', 'some', From 96bac9c149302b9862b4b74242fcb2a066f22e93 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 17 Feb 2013 20:44:28 -0800 Subject: [PATCH 19/22] Add `legacy underscore` build test. Former-commit-id: f56e254f7c2fb4c4adeac16b56c789dd8af8a986 --- test/test-build.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test-build.js b/test/test-build.js index 6cc65d19c9..759d98ebc1 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -1201,6 +1201,7 @@ 'category=collections,functions', 'backbone legacy category=utilities minus=first,last', 'legacy include=defer', + 'legacy underscore', 'underscore include=debounce,throttle plus=after minus=throttle', 'underscore mobile strict category=functions exports=amd,global plus=pick,uniq', ] @@ -1227,7 +1228,7 @@ command = 'modern ' + command; } if (index == 3) { - if (/category|underscore/.test(command)) { + if (/category|legacy|underscore/.test(command)) { return; } command = 'underscore ' + command; From 4bc49978d1b040646ed2fa4b1d738d51346d5712 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 17 Feb 2013 22:40:57 -0800 Subject: [PATCH 20/22] Avoid using `setImmediate` in IE because it cannot be cleared with `clearTimeout`. Former-commit-id: 836d49c6440b2313f1885456645ed4a00ab82ae6 --- build.js | 35 ++++-- dist/lodash.compat.js | 15 ++- dist/lodash.compat.min.js | 72 ++++++------ dist/lodash.js | 15 ++- dist/lodash.min.js | 68 +++++------ dist/lodash.underscore.js | 15 ++- dist/lodash.underscore.min.js | 56 ++++----- doc/README.md | 214 +++++++++++++++++----------------- lodash.js | 15 ++- 9 files changed, 274 insertions(+), 231 deletions(-) diff --git a/build.js b/build.js index 83aff373ff..b482ed7d7d 100755 --- a/build.js +++ b/build.js @@ -472,8 +472,14 @@ var source = [ ';(function(window) {', - " var freeExports = typeof exports == 'object' && exports &&", - " (typeof global == 'object' && global && global == global.global && (window = global), exports);", + " var freeExports = typeof exports == 'object' && exports;", + '', + " var freeModule = typeof module == 'object' && module && module.exports == freeExports && module;", + '', + " var freeGlobal = typeof global == 'object' && global;", + ' if (freeGlobal.global === freeGlobal) {', + ' window = freeGlobal;', + ' }', '', ' var templates = {},', ' _ = window._;', @@ -505,8 +511,8 @@ ' lodash.templates = lodash.extend(lodash.templates || {}, templates);', ' });', " } else if (freeExports) {", - " if (typeof module == 'object' && module && module.exports == freeExports) {", - ' (module.exports = templates).templates = templates;', + " if (freeModule) {", + ' (freeModule.exports = templates).templates = templates;', ' } else {', ' freeExports.templates = templates;', ' }', @@ -1184,6 +1190,17 @@ .replace(/(?:\s*\/\/.*)*\n( *)if *\(hasObjectSpliceBug[\s\S]+?(?:{\s*}|\n\1})/, ''); } + /** + * Removes the `setImmediate` fork of `_.defer`. + * + * @private + * @param {String} source The source to process. + * @returns {String} Returns the modified source. + */ + function removeSetImmediate(source) { + return source.replace(/(?:\s*\/\/.*)*\n( *)if *\(isV8 *&& *freeModule[\s\S]+?\n\1}/, ''); + } + /** * Removes a given variable from `source`. * @@ -2110,6 +2127,8 @@ /*----------------------------------------------------------------------*/ if (isLegacy) { + source = removeSetImmediate(source); + _.each(['isBindFast', 'isV8', 'nativeBind', 'nativeIsArray', 'nativeKeys', 'reNative'], function(varName) { source = removeVar(source, varName); }); @@ -2119,11 +2138,6 @@ return match.replace(/(?:\s*\/\/.*)*\s*return isBindFast[^:]+:\s*/, 'return '); }); - // remove native `setImmediate` branch in `_.defer` - source = source.replace(matchFunction(source, 'defer'), function(match) { - return match.replace(/reNative.*?\|\|\s*/, ''); - }); - // remove native `Array.isArray` branch in `_.isArray` source = source.replace(matchFunction(source, 'isArray'), function(match) { return match.replace(/nativeIsArray * \|\|\s*/, ''); @@ -2296,7 +2310,7 @@ source = source.replace(/(?: *\/\/.*\n)*( *)if *\(typeof +define[\s\S]+?else /, '$1'); } if (!isNode) { - source = source.replace(/(?: *\/\/.*\n)*( *)if *\(typeof +module[\s\S]+?else *{([\s\S]+?\n)\1}\n/, '$1$2'); + source = source.replace(/(?: *\/\/.*\n)*( *)if *\(freeModule[\s\S]+?else *{([\s\S]+?\n)\1}\n/, '$1$2'); } if (!isCommonJS) { source = source.replace(/(?: *\/\/.*\n)*(?:( *)else *{)?\s*freeExports\.\w+ *=[\s\S]+?(?:\n\1})?\n/, ''); @@ -2380,6 +2394,7 @@ source = removeHasEnumPrototype(source); } if (isRemoved(source, 'createIterator', 'bind', 'keys')) { + source = removeSetImmediate(source); source = removeVar(source, 'isBindFast'); source = removeVar(source, 'isV8'); source = removeVar(source, 'nativeBind'); diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index edd4e1cf8f..4ee3363328 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -12,6 +12,9 @@ /** Detect free variable `exports` */ var freeExports = typeof exports == 'object' && exports; + /** Detect free variable `module` */ + var freeModule = typeof module == 'object' && module && module.exports == freeExports && module; + /** Detect free variable `global` and use it as `window` */ var freeGlobal = typeof global == 'object' && global; if (freeGlobal.global === freeGlobal) { @@ -4224,10 +4227,14 @@ * _.defer(function() { alert('deferred'); }); * // returns from the function before `alert` is called */ - var defer = reNative.test(window.setImmediate) && bind(setImmediate, window) || function(func) { + function defer(func) { var args = slice(arguments, 1); return setTimeout(function() { func.apply(undefined, args); }, 1); - }; + } + // use Node's `setImmediate`, if available + if (isV8 && freeModule && typeof setImmediate == 'function') { + defer = bind(setImmediate, window); + } /** * Creates a function that memoizes the result of `func`. If `resolver` is @@ -5130,8 +5137,8 @@ // check for `exports` after `define` in case a build optimizer adds an `exports` object else if (freeExports) { // in Node.js or RingoJS v0.8.0+ - if (typeof module == 'object' && module && module.exports == freeExports) { - (module.exports = lodash)._ = lodash; + if (freeModule) { + (freeModule.exports = lodash)._ = lodash; } // in Narwhal or RingoJS v0.7.0- else { diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 1e19845b8f..27226a1823 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -4,39 +4,39 @@ * Build: `lodash -o ./dist/lodash.compat.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ -;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||it);if(u){var o={};for(r=t-1;++rt||typeof n=="undefined")return 1;if(ne;e++)r+="j='"+t.k[e]+"';if(","constructor"==t.k[e]&&(r+="!(g&&g.prototype===n)&&"),r+="i.call(n,j)){"+t.h+"}"; -return(t.b||t.i)&&(r+="}"),r+=t.c+";return u",Function("f,i,k,l,m,r,p","return function("+n+"){"+r+"}")(f,Ot,y,lr,A,rr,$t)}function c(n){return"\\"+er[n]}function l(n){return sr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);var e=-1;r=r-t||0;for(var u=Array(0>r?0:r);++er?It(0,u+r):r)||0,typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):z(n,t,r)):fr(n,function(n){return++eo&&(o=a)}}else t=!t&&A(n)?u:f(t,r),fr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function D(n,t,r,e){var u=3>arguments.length;if(t=f(t,e,4),lr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var a=pr(n),o=a.length;else Xt&&A(n)&&(u=n.split(""));return t=f(t,e,4),I(n,function(n,e,f){e=a?a[--o]:--o,r=i?(i=W,u[e]):t(r,u[e],e,f)}),r}function B(n,t,r){var e;if(t=f(t,r),lr(n)){r=-1;for(var u=n.length;++rr?It(0,u+r):r||0)-1;else if(r)return e=K(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])z(a,p))&&((r||c)&&a.push(p),i.push(e))}return i}function U(n,t){return Vt||Et&&2/g,ht=/($^)/,mt=/[&<>"']/g,dt=/['\n\r\t\u2028\u2029\\]/g,_t="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),bt=Math.ceil,jt=rt.concat,wt=Math.floor,xt=vt.test(xt=Object.getPrototypeOf)&&xt,Ot=et.hasOwnProperty,At=rt.push,St=et.toString,Et=vt.test(Et=v.bind)&&Et,kt=vt.test(kt=Array.isArray)&&kt,Nt=n.isFinite,Rt=n.isNaN,$t=vt.test($t=Object.keys)&&$t,It=Math.max,Ft=Math.min,qt=Math.random,Dt="[object Arguments]",Tt="[object Array]",Bt="[object Boolean]",Mt="[object Date]",Pt="[object Number]",zt="[object Object]",Ct="[object RegExp]",Kt="[object String]",Lt=!!n.attachEvent,Ut=Et&&!/\n|true/.test(Et+Lt),Vt=Et&&!Ut,Gt=$t&&(Lt||Ut),Ht=(Ht={0:1,length:1},rt.splice.call(Ht,0,1),Ht[0]),Jt=J; -(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Jt=!r;Z=!/valueOf/.test(t),nt=n.propertyIsEnumerable("prototype"),tt="x"!=t[0]})(1);var Qt=arguments.constructor==Object,Wt=!y(arguments),Xt="xx"!="x"[0]+Object("x")[0];try{var Yt=St.call(document)==zt&&!({toString:0}+"")}catch(Zt){}var nr={"[object Function]":W};nr[Dt]=nr[Tt]=nr[Bt]=nr[Mt]=nr[Pt]=nr[zt]=nr[Ct]=nr[Kt]=J;var tr={};tr[Tt]=Array,tr[Bt]=Boolean,tr[Mt]=Date,tr[zt]=Object,tr[Pt]=Number,tr[Ct]=RegExp,tr[Kt]=String; -var rr={"boolean":W,"function":J,object:J,number:W,string:W,undefined:W},er={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:yt,variable:"",imports:{_:r}};var ur={a:"q,w,h",l:"var a=arguments,b=0,c=typeof h=='number'?2:a.length;while(++b":">",'"':""","'":"'"},vr=b(sr),gr=a(ur,{l:ur.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=f(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[j]=d?d(u[j],n[j]):n[j]"}),yr=a(ur); -w(/x/)&&(w=function(n){return n instanceof Function||"[object Function]"==St.call(n)});var hr=xt?function(n){if(!n||typeof n!="object")return W;var t=n.valueOf,r=typeof t=="function"&&(r=xt(t))&&xt(r);return r?n==r||xt(n)==r&&!y(n):h(n)}:h,mr=F,dr=R,_r=vt.test(n.n)&&U(setImmediate,n)||function(n){var r=v(arguments,1);return setTimeout(function(){n.apply(t,r)},1)};r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},r.assign=gr,r.at=function(n){var t=-1,r=jt.apply(rt,v(arguments,1)),e=r.length,u=Array(e); -for(Xt&&A(n)&&(n=n.split(""));++tz(c,l)){f&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;a.push(l)}}return a},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return I(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=pr,r.map=F,r.max=q,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return Ot.call(r,e)?r[e]:r[e]=n.apply(this,arguments) -}},r.merge=S,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&lr(n)){r=-1;for(var i=n.length;++rz(o,r,1))&&(u[r]=n)}),u},r.once=function(n){var t,r; -return function(){return t?r:(t=J,r=n.apply(this,arguments),n=Q,r)}},r.pairs=function(n){for(var t=-1,r=pr(n),e=r.length,u=Array(e);++tr?It(0,e+r):Ft(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=G,r.noConflict=function(){return n._=ft,this},r.random=function(n,t){return n==Q&&t==Q&&(t=1),n=+n||0,t==Q&&(t=n,n=0),n+wt(qt()*((+t||0)-n+1)) -},r.reduce=D,r.reduceRight=T,r.result=function(n,r){var e=n?n[r]:t;return w(e)?n[r]():e},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:pr(n).length},r.some=B,r.sortedIndex=K,r.template=function(n,e,u){var o=r.templateSettings;n||(n=""),u=yr({},u,o);var i,f=yr({},u.imports,o.imports),o=pr(f),f=E(f),a=0,l=u.interpolate||ht,p="__p+='";n.replace(RegExp((u.escape||ht).source+"|"+l.source+"|"+(l===yt?gt:ht).source+"|"+(u.evaluate||ht).source+"|$","g"),function(t,r,e,u,o,f){return e||(e=u),p+=n.slice(a,f).replace(dt,c),r&&(p+="'+__e("+r+")+'"),o&&(i=J,p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),a=f+t.length,t -}),p+="';\n",l=u=u.variable,l||(u="obj",p="with("+u+"){"+p+"}"),p=(i?p.replace(ct,""):p).replace(lt,"$1").replace(pt,"$1;"),p="function("+u+"){"+(l?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+p+"return __p}";try{var s=Function(o,"return "+p).apply(t,f)}catch(v){throw v.source=p,v}return e?s(e):(s.source=p,s)},r.unescape=function(n){return n==Q?"":(n+"").replace(at,g)},r.uniqueId=function(n){var t=++ut;return(n==Q?"":n+"")+t -},r.all=N,r.any=B,r.detect=$,r.foldl=D,r.foldr=T,r.include=k,r.inject=D,cr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return At.apply(t,arguments),n.apply(r,t)})}),r.first=M,r.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=Q){var o=u;for(t=f(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==Q||r)return n[u-1];return v(n,It(0,u-e))}},r.take=M,r.head=M,cr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e); -return t==Q||e&&typeof t!="function"?u:new r(u)})}),r.VERSION="1.0.0",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=H,r.prototype.valueOf=H,fr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),fr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),fr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments)) -}}),Ht&&fr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):X?typeof module=="object"&&module&&module.exports==X?(module.exports=r)._=r:X._=r:n._=r})(this); \ No newline at end of file +;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||at);if(u){var o={};for(r=t-1;++rt||typeof n=="undefined")return 1;if(ne;e++)r+="j='"+t.k[e]+"';if(","constructor"==t.k[e]&&(r+="!(g&&g.prototype===n)&&"),r+="i.call(n,j)){"+t.h+"}"; +return(t.b||t.i)&&(r+="}"),r+=t.c+";return u",Function("f,i,k,l,m,r,p","return function("+n+"){"+r+"}")(f,St,y,sr,A,ur,Ft)}function c(n){return"\\"+or[n]}function l(n){return gr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);var e=-1;r=r-t||0;for(var u=Array(0>r?0:r);++er?qt(0,u+r):r)||0,typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):z(n,t,r)):cr(n,function(n){return++eo&&(o=a)}}else t=!t&&A(n)?u:f(t,r),cr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function D(n,t,r,e){var u=3>arguments.length;if(t=f(t,e,4),sr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var a=vr(n),o=a.length;else Zt&&A(n)&&(u=n.split(""));return t=f(t,e,4),$(n,function(n,e,f){e=a?a[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,f)}),r}function B(n,t,r){var e;if(t=f(t,r),sr(n)){r=-1;for(var u=n.length;++rr?qt(0,u+r):r||0)-1;else if(r)return e=K(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])z(a,p))&&((r||c)&&a.push(p),i.push(e))}return i}function U(n,t){return Ht||It&&2/g,dt=/($^)/,_t=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,jt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),wt=Math.ceil,xt=ut.concat,Ot=Math.floor,At=yt.test(At=Object.getPrototypeOf)&&At,St=ot.hasOwnProperty,Et=ut.push,kt=ot.toString,It=yt.test(It=v.bind)&&It,Nt=yt.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,$t=n.isNaN,Ft=yt.test(Ft=Object.keys)&&Ft,qt=Math.max,Dt=Math.min,Tt=Math.random,Bt="[object Arguments]",Mt="[object Array]",Pt="[object Boolean]",zt="[object Date]",Ct="[object Number]",Kt="[object Object]",Lt="[object RegExp]",Ut="[object String]",Vt=!!n.attachEvent,Gt=It&&!/\n|true/.test(It+Vt),Ht=It&&!Gt,Jt=Ft&&(Vt||Gt),Qt=(Qt={0:1,length:1},ut.splice.call(Qt,0,1),Qt[0]),Wt=Q; +(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Wt=!r;tt=!/valueOf/.test(t),rt=n.propertyIsEnumerable("prototype"),et="x"!=t[0]})(1);var Xt=arguments.constructor==Object,Yt=!y(arguments),Zt="xx"!="x"[0]+Object("x")[0];try{var nr=kt.call(document)==Kt&&!({toString:0}+"")}catch(tr){}var rr={"[object Function]":X};rr[Bt]=rr[Mt]=rr[Pt]=rr[zt]=rr[Ct]=rr[Kt]=rr[Lt]=rr[Ut]=Q;var er={};er[Mt]=Array,er[Pt]=Boolean,er[zt]=Date,er[Kt]=Object,er[Ct]=Number,er[Lt]=RegExp,er[Ut]=String; +var ur={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},or={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:{_:r}};var ir={a:"q,w,h",l:"var a=arguments,b=0,c=typeof h=='number'?2:a.length;while(++b":">",'"':""","'":"'"},yr=b(gr),hr=a(ir,{l:ir.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=f(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[j]=d?d(u[j],n[j]):n[j]"}),mr=a(ir); +w(/x/)&&(w=function(n){return n instanceof Function||"[object Function]"==kt.call(n)});var dr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!y(n):h(n)}:h,_r=F,br=N;Gt&&Z&&typeof setImmediate=="function"&&(V=U(setImmediate,n)),r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},r.assign=hr,r.at=function(n){var t=-1,r=xt.apply(ut,v(arguments,1)),e=r.length,u=Array(e);for(Zt&&A(n)&&(n=n.split(""));++tz(c,l)){f&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n; +a.push(l)}}return a},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return $(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=vr,r.map=F,r.max=q,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return St.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=S,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&sr(n)){r=-1;for(var i=n.length;++rz(o,r,1))&&(u[r]=n)}),u},r.once=function(n){var t,r;return function(){return t?r:(t=Q,r=n.apply(this,arguments),n=W,r)}},r.pairs=function(n){for(var t=-1,r=vr(n),e=r.length,u=Array(e);++tr?qt(0,e+r):Dt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=ct,this},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Tt()*((+t||0)-n+1))},r.reduce=D,r.reduceRight=T,r.result=function(n,r){var e=n?n[r]:t;return w(e)?n[r]():e},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:vr(n).length +},r.some=B,r.sortedIndex=K,r.template=function(n,e,u){var o=r.templateSettings;n||(n=""),u=mr({},u,o);var i,f=mr({},u.imports,o.imports),o=vr(f),f=E(f),a=0,l=u.interpolate||dt,p="__p+='";n.replace(RegExp((u.escape||dt).source+"|"+l.source+"|"+(l===mt?ht:dt).source+"|"+(u.evaluate||dt).source+"|$","g"),function(t,r,e,u,o,f){return e||(e=u),p+=n.slice(a,f).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(i=Q,p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),a=f+t.length,t}),p+="';\n",l=u=u.variable,l||(u="obj",p="with("+u+"){"+p+"}"),p=(i?p.replace(pt,""):p).replace(st,"$1").replace(vt,"$1;"),p="function("+u+"){"+(l?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+p+"return __p}"; +try{var s=Function(o,"return "+p).apply(t,f)}catch(v){throw v.source=p,v}return e?s(e):(s.source=p,s)},r.unescape=function(n){return n==W?"":(n+"").replace(lt,g)},r.uniqueId=function(n){var t=++it;return(n==W?"":n+"")+t},r.all=I,r.any=B,r.detect=R,r.foldl=D,r.foldr=T,r.include=k,r.inject=D,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return Et.apply(t,arguments),n.apply(r,t)})}),r.first=M,r.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=W){var o=u; +for(t=f(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==W||r)return n[u-1];return v(n,qt(0,u-e))}},r.take=M,r.head=M,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e&&typeof t!="function"?u:new r(u)})}),r.VERSION="1.0.0",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,cr(["join","pop","shift"],function(n){var t=ut[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),cr(["push","reverse","sort","unshift"],function(n){var t=ut[n]; +r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),cr(["concat","slice","splice"],function(n){var t=ut[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments))}}),Qt&&cr(["pop","shift","splice"],function(n){var t=ut[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r +})):Y?Z?(Z.exports=r)._=r:Y._=r:n._=r})(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index 09c2830cc0..c9100cac17 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -12,6 +12,9 @@ /** Detect free variable `exports` */ var freeExports = typeof exports == 'object' && exports; + /** Detect free variable `module` */ + var freeModule = typeof module == 'object' && module && module.exports == freeExports && module; + /** Detect free variable `global` and use it as `window` */ var freeGlobal = typeof global == 'object' && global; if (freeGlobal.global === freeGlobal) { @@ -4074,10 +4077,14 @@ * _.defer(function() { alert('deferred'); }); * // returns from the function before `alert` is called */ - var defer = reNative.test(window.setImmediate) && bind(setImmediate, window) || function(func) { + function defer(func) { var args = slice(arguments, 1); return setTimeout(function() { func.apply(undefined, args); }, 1); - }; + } + // use Node's `setImmediate`, if available + if (isV8 && freeModule && typeof setImmediate == 'function') { + defer = bind(setImmediate, window); + } /** * Creates a function that memoizes the result of `func`. If `resolver` is @@ -4961,8 +4968,8 @@ // check for `exports` after `define` in case a build optimizer adds an `exports` object else if (freeExports) { // in Node.js or RingoJS v0.8.0+ - if (typeof module == 'object' && module && module.exports == freeExports) { - (module.exports = lodash)._ = lodash; + if (freeModule) { + (freeModule.exports = lodash)._ = lodash; } // in Narwhal or RingoJS v0.7.0- else { diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 67a185a2ed..4062e9b7f6 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -4,37 +4,37 @@ * Build: `lodash modern -o ./dist/lodash.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ -;(function(n,t){function r(n){if(!n||typeof n!="object")return Q;var t=n.valueOf,r=typeof t=="function"&&(r=dt(t))&&dt(r);if(r)n=n==r||dt(n)==r&&!h(n);else{var e=Q;!n||typeof n!="object"||h(n)?n=e:(t=n.constructor,!j(t)||t instanceof t?(Wt(n,function(n,t){e=t}),n=e===Q||_t.call(n,e)):n=e)}return n}function e(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof e?(this.__wrapped__=n,void 0):new e(n)}function u(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||rt);if(u){var o={};for(r=t-1;++rt||typeof n=="undefined")return 1;if(nr?0:r);++er?St(0,u+r):r)||0,typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):z(n,t,r)):Qt(n,function(n){return++eu&&(u=f)}}else t=!t&&A(n)?o:a(t,r),Qt(n,function(n,r,o){r=t(n,r,o),r>e&&(e=r,u=n)});return u}function D(n,t,r,e){var u=3>arguments.length;if(t=a(t,e,4),Yt(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof u!="number")var i=Zt(n),u=i.length;return t=a(t,e,4),$(n,function(e,f,a){f=i?i[--u]:--u,r=o?(o=Q,n[f]):t(r,n[f],f,a)}),r}function I(n,t,r){var e;if(t=a(t,r),Yt(n)){r=-1;for(var u=n.length;++rr?St(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])z(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function U(n,t){return Pt||wt&&2/g,st=/($^)/,vt=/[&<>"']/g,gt=/['\n\r\t\u2028\u2029\\]/g,ht=Math.ceil,yt=Y.concat,mt=Math.floor,dt=ct.test(dt=Object.getPrototypeOf)&&dt,_t=Z.hasOwnProperty,bt=Y.push,jt=Z.toString,wt=ct.test(wt=v.bind)&&wt,xt=ct.test(xt=Array.isArray)&&xt,At=n.isFinite,Ot=n.isNaN,Et=ct.test(Et=Object.keys)&&Et,St=Math.max,kt=Math.min,Nt=Math.random,Rt="[object Arguments]",$t="[object Array]",Ft="[object Boolean]",qt="[object Date]",Dt="[object Number]",Tt="[object Object]",It="[object RegExp]",Bt="[object String]",Mt=!!n.attachEvent,zt=wt&&!/\n|true/.test(wt+Mt),Pt=wt&&!zt,Ct=Et&&(Mt||zt),Kt={"[object Function]":Q}; -Kt[Rt]=Kt[$t]=Kt[Ft]=Kt[qt]=Kt[Dt]=Kt[Tt]=Kt[It]=Kt[Bt]=J;var Ut={};Ut[$t]=Array,Ut[Ft]=Boolean,Ut[qt]=Date,Ut[Tt]=Object,Ut[Dt]=Number,Ut[It]=RegExp,Ut[Bt]=String;var Vt={"boolean":Q,"function":J,object:J,number:Q,string:Q,undefined:Q},Gt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};e.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:pt,variable:"",imports:{_:e}};var Ht={a:"q,w,h",l:"var a=arguments,b=0,c=typeof h=='number'?2:a.length;while(++b":">",'"':""","'":"'"},tr=_(nr),rr=c(Ht,{l:Ht.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=f(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[j]=d?d(u[j],n[j]):n[j]"}),er=c(Ht);j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==jt.call(n)});var ur=ct.test(n.e)&&U(setImmediate,n)||function(n){var r=v(arguments,1);return setTimeout(function(){n.apply(t,r) -},1)};e.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},e.assign=rr,e.at=function(n){for(var t=-1,r=yt.apply(Y,v(arguments,1)),e=r.length,u=Array(e);++tz(c,l)){f&&c.push(l);for(var s=r;--s;)if(!(e[s]||(e[s]=u(t[s],0,100)))(l))continue n;a.push(l)}}return a},e.invert=_,e.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return $(n,function(n){i[++e]=(u?t:n[t]).apply(n,r) -}),i},e.keys=Zt,e.map=F,e.max=q,e.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return _t.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},e.merge=O,e.min=function(n,t,r){var e=1/0,u=e;if(!t&&Yt(n)){r=-1;for(var i=n.length;++rz(o,r,1))&&(u[r]=n)}),u},e.once=function(n){var t,r;return function(){return t?r:(t=J,r=n.apply(this,arguments),n=L,r)}},e.pairs=function(n){for(var t=-1,r=Zt(n),e=r.length,u=Array(e);++tr?St(0,e+r):kt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},e.mixin=G,e.noConflict=function(){return n._=et,this -},e.random=function(n,t){return n==L&&t==L&&(t=1),n=+n||0,t==L&&(t=n,n=0),n+mt(Nt()*((+t||0)-n+1))},e.reduce=D,e.reduceRight=T,e.result=function(n,r){var e=n?n[r]:t;return j(e)?n[r]():e},e.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Zt(n).length},e.some=I,e.sortedIndex=C,e.template=function(n,r,u){var o=e.templateSettings;n||(n=""),u=er({},u,o);var i,f=er({},u.imports,o.imports),o=Zt(f),f=E(f),a=0,c=u.interpolate||st,p="__p+='";n.replace(RegExp((u.escape||st).source+"|"+c.source+"|"+(c===pt?lt:st).source+"|"+(u.evaluate||st).source+"|$","g"),function(t,r,e,u,o,f){return e||(e=u),p+=n.slice(a,f).replace(gt,l),r&&(p+="'+__e("+r+")+'"),o&&(i=J,p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),a=f+t.length,t -}),p+="';\n",c=u=u.variable,c||(u="obj",p="with("+u+"){"+p+"}"),p=(i?p.replace(ot,""):p).replace(it,"$1").replace(ft,"$1;"),p="function("+u+"){"+(c?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+p+"return __p}";try{var s=Function(o,"return "+p).apply(t,f)}catch(v){throw v.source=p,v}return r?s(r):(s.source=p,s)},e.unescape=function(n){return n==L?"":(n+"").replace(ut,g)},e.uniqueId=function(n){var t=++nt;return(n==L?"":n+"")+t -},e.all=k,e.any=I,e.detect=R,e.foldl=D,e.foldr=T,e.include=S,e.inject=D,Xt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(){var t=[this.__wrapped__];return bt.apply(t,arguments),n.apply(e,t)})}),e.first=B,e.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=L){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==L||r)return n[u-1];return v(n,St(0,u-e))}},e.take=B,e.head=B,Xt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(t,r){var u=n(this.__wrapped__,t,r); -return t==L||r&&typeof t!="function"?u:new e(u)})}),e.VERSION="1.0.0",e.prototype.toString=function(){return this.__wrapped__+""},e.prototype.value=H,e.prototype.valueOf=H,Qt(["join","pop","shift"],function(n){var t=Y[n];e.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),Qt(["push","reverse","sort","unshift"],function(n){var t=Y[n];e.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Qt(["concat","slice","splice"],function(n){var t=Y[n];e.prototype[n]=function(){return new e(t.apply(this.__wrapped__,arguments)) -}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=e,define(function(){return e})):W?typeof module=="object"&&module&&module.exports==W?(module.exports=e)._=e:W._=e:n._=e})(this); \ No newline at end of file +;(function(n,t){function r(n){if(!n||typeof n!="object")return W;var t=n.valueOf,r=typeof t=="function"&&(r=bt(t))&&bt(r);if(r)n=n==r||bt(n)==r&&!h(n);else{var e=W;!n||typeof n!="object"||h(n)?n=e:(t=n.constructor,!j(t)||t instanceof t?(Yt(n,function(n,t){e=t}),n=e===W||jt.call(n,e)):n=e)}return n}function e(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof e?(this.__wrapped__=n,void 0):new e(n)}function u(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||ut);if(u){var o={};for(r=t-1;++rt||typeof n=="undefined")return 1;if(nr?0:r);++er?Nt(0,u+r):r)||0,typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):z(n,t,r)):Xt(n,function(n){return++eu&&(u=f)}}else t=!t&&A(n)?o:a(t,r),Xt(n,function(n,r,o){r=t(n,r,o),r>e&&(e=r,u=n)});return u}function D(n,t,r,e){var u=3>arguments.length;if(t=a(t,e,4),nr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof u!="number")var i=tr(n),u=i.length;return t=a(t,e,4),$(n,function(e,f,a){f=i?i[--u]:--u,r=o?(o=W,n[f]):t(r,n[f],f,a)}),r}function T(n,t,r){var e;if(t=a(t,r),nr(n)){r=-1;for(var u=n.length;++rr?Nt(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])z(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function U(n,t){return Kt||At&&2/g,gt=/($^)/,ht=/[&<>"']/g,yt=/['\n\r\t\u2028\u2029\\]/g,mt=Math.ceil,dt=nt.concat,_t=Math.floor,bt=pt.test(bt=Object.getPrototypeOf)&&bt,jt=tt.hasOwnProperty,wt=nt.push,xt=tt.toString,At=pt.test(At=v.bind)&&At,Ot=pt.test(Ot=Array.isArray)&&Ot,Et=n.isFinite,St=n.isNaN,kt=pt.test(kt=Object.keys)&&kt,Nt=Math.max,Rt=Math.min,$t=Math.random,Ft="[object Arguments]",qt="[object Array]",Dt="[object Boolean]",It="[object Date]",Tt="[object Number]",Bt="[object Object]",Mt="[object RegExp]",zt="[object String]",Pt=!!n.attachEvent,Ct=At&&!/\n|true/.test(At+Pt),Kt=At&&!Ct,Ut=kt&&(Pt||Ct),Vt={"[object Function]":W}; +Vt[Ft]=Vt[qt]=Vt[Dt]=Vt[It]=Vt[Tt]=Vt[Bt]=Vt[Mt]=Vt[zt]=L;var Gt={};Gt[qt]=Array,Gt[Dt]=Boolean,Gt[It]=Date,Gt[Bt]=Object,Gt[Tt]=Number,Gt[Mt]=RegExp,Gt[zt]=String;var Ht={"boolean":W,"function":L,object:L,number:W,string:W,undefined:W},Jt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};e.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:vt,variable:"",imports:{_:e}};var Lt={a:"q,w,h",l:"var a=arguments,b=0,c=typeof h=='number'?2:a.length;while(++b":">",'"':""","'":"'"},er=_(rr),ur=c(Lt,{l:Lt.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=f(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[j]=d?d(u[j],n[j]):n[j]"}),or=c(Lt);j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==xt.call(n)}),Ct&&Y&&typeof setImmediate=="function"&&(V=U(setImmediate,n)),e.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 +}},e.assign=ur,e.at=function(n){for(var t=-1,r=dt.apply(nt,v(arguments,1)),e=r.length,u=Array(e);++tz(c,l)){f&&c.push(l);for(var s=r;--s;)if(!(e[s]||(e[s]=u(t[s],0,100)))(l))continue n;a.push(l)}}return a},e.invert=_,e.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return $(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},e.keys=tr,e.map=F,e.max=q,e.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+""; +return jt.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},e.merge=O,e.min=function(n,t,r){var e=1/0,u=e;if(!t&&nr(n)){r=-1;for(var i=n.length;++rz(o,r,1))&&(u[r]=n) +}),u},e.once=function(n){var t,r;return function(){return t?r:(t=L,r=n.apply(this,arguments),n=Q,r)}},e.pairs=function(n){for(var t=-1,r=tr(n),e=r.length,u=Array(e);++tr?Nt(0,e+r):Rt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},e.mixin=H,e.noConflict=function(){return n._=ot,this},e.random=function(n,t){return n==Q&&t==Q&&(t=1),n=+n||0,t==Q&&(t=n,n=0),n+_t($t()*((+t||0)-n+1)) +},e.reduce=D,e.reduceRight=I,e.result=function(n,r){var e=n?n[r]:t;return j(e)?n[r]():e},e.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:tr(n).length},e.some=T,e.sortedIndex=C,e.template=function(n,r,u){var o=e.templateSettings;n||(n=""),u=or({},u,o);var i,f=or({},u.imports,o.imports),o=tr(f),f=E(f),a=0,c=u.interpolate||gt,p="__p+='";n.replace(RegExp((u.escape||gt).source+"|"+c.source+"|"+(c===vt?st:gt).source+"|"+(u.evaluate||gt).source+"|$","g"),function(t,r,e,u,o,f){return e||(e=u),p+=n.slice(a,f).replace(yt,l),r&&(p+="'+__e("+r+")+'"),o&&(i=L,p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),a=f+t.length,t +}),p+="';\n",c=u=u.variable,c||(u="obj",p="with("+u+"){"+p+"}"),p=(i?p.replace(ft,""):p).replace(at,"$1").replace(ct,"$1;"),p="function("+u+"){"+(c?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+p+"return __p}";try{var s=Function(o,"return "+p).apply(t,f)}catch(v){throw v.source=p,v}return r?s(r):(s.source=p,s)},e.unescape=function(n){return n==Q?"":(n+"").replace(it,g)},e.uniqueId=function(n){var t=++rt;return(n==Q?"":n+"")+t +},e.all=k,e.any=T,e.detect=R,e.foldl=D,e.foldr=I,e.include=S,e.inject=D,Zt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(){var t=[this.__wrapped__];return wt.apply(t,arguments),n.apply(e,t)})}),e.first=B,e.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=Q){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==Q||r)return n[u-1];return v(n,Nt(0,u-e))}},e.take=B,e.head=B,Zt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(t,r){var u=n(this.__wrapped__,t,r); +return t==Q||r&&typeof t!="function"?u:new e(u)})}),e.VERSION="1.0.0",e.prototype.toString=function(){return this.__wrapped__+""},e.prototype.value=J,e.prototype.valueOf=J,Xt(["join","pop","shift"],function(n){var t=nt[n];e.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),Xt(["push","reverse","sort","unshift"],function(n){var t=nt[n];e.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Xt(["concat","slice","splice"],function(n){var t=nt[n];e.prototype[n]=function(){return new e(t.apply(this.__wrapped__,arguments)) +}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=e,define(function(){return e})):X?Y?(Y.exports=e)._=e:X._=e:n._=e})(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index 8f526f028d..484317168e 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -12,6 +12,9 @@ /** Detect free variable `exports` */ var freeExports = typeof exports == 'object' && exports; + /** Detect free variable `module` */ + var freeModule = typeof module == 'object' && module && module.exports == freeExports && module; + /** Detect free variable `global` and use it as `window` */ var freeGlobal = typeof global == 'object' && global; if (freeGlobal.global === freeGlobal) { @@ -3463,10 +3466,14 @@ * _.defer(function() { alert('deferred'); }); * // returns from the function before `alert` is called */ - var defer = reNative.test(window.setImmediate) && bind(setImmediate, window) || function(func) { + function defer(func) { var args = slice(arguments, 1); return setTimeout(function() { func.apply(undefined, args); }, 1); - }; + } + // use Node's `setImmediate`, if available + if (isV8 && freeModule && typeof setImmediate == 'function') { + defer = bind(setImmediate, window); + } /** * Creates a function that memoizes the result of `func`. If `resolver` is @@ -4285,8 +4292,8 @@ if (freeExports) { // in Node.js or RingoJS v0.8.0+ - if (typeof module == 'object' && module && module.exports == freeExports) { - (module.exports = lodash)._ = lodash; + if (freeModule) { + (freeModule.exports = lodash)._ = lodash; } // in Narwhal or RingoJS v0.7.0- else { diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index 7a92f955dc..03f4c7b1b4 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -4,31 +4,31 @@ * Build: `lodash underscore -o ./dist/lodash.underscore.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ -;(function(n,t){function r(n,t){var r;if(n&&Rt[typeof n])for(r in t||(t=W),n)if(t(n[r],r,n)===nt)break}function e(n,t,r){if(n){t=t&&typeof r=="undefined"?t:a(t,r);var e=n.length;if(r=-1,typeof e=="number")for(;++rt||typeof n=="undefined")return 1;if(nr?0:r);++eo&&(o=f)}}else t=a(t,r),e(n,function(n,r,e){r=t(n,r,e),r>u&&(u=r,o=n)});return o}function q(n,t,r,u){var o=3>arguments.length;if(t=a(t,u,4),qt(n)){var i=-1,f=n.length;for(o&&(r=n[++i]);++iarguments.length;if(typeof u!="number")var i=It(n),u=i.length;return t=a(t,e,4),F(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=K,n[a]):t(r,n[a],a,f)}),r}function B(n,t,r){var u; -if(t=a(t,r),qt(n)){r=-1;for(var o=n.length;++rr?mt(0,u+r):r||0)-1;else if(r)return e=P(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])z(f,c))&&(r&&f.push(c),i.push(e))}return i}function V(n,t){return Nt||st&&2"']/g,ot=/['\n\r\t\u2028\u2029\\]/g,it=Math.ceil,at=X.concat,ft=Math.floor,ct=Y.hasOwnProperty,lt=X.push,pt=Y.toString,st=Q.test(st=p.bind)&&st,vt=Q.test(vt=Array.isArray)&&vt,ht=n.isFinite,gt=n.isNaN,yt=Q.test(yt=Object.keys)&&yt,mt=Math.max,_t=Math.min,dt=Math.random,bt="[object Arguments]",jt="[object Array]",wt="[object Boolean]",At="[object Date]",xt="[object Number]",Et="[object Object]",Ot="[object RegExp]",St="[object String]",Y=!!n.attachEvent,Y=st&&!/\n|true/.test(st+Y),Nt=st&&!Y,kt=(kt={0:1,length:1},X.splice.call(kt,0,1),kt[0]),Ft=arguments.constructor==Object,Rt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Tt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; -u.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},v(arguments)||(v=function(n){return n?ct.call(n,"callee"):K});var qt=vt||function(n){return Ft&&n instanceof Array||pt.call(n)==jt},It=yt?function(n){return w(n)?yt(n):[]}:h,Bt={"&":"&","<":"<",">":">",'"':""","'":"'"},Dt=_(Bt);j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==pt.call(n)});var Mt=R,vt=Q.test(n.d)&&V(setImmediate,n)||function(n){var r=p(arguments,1); -return setTimeout(function(){n.apply(t,r)},1)};u.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},u.bind=V,u.bindAll=function(n){for(var t=at.apply(X,arguments),r=1z(e,o,r)&&u.push(o)}return u},u.filter=N,u.flatten=$,u.forEach=F,u.functions=m,u.groupBy=function(n,t,r){var e={};return t=a(t,r),F(n,function(n,r,u){r=t(n,r,u)+"",(ct.call(e,r)?e[r]:e[r]=[]).push(n)}),e},u.initial=function(n,t,r){if(!n)return[];var e=0,u=n.length;if(typeof t!="number"&&t!=J){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else e=t==J||r?1:t||e;return p(n,0,_t(mt(0,u-e),u))},u.intersection=function(n){var t=arguments,r=t.length,e=-1,u=n?n.length:0,o=[];n:for(;++ez(o,i)){for(var a=r;--a;)if(0>z(t[a],i))continue n; -o.push(i)}}return o},u.invert=_,u.invoke=function(n,t){var r=p(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return F(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},u.keys=It,u.map=R,u.max=T,u.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return ct.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},u.min=function(n,t,r){var u=1/0,o=u;if(!t&&qt(n)){r=-1;for(var i=n.length;++rz(t,r,1)&&(e[r]=n)}),e},u.once=function(n){var t,r;return function(){return t?r:(t=H,r=n.apply(this,arguments),n=J,r)}},u.pairs=function(n){for(var t=-1,r=It(n),e=r.length,u=Array(e);++tz(arguments,u,1)&&e.push(u)}return e},u.wrap=function(n,t){return function(){var r=[n];return lt.apply(r,arguments),t.apply(this,r)}},u.zip=function(n){for(var t=-1,r=n?T(Mt(arguments,"length")):0,e=Array(r);++tr?mt(0,e+r):_t(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},u.mixin=G,u.noConflict=function(){return n._=tt,this},u.random=function(n,t){return n==J&&t==J&&(t=1),n=+n||0,t==J&&(t=n,n=0),n+ft(dt()*((+t||0)-n+1))},u.reduce=q,u.reduceRight=I,u.result=function(n,t){var r=n?n[t]:J; -return j(r)?n[t]():r},u.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:It(n).length},u.some=B,u.sortedIndex=P,u.template=function(n,t,r){n||(n=""),r=y({},r,u.templateSettings);var e=0,o="__p+='",i=r.variable;n.replace(RegExp((r.escape||et).source+"|"+(r.interpolate||et).source+"|"+(r.evaluate||et).source+"|$","g"),function(t,r,u,i,a){return o+=n.slice(e,a).replace(ot,f),r&&(o+="'+_['escape']("+r+")+'"),i&&(o+="';"+i+";__p+='"),u&&(o+="'+((__t=("+u+"))==null?'':__t)+'"),e=a+t.length,t -}),o+="';\n",i||(i="obj",o="with("+i+"||{}){"+o+"}"),o="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+o+"return __p}";try{var a=Function("_","return "+o)(u)}catch(c){throw c.source=o,c}return t?a(t):(a.source=o,a)},u.unescape=function(n){return n==J?"":(n+"").replace(rt,s)},u.uniqueId=function(n){var t=++Z+"";return n?n+t:t},u.all=S,u.any=B,u.detect=k,u.foldl=q,u.foldr=I,u.include=O,u.inject=q,u.first=M,u.last=function(n,t,r){if(n){var e=0,u=n.length; -if(typeof t!="number"&&t!=J){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==J||r)return n[u-1];return p(n,mt(0,u-e))}},u.take=M,u.head=M,u.chain=function(n){return n=new u(n),n.__chain__=H,n},u.VERSION="1.0.0",G(u),u.prototype.chain=function(){return this.__chain__=H,this},u.prototype.value=function(){return this.__wrapped__},e("pop push reverse shift sort splice unshift".split(" "),function(n){var t=X[n];u.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),kt&&0===n.length&&delete n[0],this -}}),e(["concat","join","slice"],function(n){var t=X[n];u.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new u(n),n.__chain__=H),n}}),L?typeof module=="object"&&module&&module.exports==L?(module.exports=u)._=u:L._=u:n._=u})(this); \ No newline at end of file +;(function(n,t){function r(n,t){var r;if(n&&qt[typeof n])for(r in t||(t=G),n)if(t(n[r],r,n)===tt)break}function e(n,t,r){if(n){t=t&&typeof r=="undefined"?t:a(t,r);var e=n.length;if(r=-1,typeof e=="number")for(;++rt||typeof n=="undefined")return 1;if(nr?0:r);++eo&&(o=f)}}else t=a(t,r),e(n,function(n,r,e){r=t(n,r,e),r>u&&(u=r,o=n)});return o}function q(n,t,r,u){var o=3>arguments.length;if(t=a(t,u,4),Bt(n)){var i=-1,f=n.length;for(o&&(r=n[++i]);++iarguments.length;if(typeof u!="number")var i=Dt(n),u=i.length;return t=a(t,e,4),F(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=L,n[a]):t(r,n[a],a,f)}),r}function B(n,t,r){var u; +if(t=a(t,r),Bt(n)){r=-1;for(var o=n.length;++rr?dt(0,u+r):r||0)-1;else if(r)return e=P(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])z(f,c))&&(r&&f.push(c),i.push(e))}return i}function V(n,t){return Ft||ht&&2"']/g,at=/['\n\r\t\u2028\u2029\\]/g,ft=Math.ceil,ct=Z.concat,lt=Math.floor,pt=Y.hasOwnProperty,st=Z.push,vt=Y.toString,ht=ut.test(ht=p.bind)&&ht,gt=ut.test(gt=Array.isArray)&>,yt=n.isFinite,mt=n.isNaN,_t=ut.test(_t=Object.keys)&&_t,dt=Math.max,bt=Math.min,jt=Math.random,wt="[object Arguments]",At="[object Array]",xt="[object Boolean]",Et="[object Date]",Ot="[object Number]",St="[object Object]",Nt="[object RegExp]",kt="[object String]",Y=!!n.attachEvent,Y=ht&&!/\n|true/.test(ht+Y),Ft=ht&&!Y,Rt=(Rt={0:1,length:1},Z.splice.call(Rt,0,1),Rt[0]),Tt=arguments.constructor==Object,qt={"boolean":L,"function":J,object:J,number:L,string:L,undefined:L},It={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +u.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},v(arguments)||(v=function(n){return n?pt.call(n,"callee"):L});var Bt=gt||function(n){return Tt&&n instanceof Array||vt.call(n)==At},Dt=_t?function(n){return w(n)?_t(n):[]}:h,Mt={"&":"&","<":"<",">":">",'"':""","'":"'"},$t=_(Mt);j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==vt.call(n)});var zt=R;Y&&X&&typeof setImmediate=="function"&&(W=V(setImmediate,n)),u.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 +}},u.bind=V,u.bindAll=function(n){for(var t=ct.apply(Z,arguments),r=1z(e,o,r)&&u.push(o)}return u},u.filter=N,u.flatten=$,u.forEach=F,u.functions=m,u.groupBy=function(n,t,r){var e={};return t=a(t,r),F(n,function(n,r,u){r=t(n,r,u)+"",(pt.call(e,r)?e[r]:e[r]=[]).push(n) +}),e},u.initial=function(n,t,r){if(!n)return[];var e=0,u=n.length;if(typeof t!="number"&&t!=K){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else e=t==K||r?1:t||e;return p(n,0,bt(dt(0,u-e),u))},u.intersection=function(n){var t=arguments,r=t.length,e=-1,u=n?n.length:0,o=[];n:for(;++ez(o,i)){for(var a=r;--a;)if(0>z(t[a],i))continue n;o.push(i)}}return o},u.invert=_,u.invoke=function(n,t){var r=p(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0); +return F(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},u.keys=Dt,u.map=R,u.max=T,u.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";return pt.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},u.min=function(n,t,r){var u=1/0,o=u;if(!t&&Bt(n)){r=-1;for(var i=n.length;++rz(t,r,1)&&(e[r]=n)}),e},u.once=function(n){var t,r;return function(){return t?r:(t=J,r=n.apply(this,arguments),n=K,r)}},u.pairs=function(n){for(var t=-1,r=Dt(n),e=r.length,u=Array(e);++tz(arguments,u,1)&&e.push(u)}return e},u.wrap=function(n,t){return function(){var r=[n];return st.apply(r,arguments),t.apply(this,r)}},u.zip=function(n){for(var t=-1,r=n?T(zt(arguments,"length")):0,e=Array(r);++tr?dt(0,e+r):bt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},u.mixin=H,u.noConflict=function(){return n._=rt,this},u.random=function(n,t){return n==K&&t==K&&(t=1),n=+n||0,t==K&&(t=n,n=0),n+lt(jt()*((+t||0)-n+1))},u.reduce=q,u.reduceRight=I,u.result=function(n,t){var r=n?n[t]:K;return j(r)?n[t]():r},u.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Dt(n).length +},u.some=B,u.sortedIndex=P,u.template=function(n,t,r){n||(n=""),r=y({},r,u.templateSettings);var e=0,o="__p+='",i=r.variable;n.replace(RegExp((r.escape||ot).source+"|"+(r.interpolate||ot).source+"|"+(r.evaluate||ot).source+"|$","g"),function(t,r,u,i,a){return o+=n.slice(e,a).replace(at,f),r&&(o+="'+_['escape']("+r+")+'"),i&&(o+="';"+i+";__p+='"),u&&(o+="'+((__t=("+u+"))==null?'':__t)+'"),e=a+t.length,t}),o+="';\n",i||(i="obj",o="with("+i+"||{}){"+o+"}"),o="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+o+"return __p}"; +try{var a=Function("_","return "+o)(u)}catch(c){throw c.source=o,c}return t?a(t):(a.source=o,a)},u.unescape=function(n){return n==K?"":(n+"").replace(et,s)},u.uniqueId=function(n){var t=++nt+"";return n?n+t:t},u.all=S,u.any=B,u.detect=k,u.foldl=q,u.foldr=I,u.include=O,u.inject=q,u.first=M,u.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=K){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==K||r)return n[u-1];return p(n,dt(0,u-e))}},u.take=M,u.head=M,u.chain=function(n){return n=new u(n),n.__chain__=J,n +},u.VERSION="1.0.0",H(u),u.prototype.chain=function(){return this.__chain__=J,this},u.prototype.value=function(){return this.__wrapped__},e("pop push reverse shift sort splice unshift".split(" "),function(n){var t=Z[n];u.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),Rt&&0===n.length&&delete n[0],this}}),e(["concat","join","slice"],function(n){var t=Z[n];u.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new u(n),n.__chain__=J),n +}}),Q?X?(X.exports=u)._=u:Q._=u:n._=u})(this); \ No newline at end of file diff --git a/doc/README.md b/doc/README.md index 5176250d2f..ec6bfe3006 100644 --- a/doc/README.md +++ b/doc/README.md @@ -197,7 +197,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3163 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3166 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -221,7 +221,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3193 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3196 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -246,7 +246,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.first(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3265 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3268 "View in source") [Ⓣ][1] Gets the first element of the `array`. If a number `n` is passed, the first `n` elements of the `array` are returned. If a `callback` function is passed, the first elements the `callback` returns truthy for are returned. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -306,7 +306,7 @@ _.first(food, { 'type': 'fruit' }); ### `_.flatten(array, shallow)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3304 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3307 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `shallow` is truthy, `array` will only be flattened a single level. @@ -334,7 +334,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3346 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3349 "View in source") [Ⓣ][1] Gets the index at which the first occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `fromIndex` will run a faster binary search. @@ -366,7 +366,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3420 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3423 "View in source") [Ⓣ][1] Gets all but the last element of `array`. If a number `n` is passed, the last `n` elements are excluded from the result. If a `callback` function is passed, the last elements the `callback` returns truthy for are excluded from the result. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -423,7 +423,7 @@ _.initial(food, { 'type': 'vegetable' }); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3454 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3457 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -447,7 +447,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3545 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3548 "View in source") [Ⓣ][1] Gets the last element of the `array`. If a number `n` is passed, the last `n` elements of the `array` are returned. If a `callback` function is passed, the last elements the `callback` returns truthy for are returned. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -504,7 +504,7 @@ _.last(food, { 'type': 'vegetable' }); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3586 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3589 "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. @@ -533,7 +533,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.object(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3616 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3619 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -558,7 +558,7 @@ _.object(['moe', 'larry'], [30, 40]); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3660 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3663 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. @@ -596,7 +596,7 @@ _.range(0); ### `_.rest(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3738 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3741 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. If a number `n` is passed, the first `n` values are excluded from the result. If a `callback` function is passed, the first elements the `callback` returns truthy for are excluded from the result. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -656,7 +656,7 @@ _.rest(food, { 'type': 'fruit' }); ### `_.sortedIndex(array, value [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3802 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3805 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. @@ -705,7 +705,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3834 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3837 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -729,7 +729,7 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3881 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3884 "View in source") [Ⓣ][1] Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -776,7 +776,7 @@ _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3940 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3943 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -801,7 +801,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3971 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3974 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -832,7 +832,7 @@ _.zip(['moe', 'larry'], [30, 40], [true, false]); ### `_(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L269 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L272 "View in source") [Ⓣ][1] Creates a `lodash` object, that wraps the given `value`, to enable method chaining. @@ -861,7 +861,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4867 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4874 "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. @@ -891,7 +891,7 @@ _([1, 2, 3, 4]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4884 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4891 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -912,7 +912,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4901 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4908 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -943,7 +943,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2164 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2167 "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. @@ -971,7 +971,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2206 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2209 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -1009,7 +1009,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2260 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2263 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of the `collection` through the given `callback`. The corresponding value of each key is the number of times the key was returned by the `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1045,7 +1045,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2312 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2315 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1091,7 +1091,7 @@ _.every(stooges, { 'age': 50 }); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2373 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2376 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1137,7 +1137,7 @@ _.filter(food, { 'type': 'fruit' }); ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2440 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2443 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first that the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1185,7 +1185,7 @@ var healthy = _.find(food, 'organic'); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2475 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2478 "View in source") [Ⓣ][1] Iterates over a `collection`, executing the `callback` for each element in the `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1217,7 +1217,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2525 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2528 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of the `collection` through the `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1254,7 +1254,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2558 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2561 "View in source") [Ⓣ][1] Invokes the method named by `methodName` on each element in the `collection`, returning an array of the results of each invoked method. Additional arguments will be passed to each invoked method. If `methodName` is a function, it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1283,7 +1283,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2610 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2613 "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)*. @@ -1328,7 +1328,7 @@ _.map(stooges, 'name'); ### `_.max(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2667 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2670 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1370,7 +1370,7 @@ _.max(stooges, 'age'); ### `_.min(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2736 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2739 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1412,7 +1412,7 @@ _.min(stooges, 'age'); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2786 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2789 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1442,7 +1442,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2818 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2821 "View in source") [Ⓣ][1] Reduces a `collection` to a value that is the accumulated result of running each element in the `collection` through the `callback`, where each successive `callback` execution consumes the return value of the previous execution. If `accumulator` is not passed, the first element of the `collection` will be used as the initial `accumulator` value. The `callback` is bound to `thisArg` and invoked with four arguments; *(accumulator, value, index|key, collection)*. @@ -1480,7 +1480,7 @@ var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2861 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2864 "View in source") [Ⓣ][1] This method is similar to `_.reduce`, except that it iterates over a `collection` from right to left. @@ -1511,7 +1511,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2921 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2924 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1554,7 +1554,7 @@ _.reject(food, { 'type': 'fruit' }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2942 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2945 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1578,7 +1578,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2975 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2978 "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. @@ -1608,7 +1608,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3022 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3025 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1654,7 +1654,7 @@ _.some(food, { 'type': 'meat' }); ### `_.sortBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3078 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3081 "View in source") [Ⓣ][1] Creates an array of elements, sorted in ascending order by the results of running each element in the `collection` through the `callback`. This method performs a stable sort, that is, it will preserve the original sort order of equal elements. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1691,7 +1691,7 @@ _.sortBy(['banana', 'strawberry', 'apple'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3113 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3116 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1715,7 +1715,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3145 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3148 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that have the given `properties`. When checking `properties`, this method performs a deep comparison between values to determine if they are equivalent to each other. @@ -1752,7 +1752,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4004 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4007 "View in source") [Ⓣ][1] Creates a function that is restricted to executing `func` only after it is called `n` times. The `func` is executed with the `this` binding of the created function. @@ -1780,7 +1780,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4037 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4040 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1811,7 +1811,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4068 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4071 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. Method names may be specified as individual arguments or as arrays of method names. If no method names are provided, all the function properties of `object` will be bound. @@ -1842,7 +1842,7 @@ jQuery('#docs').on('click', view.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4114 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4117 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed to the bound function. This method differs from `_.bind` by allowing bound functions to reference methods that will be redefined or don't yet exist. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -1883,7 +1883,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4137 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4140 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -1910,7 +1910,7 @@ welcome('moe'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4170 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4173 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -1936,7 +1936,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4234 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4237 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -1961,7 +1961,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4214 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4217 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -1988,7 +1988,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4258 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4265 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -2014,7 +2014,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4285 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4292 "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. @@ -2040,7 +2040,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4320 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4327 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `_.bind`, except it does **not** alter the `this` binding. @@ -2067,7 +2067,7 @@ hi('moe'); ### `_.partialRight(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4351 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4358 "View in source") [Ⓣ][1] This method is similar to `_.partial`, except that `partial` arguments are appended to those passed to the new function. @@ -2104,7 +2104,7 @@ options.imports ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4373 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4380 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -2129,7 +2129,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4426 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4433 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -2165,7 +2165,7 @@ hello(); ### `_.assign(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1059 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1062 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the destination object. Subsequent sources will overwrite propery assignments of previous sources. If a `callback` function is passed, it will be executed to produce the assigned values. The `callback` is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. @@ -2203,7 +2203,7 @@ defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.clone(value [, deep=false, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1114 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1117 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. If a `callback` function is passed, it will be executed to produce the cloned values. If `callback` returns `undefined`, cloning will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. @@ -2250,7 +2250,7 @@ clone.childNodes.length; ### `_.cloneDeep(value [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1239 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1242 "View in source") [Ⓣ][1] Creates a deep clone of `value`. If a `callback` function is passed, it will be executed to produce the cloned values. If `callback` returns the value it was passed, cloning will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. @@ -2296,7 +2296,7 @@ clone.node == view.node; ### `_.defaults(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1263 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1266 "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. @@ -2322,7 +2322,7 @@ _.defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L879 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L882 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2358,7 +2358,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L904 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L907 "View in source") [Ⓣ][1] Iterates over an object's own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2386,7 +2386,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1280 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1283 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2413,7 +2413,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1305 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1308 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2438,7 +2438,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1322 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1325 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2462,7 +2462,7 @@ _.invert({ 'first': 'moe', 'second': 'larry' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L840 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L843 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -2489,7 +2489,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L922 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L925 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2516,7 +2516,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1348 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1351 "View in source") [Ⓣ][1] Checks if `value` is a boolean value. @@ -2540,7 +2540,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1365 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1368 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2564,7 +2564,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1382 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1385 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2588,7 +2588,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1407 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1410 "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". @@ -2618,7 +2618,7 @@ _.isEmpty(''); ### `_.isEqual(a, b [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1466 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1469 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. If `callback` is passed, it will be executed to compare values. If `callback` returns `undefined`, comparisons will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with two arguments; *(a, b)*. @@ -2663,7 +2663,7 @@ _.isEqual(words, otherWords, function(a, b) { ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1647 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1650 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2701,7 +2701,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1664 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1667 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2725,7 +2725,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1727 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1730 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -2760,7 +2760,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1749 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1752 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2787,7 +2787,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1766 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1769 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2811,7 +2811,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1694 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1697 "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('')`)* @@ -2841,7 +2841,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1794 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1797 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2876,7 +2876,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1819 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1822 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2900,7 +2900,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1836 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1839 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -2924,7 +2924,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1853 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1856 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -2948,7 +2948,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L941 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L944 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -2972,7 +2972,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1913 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1916 "View in source") [Ⓣ][1] Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the destination object. Subsequent sources will overwrite propery assignments of previous sources. If a `callback` function is passed, it will be executed to produce the merged values of the destination and source properties. If `callback` returns `undefined`, merging will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. @@ -3028,7 +3028,7 @@ _.merge(food, otherFood, function(a, b) { ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2020 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2023 "View in source") [Ⓣ][1] Creates a shallow clone of `object` excluding the specified properties. Property names may be specified as individual arguments or as arrays of property names. If a `callback` function is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -3059,7 +3059,7 @@ _.omit({ 'name': 'moe', 'age': 40 }, function(value) { ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2054 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2057 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -3083,7 +3083,7 @@ _.pairs({ 'moe': 30, 'larry': 40 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2092 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2095 "View in source") [Ⓣ][1] Creates a shallow clone of `object` composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. If `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -3114,7 +3114,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2129 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2132 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -3145,7 +3145,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4450 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4457 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -3169,7 +3169,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4468 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4475 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -3194,7 +3194,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4494 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4501 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -3224,7 +3224,7 @@ _('moe').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4518 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4525 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -3244,7 +3244,7 @@ var lodash = _.noConflict(); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4541 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4548 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -3272,7 +3272,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4579 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4586 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function, it will be invoked and its result returned, else the property value is returned. If `object` is falsey, then `null` is returned. @@ -3307,7 +3307,7 @@ _.result(object, 'stuff'); ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4667 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4674 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -3391,7 +3391,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4793 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4800 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3423,7 +3423,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4819 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4826 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3447,7 +3447,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4839 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4846 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3481,7 +3481,7 @@ _.uniqueId(); ### `_.templateSettings.imports._` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L338 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L341 "View in source") [Ⓣ][1] A reference to the `lodash` function. @@ -3500,7 +3500,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5069 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5076 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -3512,7 +3512,7 @@ A reference to the `lodash` function. ### `_.templateSettings` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L290 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L293 "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. @@ -3524,7 +3524,7 @@ A reference to the `lodash` function. ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L298 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L301 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to be HTML-escaped. @@ -3536,7 +3536,7 @@ A reference to the `lodash` function. ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L306 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L309 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect code to be evaluated. @@ -3548,7 +3548,7 @@ A reference to the `lodash` function. ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L314 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L317 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to inject. @@ -3560,7 +3560,7 @@ A reference to the `lodash` function. ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L322 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L325 "View in source") [Ⓣ][1] *(String)*: Used to reference the data object in the template text. @@ -3572,7 +3572,7 @@ A reference to the `lodash` function. ### `_.templateSettings.imports` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L330 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L333 "View in source") [Ⓣ][1] *(Object)*: Used to import variables into the compiled template. diff --git a/lodash.js b/lodash.js index fe0ac0cce9..1362e12486 100644 --- a/lodash.js +++ b/lodash.js @@ -11,6 +11,9 @@ /** Detect free variable `exports` */ var freeExports = typeof exports == 'object' && exports; + /** Detect free variable `module` */ + var freeModule = typeof module == 'object' && module && module.exports == freeExports && module; + /** Detect free variable `global` and use it as `window` */ var freeGlobal = typeof global == 'object' && global; if (freeGlobal.global === freeGlobal) { @@ -4231,10 +4234,14 @@ * _.defer(function() { alert('deferred'); }); * // returns from the function before `alert` is called */ - var defer = reNative.test(window.setImmediate) && bind(setImmediate, window) || function(func) { + function defer(func) { var args = slice(arguments, 1); return setTimeout(function() { func.apply(undefined, args); }, 1); - }; + } + // use Node's `setImmediate`, if available + if (isV8 && freeModule && typeof setImmediate == 'function') { + defer = bind(setImmediate, window); + } /** * Creates a function that memoizes the result of `func`. If `resolver` is @@ -5141,8 +5148,8 @@ // check for `exports` after `define` in case a build optimizer adds an `exports` object else if (freeExports) { // in Node.js or RingoJS v0.8.0+ - if (typeof module == 'object' && module && module.exports == freeExports) { - (module.exports = lodash)._ = lodash; + if (freeModule) { + (freeModule.exports = lodash)._ = lodash; } // in Narwhal or RingoJS v0.7.0- else { From 7093e9c0d427eb283b90a026902b3354a751816c Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 17 Feb 2013 23:54:19 -0800 Subject: [PATCH 21/22] Add PhantomJS not to CONTRIBUTING.md. Former-commit-id: e7c81af0fb6e1ede8f89d50ffdc5ec671e124252 --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f2eb92f587..7ebb5bc1b3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,7 +7,7 @@ Please make sure to [search the issue tracker](https://github.com/bestiejs/lodas Include updated unit tests in the `test` directory as part of your pull request. You can run the tests from the command line via `npm test`, or open `test/index.html` in a web browser. -The `test/run-test.sh` script attempts to run the tests in [Rhino](https://developer.mozilla.org/en-US/docs/Rhino), [RingoJS](http://ringojs.org/), [Narwhal](https://github.com/280north/narwhal), and [Node](http://nodejs.org/), before running them in your default browser. +The `test/run-test.sh` script attempts to run the tests in [Rhino](https://developer.mozilla.org/en-US/docs/Rhino), [Narwhal](https://github.com/280north/narwhal), [RingoJS](http://ringojs.org/), [PhantomJS](http://phantomjs.org/), and [Node](http://nodejs.org/), before running them in your default browser. The [Backbone](http://backbonejs.org/) and [Underscore](http://http://underscorejs.org/) test suites are included as well. ## Contributor License Agreement From 2459a53350d3929600e0027542a7f5b61e180629 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 18 Feb 2013 00:07:13 -0800 Subject: [PATCH 22/22] Bump to v1.0.1. Former-commit-id: b2536f9a226c7418ad3aaa7b5fb88282b77d20e5 --- README.md | 83 +++++++++++++++-------------------- build.js | 9 ++-- dist/lodash.compat.js | 8 ++-- dist/lodash.compat.min.js | 4 +- dist/lodash.js | 6 +-- dist/lodash.min.js | 4 +- dist/lodash.underscore.js | 6 +-- dist/lodash.underscore.min.js | 4 +- doc/README.md | 2 +- doc/parse.php | 2 +- lodash.js | 8 ++-- package.json | 2 +- 12 files changed, 65 insertions(+), 73 deletions(-) diff --git a/README.md b/README.md index 494ab29032..6181c7790f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Lo-Dash v1.0.0 +# Lo-Dash v1.0.1 [![build status](https://secure.travis-ci.org/bestiejs/lodash.png)](http://travis-ci.org/bestiejs/lodash) An alternative to Underscore.js, delivering consistency, [customization](https://github.com/bestiejs/lodash#custom-builds), [performance](http://lodash.com/benchmarks), and [extra features](https://github.com/bestiejs/lodash#features). @@ -6,24 +6,24 @@ An alternative to Underscore.js, delivering consistency, [customization](https:/ ## Download * Lo-Dash builds (for modern environments):
-[Development](https://raw.github.com/bestiejs/lodash/v1.0.0/dist/lodash.js) and -[Production](https://raw.github.com/bestiejs/lodash/v1.0.0/dist/lodash.min.js) +[Development](https://raw.github.com/bestiejs/lodash/v1.0.1/dist/lodash.js) and +[Production](https://raw.github.com/bestiejs/lodash/v1.0.1/dist/lodash.min.js) * Lo-Dash compatibility builds (for legacy and modern environments):
-[Development](https://raw.github.com/bestiejs/lodash/v1.0.0/dist/lodash.compat.js) and -[Production](https://raw.github.com/bestiejs/lodash/v1.0.0/dist/lodash.compat.min.js) +[Development](https://raw.github.com/bestiejs/lodash/v1.0.1/dist/lodash.compat.js) and +[Production](https://raw.github.com/bestiejs/lodash/v1.0.1/dist/lodash.compat.min.js) * Underscore compatibility builds:
-[Development](https://raw.github.com/bestiejs/lodash/v1.0.0/dist/lodash.underscore.js) and -[Production](https://raw.github.com/bestiejs/lodash/v1.0.0/dist/lodash.underscore.min.js) +[Development](https://raw.github.com/bestiejs/lodash/v1.0.1/dist/lodash.underscore.js) and +[Production](https://raw.github.com/bestiejs/lodash/v1.0.1/dist/lodash.underscore.min.js) -* CDN copies of ≤ v1.0.0’s builds are available on [cdnjs](http://cdnjs.com/) thanks to [CloudFlare](http://www.cloudflare.com/):
-[Lo-Dash dev](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.0/lodash.js), -[Lo-Dash prod](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.0/lodash.min.js),
-[Lo-Dash compat-dev](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.0/lodash.compat.js), -[Lo-Dash compat-prod](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.0/lodash.compat.min.js),
-[Underscore compat-dev](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.0/lodash.underscore.js), and -[Underscore compat-prod](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.0/lodash.underscore.min.js) +* CDN copies of ≤ v1.0.1’s builds are available on [cdnjs](http://cdnjs.com/) thanks to [CloudFlare](http://www.cloudflare.com/):
+[Lo-Dash dev](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.1/lodash.js), +[Lo-Dash prod](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.1/lodash.min.js),
+[Lo-Dash compat-dev](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.1/lodash.compat.js), +[Lo-Dash compat-prod](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.1/lodash.compat.min.js),
+[Underscore compat-dev](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.1/lodash.underscore.js), and +[Underscore compat-prod](http://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.0.1/lodash.underscore.min.js) * For optimal file size, [create a custom build](https://github.com/bestiejs/lodash#custom-builds) with only the features you need @@ -33,16 +33,20 @@ We’ve got [API docs](http://lodash.com/docs), [benchmarks](http://lodash.com/b For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/lodash/wiki/Roadmap). -## Screencasts +## Resources -For more information check out these screencasts over Lo-Dash: +For more information check out these articles, screencasts, and other videos over Lo-Dash: - * [Introducing Lo-Dash](https://vimeo.com/44154599) - * [Lo-Dash optimizations and custom builds](https://vimeo.com/44154601) - * [Lo-Dash’s origin and why it’s a better utility belt](https://vimeo.com/44154600) - * [Unit testing in Lo-Dash](https://vimeo.com/45865290) - * [Lo-Dash’s approach to native method use](https://vimeo.com/48576012) - * [CascadiaJS: Lo-Dash for a better utility belt](http://www.youtube.com/watch?v=dpPy4f_SeEk) + * Posts + - [Say “Hello” to Lo-Dash](http://kitcambridge.be/blog/say-hello-to-lo-dash/) + + * Videos + - [Introducing Lo-Dash](https://vimeo.com/44154599) + - [Lo-Dash optimizations and custom builds](https://vimeo.com/44154601) + - [Lo-Dash’s origin and why it’s a better utility belt](https://vimeo.com/44154600) + - [Unit testing in Lo-Dash](https://vimeo.com/45865290) + - [Lo-Dash’s approach to native method use](https://vimeo.com/48576012) + - [CascadiaJS: Lo-Dash for a better utility belt](http://www.youtube.com/watch?v=dpPy4f_SeEk) ## Features @@ -69,7 +73,7 @@ For more information check out these screencasts over Lo-Dash: ## Support -Lo-Dash has been tested in at least Chrome 5~24, Firefox 1~18, IE 6-10, Opera 9.25-12, Safari 3-6, Node.js 0.4.8-0.8.19, Narwhal 0.3.2, PhantomJS 1.8.1, RingoJS 0.9, and Rhino 1.7RC5. +Lo-Dash has been tested in at least Chrome 5~24, Firefox 1~18, IE 6-10, Opera 9.25-12, Safari 3-6, Node.js 0.4.8-0.8.20, Narwhal 0.3.2, PhantomJS 1.8.1, RingoJS 0.9, and Rhino 1.7RC5. ## Custom builds @@ -243,30 +247,15 @@ require({ ## Release Notes -### v1.0.0 - -#### Compatibility Warnings - - * Made `_.defaults` preserve `null` values, instead of overwriting them - -#### Changes - - * Added [_.at](http://lodash.com/docs#at) and [_.partialRight](http://lodash.com/docs#partialRight) - * Added [*“imports”*](http://lodash.com/docs#templateSettings_imports) option to `_.templateSettings` - * Added `modern` and `--source-map`/`-p` build options - * Added support for *“_.pluck”* and *“_.where”* `callback` shorthands - * Ensured `_.assign` and `_.defaults` support arrays - * Ensured `_.merge` assigns `null` values and produces dense arrays - * Deferred minifier downloads until the `lodash` utility requires them - * Flipped `noNodeClass` test to avoid triggering Firebug’s *“break on all errors”* feature - * Made `_.where` support deep object comparisons - * Optimized `_.invert`, `_.pairs`, and `_.values` - * Reduced `_.max`, `_.min`, `_.pluck`, `_.toArray`, and `_.where` - * Simplified `createIterator` and `iteratorTemplate` - * Tweaked `_.uniqueId` to avoid problems with buggy minifiers - * Updated `underscore` build compatibility to v1.4.4 - * Added support for `callback` and `thisArg` arguments to `_.assign`, `_.clone`,
- `_.cloneDeep`, `_.first`, `_.last`, `_.initial`, `_.isEqual`, `_.merge`, and `_.rest` +### v1.0.1 + + * Add support for specifying source map URLs in `-p`/`--source-map` build options + * Ensured the second argument passed to `_.assign` is not treated as a `callback` + * Ensured `-p`/`--source-map` build options correctly set the `sourceMappingURL` + * Made `-p`/`--source-map` build options set source map *“sources”* keys based on the builds performed + * Made `_.defer` use `setImmediate`, in Node.js, when available + * Made `_.where` search arrays for values regardless of their index position + * Removed dead code from `_.template` The full changelog is available [here](https://github.com/bestiejs/lodash/wiki/Changelog). diff --git a/build.js b/build.js index b482ed7d7d..4e34c827da 100755 --- a/build.js +++ b/build.js @@ -2324,9 +2324,6 @@ } else { source = source.replace(/(?: *\/\/.*\n)* *(?:else )?if *\(freeExports\) *{\s*}(?:\s*else *{([\s\S]+?) *})?\n/, '$1\n'); } - if ((source.match(/\bfreeExports\b/g) || []).length < 2) { - source = removeVar(source, 'freeExports'); - } }()); /*------------------------------------------------------------------------*/ @@ -2409,6 +2406,12 @@ source = source.replace(/^ *\(function\(\) *{[\s\S]+?}\(1\)\);\n/m, ''); } } + if ((source.match(/\bfreeModule\b/g) || []).length < 2) { + source = removeVar(source, 'freeModule'); + } + if ((source.match(/\bfreeExports\b/g) || []).length < 2) { + source = removeVar(source, 'freeExports'); + } debugSource = cleanupSource(source); source = cleanupSource(source); diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 4ee3363328..37ebc920be 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -1,6 +1,6 @@ /** * @license - * Lo-Dash 1.0.0 (Custom Build) + * Lo-Dash 1.0.1 (Custom Build) * Build: `lodash -o ./dist/lodash.compat.js` * Copyright 2012-2013 The Dojo Foundation * Based on Underscore.js 1.4.4 @@ -186,7 +186,7 @@ var noCharByIndex = ('x'[0] + Object('x')[0]) != 'xx'; /** - * Detect if a node's [[Class]] is unresolvable (IE < 9) + * Detect if a DOM node's [[Class]] is unresolvable (IE < 9) * and that the JS engine won't error when attempting to coerce an object to * a string without a `toString` function. */ @@ -4231,7 +4231,7 @@ var args = slice(arguments, 1); return setTimeout(function() { func.apply(undefined, args); }, 1); } - // use Node's `setImmediate`, if available + // use `setImmediate` if it's available in Node.js if (isV8 && freeModule && typeof setImmediate == 'function') { defer = bind(setImmediate, window); } @@ -5066,7 +5066,7 @@ * @memberOf _ * @type String */ - lodash.VERSION = '1.0.0'; + lodash.VERSION = '1.0.1'; // add "Chaining" functions to the wrapper lodash.prototype.toString = wrapperToString; diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 27226a1823..adb164d973 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -1,6 +1,6 @@ /** * @license - * Lo-Dash 1.0.0 (Custom Build) lodash.com/license + * Lo-Dash 1.0.1 (Custom Build) lodash.com/license * Build: `lodash -o ./dist/lodash.compat.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ @@ -37,6 +37,6 @@ return Et.apply(r,arguments),t.apply(this,r)}},r.zip=function(n){for(var t=-1,r= },r.isString=A,r.isUndefined=function(n){return typeof n=="undefined"},r.lastIndexOf=function(n,t,r){var e=n?n.length:0;for(typeof r=="number"&&(e=(0>r?qt(0,e+r):Dt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=ct,this},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Tt()*((+t||0)-n+1))},r.reduce=D,r.reduceRight=T,r.result=function(n,r){var e=n?n[r]:t;return w(e)?n[r]():e},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:vr(n).length },r.some=B,r.sortedIndex=K,r.template=function(n,e,u){var o=r.templateSettings;n||(n=""),u=mr({},u,o);var i,f=mr({},u.imports,o.imports),o=vr(f),f=E(f),a=0,l=u.interpolate||dt,p="__p+='";n.replace(RegExp((u.escape||dt).source+"|"+l.source+"|"+(l===mt?ht:dt).source+"|"+(u.evaluate||dt).source+"|$","g"),function(t,r,e,u,o,f){return e||(e=u),p+=n.slice(a,f).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(i=Q,p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),a=f+t.length,t}),p+="';\n",l=u=u.variable,l||(u="obj",p="with("+u+"){"+p+"}"),p=(i?p.replace(pt,""):p).replace(st,"$1").replace(vt,"$1;"),p="function("+u+"){"+(l?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+p+"return __p}"; try{var s=Function(o,"return "+p).apply(t,f)}catch(v){throw v.source=p,v}return e?s(e):(s.source=p,s)},r.unescape=function(n){return n==W?"":(n+"").replace(lt,g)},r.uniqueId=function(n){var t=++it;return(n==W?"":n+"")+t},r.all=I,r.any=B,r.detect=R,r.foldl=D,r.foldr=T,r.include=k,r.inject=D,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return Et.apply(t,arguments),n.apply(r,t)})}),r.first=M,r.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=W){var o=u; -for(t=f(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==W||r)return n[u-1];return v(n,qt(0,u-e))}},r.take=M,r.head=M,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e&&typeof t!="function"?u:new r(u)})}),r.VERSION="1.0.0",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,cr(["join","pop","shift"],function(n){var t=ut[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),cr(["push","reverse","sort","unshift"],function(n){var t=ut[n]; +for(t=f(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==W||r)return n[u-1];return v(n,qt(0,u-e))}},r.take=M,r.head=M,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e);return t==W||e&&typeof t!="function"?u:new r(u)})}),r.VERSION="1.0.1",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,cr(["join","pop","shift"],function(n){var t=ut[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),cr(["push","reverse","sort","unshift"],function(n){var t=ut[n]; r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),cr(["concat","slice","splice"],function(n){var t=ut[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments))}}),Qt&&cr(["pop","shift","splice"],function(n){var t=ut[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r })):Y?Z?(Z.exports=r)._=r:Y._=r:n._=r})(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index c9100cac17..67c6055838 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -1,6 +1,6 @@ /** * @license - * Lo-Dash 1.0.0 (Custom Build) + * Lo-Dash 1.0.1 (Custom Build) * Build: `lodash modern -o ./dist/lodash.js` * Copyright 2012-2013 The Dojo Foundation * Based on Underscore.js 1.4.4 @@ -4081,7 +4081,7 @@ var args = slice(arguments, 1); return setTimeout(function() { func.apply(undefined, args); }, 1); } - // use Node's `setImmediate`, if available + // use `setImmediate` if it's available in Node.js if (isV8 && freeModule && typeof setImmediate == 'function') { defer = bind(setImmediate, window); } @@ -4916,7 +4916,7 @@ * @memberOf _ * @type String */ - lodash.VERSION = '1.0.0'; + lodash.VERSION = '1.0.1'; // add "Chaining" functions to the wrapper lodash.prototype.toString = wrapperToString; diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 4062e9b7f6..c898ff0f0c 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -1,6 +1,6 @@ /** * @license - * Lo-Dash 1.0.0 (Custom Build) lodash.com/license + * Lo-Dash 1.0.1 (Custom Build) lodash.com/license * Build: `lodash modern -o ./dist/lodash.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ @@ -36,5 +36,5 @@ return jt.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},e.merge=O,e.min=function },e.reduce=D,e.reduceRight=I,e.result=function(n,r){var e=n?n[r]:t;return j(e)?n[r]():e},e.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:tr(n).length},e.some=T,e.sortedIndex=C,e.template=function(n,r,u){var o=e.templateSettings;n||(n=""),u=or({},u,o);var i,f=or({},u.imports,o.imports),o=tr(f),f=E(f),a=0,c=u.interpolate||gt,p="__p+='";n.replace(RegExp((u.escape||gt).source+"|"+c.source+"|"+(c===vt?st:gt).source+"|"+(u.evaluate||gt).source+"|$","g"),function(t,r,e,u,o,f){return e||(e=u),p+=n.slice(a,f).replace(yt,l),r&&(p+="'+__e("+r+")+'"),o&&(i=L,p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),a=f+t.length,t }),p+="';\n",c=u=u.variable,c||(u="obj",p="with("+u+"){"+p+"}"),p=(i?p.replace(ft,""):p).replace(at,"$1").replace(ct,"$1;"),p="function("+u+"){"+(c?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+p+"return __p}";try{var s=Function(o,"return "+p).apply(t,f)}catch(v){throw v.source=p,v}return r?s(r):(s.source=p,s)},e.unescape=function(n){return n==Q?"":(n+"").replace(it,g)},e.uniqueId=function(n){var t=++rt;return(n==Q?"":n+"")+t },e.all=k,e.any=T,e.detect=R,e.foldl=D,e.foldr=I,e.include=S,e.inject=D,Zt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(){var t=[this.__wrapped__];return wt.apply(t,arguments),n.apply(e,t)})}),e.first=B,e.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=Q){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==Q||r)return n[u-1];return v(n,Nt(0,u-e))}},e.take=B,e.head=B,Zt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(t,r){var u=n(this.__wrapped__,t,r); -return t==Q||r&&typeof t!="function"?u:new e(u)})}),e.VERSION="1.0.0",e.prototype.toString=function(){return this.__wrapped__+""},e.prototype.value=J,e.prototype.valueOf=J,Xt(["join","pop","shift"],function(n){var t=nt[n];e.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),Xt(["push","reverse","sort","unshift"],function(n){var t=nt[n];e.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Xt(["concat","slice","splice"],function(n){var t=nt[n];e.prototype[n]=function(){return new e(t.apply(this.__wrapped__,arguments)) +return t==Q||r&&typeof t!="function"?u:new e(u)})}),e.VERSION="1.0.1",e.prototype.toString=function(){return this.__wrapped__+""},e.prototype.value=J,e.prototype.valueOf=J,Xt(["join","pop","shift"],function(n){var t=nt[n];e.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),Xt(["push","reverse","sort","unshift"],function(n){var t=nt[n];e.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Xt(["concat","slice","splice"],function(n){var t=nt[n];e.prototype[n]=function(){return new e(t.apply(this.__wrapped__,arguments)) }}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=e,define(function(){return e})):X?Y?(Y.exports=e)._=e:X._=e:n._=e})(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index 484317168e..516edda036 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -1,6 +1,6 @@ /** * @license - * Lo-Dash 1.0.0 (Custom Build) + * Lo-Dash 1.0.1 (Custom Build) * Build: `lodash underscore -o ./dist/lodash.underscore.js` * Copyright 2012-2013 The Dojo Foundation * Based on Underscore.js 1.4.4 @@ -3470,7 +3470,7 @@ var args = slice(arguments, 1); return setTimeout(function() { func.apply(undefined, args); }, 1); } - // use Node's `setImmediate`, if available + // use `setImmediate` if it's available in Node.js if (isV8 && freeModule && typeof setImmediate == 'function') { defer = bind(setImmediate, window); } @@ -4248,7 +4248,7 @@ * @memberOf _ * @type String */ - lodash.VERSION = '1.0.0'; + lodash.VERSION = '1.0.1'; // add functions to `lodash.prototype` mixin(lodash); diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index 03f4c7b1b4..42897cec28 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -1,6 +1,6 @@ /** * @license - * Lo-Dash 1.0.0 (Custom Build) lodash.com/license + * Lo-Dash 1.0.1 (Custom Build) lodash.com/license * Build: `lodash underscore -o ./dist/lodash.underscore.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ @@ -30,5 +30,5 @@ var e=-1;t=dt(0,ft((t-n)/r));for(var u=Array(t);++er?dt(0,e+r):bt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},u.mixin=H,u.noConflict=function(){return n._=rt,this},u.random=function(n,t){return n==K&&t==K&&(t=1),n=+n||0,t==K&&(t=n,n=0),n+lt(jt()*((+t||0)-n+1))},u.reduce=q,u.reduceRight=I,u.result=function(n,t){var r=n?n[t]:K;return j(r)?n[t]():r},u.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Dt(n).length },u.some=B,u.sortedIndex=P,u.template=function(n,t,r){n||(n=""),r=y({},r,u.templateSettings);var e=0,o="__p+='",i=r.variable;n.replace(RegExp((r.escape||ot).source+"|"+(r.interpolate||ot).source+"|"+(r.evaluate||ot).source+"|$","g"),function(t,r,u,i,a){return o+=n.slice(e,a).replace(at,f),r&&(o+="'+_['escape']("+r+")+'"),i&&(o+="';"+i+";__p+='"),u&&(o+="'+((__t=("+u+"))==null?'':__t)+'"),e=a+t.length,t}),o+="';\n",i||(i="obj",o="with("+i+"||{}){"+o+"}"),o="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+o+"return __p}"; try{var a=Function("_","return "+o)(u)}catch(c){throw c.source=o,c}return t?a(t):(a.source=o,a)},u.unescape=function(n){return n==K?"":(n+"").replace(et,s)},u.uniqueId=function(n){var t=++nt+"";return n?n+t:t},u.all=S,u.any=B,u.detect=k,u.foldl=q,u.foldr=I,u.include=O,u.inject=q,u.first=M,u.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=K){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==K||r)return n[u-1];return p(n,dt(0,u-e))}},u.take=M,u.head=M,u.chain=function(n){return n=new u(n),n.__chain__=J,n -},u.VERSION="1.0.0",H(u),u.prototype.chain=function(){return this.__chain__=J,this},u.prototype.value=function(){return this.__wrapped__},e("pop push reverse shift sort splice unshift".split(" "),function(n){var t=Z[n];u.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),Rt&&0===n.length&&delete n[0],this}}),e(["concat","join","slice"],function(n){var t=Z[n];u.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new u(n),n.__chain__=J),n +},u.VERSION="1.0.1",H(u),u.prototype.chain=function(){return this.__chain__=J,this},u.prototype.value=function(){return this.__wrapped__},e("pop push reverse shift sort splice unshift".split(" "),function(n){var t=Z[n];u.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),Rt&&0===n.length&&delete n[0],this}}),e(["concat","join","slice"],function(n){var t=Z[n];u.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new u(n),n.__chain__=J),n }}),Q?X?(X.exports=u)._=u:Q._=u:n._=u})(this); \ No newline at end of file diff --git a/doc/README.md b/doc/README.md index ec6bfe3006..8e22b33a07 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,4 +1,4 @@ -# Lo-Dash v1.0.0 +# Lo-Dash v1.0.1 diff --git a/doc/parse.php b/doc/parse.php index 6cf7d397d7..978138945e 100644 --- a/doc/parse.php +++ b/doc/parse.php @@ -21,7 +21,7 @@ // generate Markdown $markdown = docdown(array( 'path' => '../' . $file, - 'title' => 'Lo-Dash v1.0.0', + 'title' => 'Lo-Dash v1.0.1', 'toc' => 'categories', 'url' => 'https://github.com/bestiejs/lodash/blob/master/lodash.js' )); diff --git a/lodash.js b/lodash.js index 1362e12486..6babfef378 100644 --- a/lodash.js +++ b/lodash.js @@ -1,6 +1,6 @@ /** * @license - * Lo-Dash 1.0.0 + * Lo-Dash 1.0.1 * Copyright 2012-2013 The Dojo Foundation * Based on Underscore.js 1.4.4 * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud Inc. @@ -185,7 +185,7 @@ var noCharByIndex = ('x'[0] + Object('x')[0]) != 'xx'; /** - * Detect if a node's [[Class]] is unresolvable (IE < 9) + * Detect if a DOM node's [[Class]] is unresolvable (IE < 9) * and that the JS engine won't error when attempting to coerce an object to * a string without a `toString` function. */ @@ -4238,7 +4238,7 @@ var args = slice(arguments, 1); return setTimeout(function() { func.apply(undefined, args); }, 1); } - // use Node's `setImmediate`, if available + // use `setImmediate` if it's available in Node.js if (isV8 && freeModule && typeof setImmediate == 'function') { defer = bind(setImmediate, window); } @@ -5073,7 +5073,7 @@ * @memberOf _ * @type String */ - lodash.VERSION = '1.0.0'; + lodash.VERSION = '1.0.1'; // add "Chaining" functions to the wrapper lodash.prototype.toString = wrapperToString; diff --git a/package.json b/package.json index ffdb2a26ea..a55a0c0713 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lodash", - "version": "1.0.0", + "version": "1.0.1", "description": "An alternative to Underscore.js, delivering consistency, customization, performance, and extra features.", "homepage": "http://lodash.com", "main": "./dist/lodash",