From 3b2e0e34ef6db89346c9c7127fe2b0e6294820d1 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 17 Apr 2013 00:08:14 -0700 Subject: [PATCH 01/38] Tweak release notes in README.md. [ci skip] Former-commit-id: 316e7610ad00ca0b9d6a80ec44d38e1e739dcfd8 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 98c9c493de..8651a92913 100644 --- a/README.md +++ b/README.md @@ -249,7 +249,6 @@ require({ ### v1.2.0 - * Added Bower package support * Added `_.unzip` * Added an `options` argument to `_.debounce` and `_.throttle` * Allowed non-`underscore` builds to include `_.findWhere` and `_.chain` @@ -257,10 +256,11 @@ require({ * Ensured build utility runs on Windows * Ensured `underscore` build versions of *“isType”* methods align with Underscore * Ensured methods avoid issues with the `__proto__` property + * Ensured `_.isEqual` uses a `callback` only if it’s a function * Ensured `_.merge` applies a `callback` to nested properties * Ensured `_.merge` passes the correct `callback` arguments when comparing objects * Made Lo-Dash work with Browserify - * Removed method compilation from the `modern` + * Removed method compilation from the `modern` build The full changelog is available [here](https://github.com/bestiejs/lodash/wiki/Changelog). From e7c44274b09e4a30fff29fcf50112f1e7fba8936 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 17 Apr 2013 08:43:18 -0700 Subject: [PATCH 02/38] Ensure `_.debounce` performs a trailing call, when both `leading` and `trailing` are `true`, only after the throttled function is called more than once. [closes #243] Former-commit-id: 59ac6bc4ece373623f2bd753b662b8cc974cabc8 --- lodash.js | 14 +++++++------- test/test.js | 19 ++++++++++++++++--- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/lodash.js b/lodash.js index 520d89b9af..f844ddb3c6 100644 --- a/lodash.js +++ b/lodash.js @@ -4478,13 +4478,14 @@ */ function debounce(func, wait, options) { var args, + inited, result, thisArg, timeoutId, trailing = true; function delayed() { - timeoutId = null; + inited = timeoutId = null; if (trailing) { result = func.apply(thisArg, args); } @@ -4497,15 +4498,15 @@ trailing = 'trailing' in options ? options.trailing : trailing; } return function() { - var isLeading = leading && !timeoutId; args = arguments; thisArg = this; - clearTimeout(timeoutId); - timeoutId = setTimeout(delayed, wait); - if (isLeading) { + if (!inited && leading) { + inited = true; result = func.apply(thisArg, args); + } else { + timeoutId = setTimeout(delayed, wait); } return result; }; @@ -4706,10 +4707,9 @@ trailing = true; function trailingCall() { - lastCalled = new Date; timeoutId = null; - if (trailing) { + lastCalled = new Date; result = func.apply(thisArg, args); } } diff --git a/test/test.js b/test/test.js index 4850b21e69..0e3878b04a 100644 --- a/test/test.js +++ b/test/test.js @@ -552,16 +552,29 @@ }, 64); }); - test('should work with `leading` option', function() { - _.each([true, { 'leading': true }], function(options) { - var withLeading = _.debounce(_.identity, 32, options); + asyncTest('should work with `leading` option', function() { + var counts = [0, 0, 0]; + _.each([true, { 'leading': true }], function(options, index) { + var withLeading = _.debounce(function(value) { + counts[index]++; + return value; + }, 32, options); + equal(withLeading('x'), 'x'); }); + _.times(2, _.debounce(function() { counts[2]++; }, 32, { 'leading': true })); + strictEqual(counts[2], 1); + _.each([false, { 'leading': false }], function(options) { var withoutLeading = _.debounce(_.identity, 32, options); strictEqual(withoutLeading('x'), undefined); }); + + setTimeout(function() { + deepEqual(counts, [1, 1, 2]); + QUnit.start(); + }, 64); }); asyncTest('should work with `trailing` option', function() { From 28cd4c3ee9971f99089cac926b2184a3360de2f6 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 17 Apr 2013 09:04:07 -0700 Subject: [PATCH 03/38] Update docs & builds. Former-commit-id: 84fbc06fe506451e70fb76cef16cbc072468df99 --- dist/lodash.compat.js | 14 +++++++------- dist/lodash.compat.min.js | 4 ++-- dist/lodash.js | 14 +++++++------- dist/lodash.min.js | 4 ++-- doc/README.md | 14 +++++++------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 5746344894..d7926b5e45 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -4468,13 +4468,14 @@ */ function debounce(func, wait, options) { var args, + inited, result, thisArg, timeoutId, trailing = true; function delayed() { - timeoutId = null; + inited = timeoutId = null; if (trailing) { result = func.apply(thisArg, args); } @@ -4487,15 +4488,15 @@ trailing = 'trailing' in options ? options.trailing : trailing; } return function() { - var isLeading = leading && !timeoutId; args = arguments; thisArg = this; - clearTimeout(timeoutId); - timeoutId = setTimeout(delayed, wait); - if (isLeading) { + if (!inited && leading) { + inited = true; result = func.apply(thisArg, args); + } else { + timeoutId = setTimeout(delayed, wait); } return result; }; @@ -4696,10 +4697,9 @@ trailing = true; function trailingCall() { - lastCalled = new Date; timeoutId = null; - if (trailing) { + lastCalled = new Date; result = func.apply(thisArg, args); } } diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 28cb0d210e..a04bc7edc5 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -27,12 +27,12 @@ U.prototype=a.prototype,ve.argsClass||(Q=function(n){return n?Qt.call(n,"callee" tt(/x/)&&(tt=function(n){return n instanceof $t||Zt.call(n)==E});var Oe=Jt?function(n){if(!n||Zt.call(n)!=A||!ve.argsClass&&Q(n))return!1;var t=n.valueOf,e=typeof t=="function"&&(e=Jt(t))&&Jt(e);return e?n==e||Jt(n)==e:G(n)}:G;pe&&u&&typeof Xt=="function"&&(Ot=xt(Xt,r));var Ee=8==ie("08")?ie:function(n,t){return ie(ut(n)?n.replace(m,""):n,t||0)};return a.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},a.assign=Ce,a.at=function(n){var t=-1,e=Gt.apply(zt,le.call(arguments,1)),r=e.length,u=It(r); for(ve.unindexedChars&&ut(n)&&(n=n.split(""));++t=l,i=[],c=i;n:for(;++u_t(c,p)){o&&c.push(p); for(var v=e;--v;)if(!(r[v]||(r[v]=F(t[v])))(p))continue n;i.push(p)}}return i},a.invert=Y,a.invoke=function(n,t){var e=le.call(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=It(typeof a=="number"?a:0);return pt(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},a.keys=de,a.map=st,a.max=vt,a.memoize=function(n,t){var e={};return function(){var r=f+(t?t.apply(this,arguments):arguments[0]);return Qt.call(e,r)?e[r]:e[r]=n.apply(this,arguments)}},a.merge=at,a.min=function(n,t,e){var r=1/0,u=r; if(!t&&Z(n)){e=-1;for(var o=n.length;++e_t(o,e))&&(u[e]=n)}),u},a.once=function(n){var t,e;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e)}},a.pairs=function(n){for(var t=-1,e=de(n),r=e.length,u=It(r);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:d,variable:"",imports:{_:M}},Q.prototype=M.prototype;var me=ce?function(n){return ot(n)?ce(n):[]}:K,be={"&":"&","<":"<",">":">",'"':""","'":"'"},de=et(be);return zt&&i&&typeof ee=="function"&&(At=St(ee,o)),Tt=8==se("08")?se:function(n,t){return se(ft(n)?n.replace(_,""):n,t||0)},M.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 }},M.assign=P,M.at=function(n){for(var t=-1,e=Xt.apply(Gt,ge.call(arguments,1)),r=e.length,u=Rt(r);++t=s,i=[],f=i;n:for(;++uxt(f,c)){o&&f.push(c); for(var v=e;--v;)if(!(r[v]||(r[v]=U(t[v])))(c))continue n;i.push(c)}}return i},M.invert=et,M.invoke=function(n,t){var e=ge.call(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Rt(typeof a=="number"?a:0);return yt(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},M.keys=me,M.map=ht,M.max=mt,M.memoize=function(n,t){var e={};return function(){var r=p+(t?t.apply(this,arguments):arguments[0]);return ne.call(e,r)?e[r]:e[r]=n.apply(this,arguments)}},M.merge=ct,M.min=function(n,t,e){var r=1/0,u=r; if(!t&&rt(n)){e=-1;for(var a=n.length;++ext(a,e))&&(u[e]=n)}),u},M.once=function(n){var t,e;return function(){return t?e:(t=r,e=n.apply(this,arguments),n=u,e)}},M.pairs=function(n){for(var t=-1,e=me(n),r=e.length,u=Rt(r);++t ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4529 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4530 "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. @@ -2127,7 +2127,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4555 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4556 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -2154,7 +2154,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4579 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4580 "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. @@ -2180,7 +2180,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4606 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4607 "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. @@ -2206,7 +2206,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4641 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4642 "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. @@ -2233,7 +2233,7 @@ hi('moe'); ### `_.partialRight(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4672 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4673 "View in source") [Ⓣ][1] This method is similar to `_.partial`, except that `partial` arguments are appended to those passed to the new function. @@ -2270,7 +2270,7 @@ options.imports ### `_.throttle(func, wait, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4699 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4700 "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. Pass an `options` object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the throttled function will return the result of the last `func` call. From 45d59d75ba9fc8776d487b0404c3221192bb8efe Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 17 Apr 2013 19:52:49 -0700 Subject: [PATCH 04/38] Remove stray `fs.writeFileSync` in build.js. Former-commit-id: ba94c84ac7e3d2fe9be8e578035132c86cd59790 --- build.js | 1 - 1 file changed, 1 deletion(-) diff --git a/build.js b/build.js index f250637338..a50dff7635 100755 --- a/build.js +++ b/build.js @@ -2667,7 +2667,6 @@ 'setTimeout': setTimeout }); - fs.writeFileSync('lodash.custom.js', source, 'utf-8') vm.runInContext(source, context); return context._; }()); From e80e1dab4d93c2deba11baae7ce0a118b7418293 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 17 Apr 2013 19:53:14 -0700 Subject: [PATCH 05/38] Add `lodash underscore` build tests for isType methods. Former-commit-id: 80898964d46abebb3acf1e5e3586f4df700cd85b --- test/test-build.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/test-build.js b/test/test-build.js index 939f237afd..f61d5e75e8 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -961,6 +961,11 @@ strictEqual(actual, false, '_.isEqual should ignore `callback` and `thisArg`: ' + basename); + _.each(['isArray', 'isBoolean', 'isDate', 'isFunction', 'isNumber', 'isRegExp', 'isString'], function(methodName) { + var proto = global[methodName.slice(2)].prototype; + strictEqual(lodash[methodName](Object.create(proto)), false, '_.' + methodName + ' returns `false` for subclassed values: ' + basename); + }); + equal(lodash.max('abc'), -Infinity, '_.max should return `-Infinity` for strings: ' + basename); equal(lodash.min('abc'), Infinity, '_.min should return `Infinity` for strings: ' + basename); From 2a92600fa7bb6d928c43aa296565a9efe38fb4cd Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 17 Apr 2013 21:36:37 -0700 Subject: [PATCH 06/38] Add `_.throttle` unit test to test `lastCalled`. Former-commit-id: 528ebd3514aacafcde55fad989f955f1fe403811 --- test/test.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/test.js b/test/test.js index 0e3878b04a..ffdaa18363 100644 --- a/test/test.js +++ b/test/test.js @@ -2843,11 +2843,27 @@ }); setTimeout(function() { - strictEqual(withCount, 2); + equal(withCount, 2); strictEqual(withoutCount, 1); QUnit.start(); }, 64); }); + + asyncTest('should not update `lastCalled`, at the end of the timeout, when `trailing` is `false`', function() { + var count = 0; + + var throttled = _.throttle(function() { + count++; + }, 64, { 'trailing': false }); + + _.times(2, throttled); + setTimeout(function() { _.times(2, throttled); }, 100); + + setTimeout(function() { + equal(count, 2); + QUnit.start(); + }, 128); + }); }()); /*--------------------------------------------------------------------------*/ From 3bb119f578506805acd9e35de227bc6c8252a69f Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 17 Apr 2013 22:40:49 -0700 Subject: [PATCH 07/38] Update `_.debounce` and `_.throttled` docs. [ci skip] Former-commit-id: 5a94c9d35069952c72303541409b88656deaa6a7 --- dist/lodash.compat.js | 18 ++++++++----- dist/lodash.js | 18 ++++++++----- dist/lodash.underscore.js | 18 ++++++++----- doc/README.md | 54 +++++++++++++++++++++------------------ lodash.js | 18 ++++++++----- 5 files changed, 77 insertions(+), 49 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index d7926b5e45..05d9fe6449 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -4452,6 +4452,10 @@ * and/or trailing edge of the `wait` timeout. Subsequent calls to the debounced * function will return the result of the last `func` call. * + * Note: If `leading` and `trailing` options are `true`, `func` will be called + * on the trailing edge of the timeout only if the the throttled function is + * invoked more than once during the `wait` timeout. + * * @static * @memberOf _ * @category Functions @@ -4666,12 +4670,14 @@ /** * 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. Pass an `options` object to indicate - * that `func` should be invoked on the leading and/or trailing edge of the - * `wait` timeout. Subsequent calls to the throttled function will return - * the result of the last `func` call. + * at most once per every `wait` milliseconds. Pass an `options` object to + * indicate that `func` should be invoked on the leading and/or trailing edge + * of the `wait` timeout. Subsequent calls to the throttled function will + * return the result of the last `func` call. + * + * Note: If `leading` and `trailing` options are `true`, `func` will be called + * on the trailing edge of the timeout only if the the throttled function is + * invoked more than once during the `wait` timeout. * * @static * @memberOf _ diff --git a/dist/lodash.js b/dist/lodash.js index 2f4cf66c4c..3a5a5d70b1 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -4193,6 +4193,10 @@ * and/or trailing edge of the `wait` timeout. Subsequent calls to the debounced * function will return the result of the last `func` call. * + * Note: If `leading` and `trailing` options are `true`, `func` will be called + * on the trailing edge of the timeout only if the the throttled function is + * invoked more than once during the `wait` timeout. + * * @static * @memberOf _ * @category Functions @@ -4407,12 +4411,14 @@ /** * 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. Pass an `options` object to indicate - * that `func` should be invoked on the leading and/or trailing edge of the - * `wait` timeout. Subsequent calls to the throttled function will return - * the result of the last `func` call. + * at most once per every `wait` milliseconds. Pass an `options` object to + * indicate that `func` should be invoked on the leading and/or trailing edge + * of the `wait` timeout. Subsequent calls to the throttled function will + * return the result of the last `func` call. + * + * Note: If `leading` and `trailing` options are `true`, `func` will be called + * on the trailing edge of the timeout only if the the throttled function is + * invoked more than once during the `wait` timeout. * * @static * @memberOf _ diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index 197441ec92..0248391940 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -3468,6 +3468,10 @@ * and/or trailing edge of the `wait` timeout. Subsequent calls to the debounced * function will return the result of the last `func` call. * + * Note: If `leading` and `trailing` options are `true`, `func` will be called + * on the trailing edge of the timeout only if the the throttled function is + * invoked more than once during the `wait` timeout. + * * @static * @memberOf _ * @category Functions @@ -3638,12 +3642,14 @@ /** * 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. Pass an `options` object to indicate - * that `func` should be invoked on the leading and/or trailing edge of the - * `wait` timeout. Subsequent calls to the throttled function will return - * the result of the last `func` call. + * at most once per every `wait` milliseconds. Pass an `options` object to + * indicate that `func` should be invoked on the leading and/or trailing edge + * of the `wait` timeout. Subsequent calls to the throttled function will + * return the result of the last `func` call. + * + * Note: If `leading` and `trailing` options are `true`, `func` will be called + * on the trailing edge of the timeout only if the the throttled function is + * invoked more than once during the `wait` timeout. * * @static * @memberOf _ diff --git a/doc/README.md b/doc/README.md index 6422682ae5..89f57f6023 100644 --- a/doc/README.md +++ b/doc/README.md @@ -972,7 +972,7 @@ _.isArray(squares.value()); ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5229 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5235 "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. @@ -1002,7 +1002,7 @@ _([1, 2, 3, 4]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5246 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5252 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -1023,7 +1023,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5263 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5269 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -2076,10 +2076,12 @@ _.toLookup(stooges, 'name'); ### `_.debounce(func, wait, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4479 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4483 "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 an `options` object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. +Note: If `leading` and `trailing` options are `true`, `func` will be called on the trailing edge of the timeout only if the the throttled function is invoked more than once during the `wait` timeout. + #### Arguments 1. `func` *(Function)*: The function to debounce. 2. `wait` *(Number)*: The number of milliseconds to delay. @@ -2102,7 +2104,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4530 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4534 "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. @@ -2127,7 +2129,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4556 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4560 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -2154,7 +2156,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4580 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4584 "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. @@ -2180,7 +2182,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4607 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4611 "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. @@ -2206,7 +2208,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4642 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4646 "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. @@ -2233,7 +2235,7 @@ hi('moe'); ### `_.partialRight(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4673 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4677 "View in source") [Ⓣ][1] This method is similar to `_.partial`, except that `partial` arguments are appended to those passed to the new function. @@ -2270,9 +2272,11 @@ options.imports ### `_.throttle(func, wait, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4700 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4706 "View in source") [Ⓣ][1] + +Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. Pass an `options` object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the throttled function will return the result of the last `func` call. -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. Pass an `options` object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the throttled function will return the result of the last `func` call. +Note: If `leading` and `trailing` options are `true`, `func` will be called on the trailing edge of the timeout only if the the throttled function is invoked more than once during the `wait` timeout. #### Arguments 1. `func` *(Function)*: The function to throttle. @@ -2296,7 +2300,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4765 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4771 "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. @@ -3340,7 +3344,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4789 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4795 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -3364,7 +3368,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4807 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4813 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -3389,7 +3393,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4833 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4839 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -3419,7 +3423,7 @@ _('moe').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4862 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4868 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -3439,7 +3443,7 @@ var lodash = _.noConflict(); ### `_.parseInt(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4883 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4889 "View in source") [Ⓣ][1] Converts the given `value` into an integer of the specified `radix`. @@ -3465,7 +3469,7 @@ _.parseInt('08'); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4906 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4912 "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. @@ -3493,7 +3497,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4945 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4951 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function, it will be invoked with the `this` binding of `object` and its result returned, else the property value is returned. If `object` is falsey, then `undefined` is returned. @@ -3546,7 +3550,7 @@ Create a new `lodash` function using the given `context` object. ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5029 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5035 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -3628,7 +3632,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5154 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5160 "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)*. @@ -3660,7 +3664,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5181 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5187 "View in source") [Ⓣ][1] The inverse of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3684,7 +3688,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5201 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5207 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3737,7 +3741,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5438 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5444 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index f844ddb3c6..63ee29cac7 100644 --- a/lodash.js +++ b/lodash.js @@ -4462,6 +4462,10 @@ * and/or trailing edge of the `wait` timeout. Subsequent calls to the debounced * function will return the result of the last `func` call. * + * Note: If `leading` and `trailing` options are `true`, `func` will be called + * on the trailing edge of the timeout only if the the throttled function is + * invoked more than once during the `wait` timeout. + * * @static * @memberOf _ * @category Functions @@ -4676,12 +4680,14 @@ /** * 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. Pass an `options` object to indicate - * that `func` should be invoked on the leading and/or trailing edge of the - * `wait` timeout. Subsequent calls to the throttled function will return - * the result of the last `func` call. + * at most once per every `wait` milliseconds. Pass an `options` object to + * indicate that `func` should be invoked on the leading and/or trailing edge + * of the `wait` timeout. Subsequent calls to the throttled function will + * return the result of the last `func` call. + * + * Note: If `leading` and `trailing` options are `true`, `func` will be called + * on the trailing edge of the timeout only if the the throttled function is + * invoked more than once during the `wait` timeout. * * @static * @memberOf _ From a707c2fe8ea7599faf219fa3e3393d7e964b01b6 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 19 Apr 2013 00:12:22 -0700 Subject: [PATCH 08/38] Ensure isType methods return `false` for subclassed values. Former-commit-id: e300d12eb506c6ae4949bd37cf8eb33c3a4be2e1 --- build.js | 45 ++++++++++++++++++++++++------------------ lodash.js | 49 ++++++++++++++++++++++------------------------ test/test-build.js | 5 ----- test/test.js | 9 +++++++++ 4 files changed, 58 insertions(+), 50 deletions(-) diff --git a/build.js b/build.js index a50dff7635..458a82fd92 100755 --- a/build.js +++ b/build.js @@ -786,6 +786,19 @@ return (source.match(/(?:\s*\/\/.*)*\n( *)if *\((?:!support\.argsClass|!isArguments)[\s\S]+?};\n\1}/) || [''])[0]; } + /** + * Gets the `_.isArray` fallback from `source`. + * + * @private + * @param {String} source The source to inspect. + * @returns {String} Returns the `isArray` fallback. + */ + function getIsArrayFallback(source) { + return matchFunction(source, 'isArray') + .replace(/^[\s\S]+?=\s*nativeIsArray\b/, '') + .replace(/[;\s]+$/, ''); + } + /** * Gets the `_.isFunction` fallback from `source`. * @@ -1016,6 +1029,17 @@ return source.replace(getIsArgumentsFallback(source), ''); } + /** + * Removes the `_.isArray` fallback from `source`. + * + * @private + * @param {String} source The source to process. + * @returns {String} Returns the modified source. + */ + function removeIsArrayFallback(source) { + return source.replace(getIsArrayFallback(source), ''); + } + /** * Removes the `_.isFunction` fallback from `source`. * @@ -1074,11 +1098,6 @@ function removeSupportArgsObject(source) { source = removeSupportProp(source, 'argsObject'); - // remove `argsAreObjects` from `_.isArray` - source = source.replace(matchFunction(source, 'isArray'), function(match) { - return match.replace(/\(support\.argsObject\s*&&\s*([^)]+)\)/g, '$1'); - }); - // remove `argsAreObjects` from `_.isEqual` source = source.replace(matchFunction(source, 'isEqual'), function(match) { return match.replace(/!support.\argsObject[^:]+:\s*/g, ''); @@ -1867,7 +1886,7 @@ // remove native `Array.isArray` branch in `_.isArray` source = source.replace(matchFunction(source, 'isArray'), function(match) { - return match.replace(/\s*\(nativeIsArray.+/, ' toString.call(value) == arrayClass;'); + return match.replace(/\bnativeIsArray\s*\|\|\s*/, ''); }); // replace `_.keys` with `shimKeys` @@ -1919,6 +1938,7 @@ source = removeSupportNodeClass(source); if (!isMobile) { + source = removeIsArrayFallback(source); source = removeSupportEnumPrototypes(source); source = removeSupportNonEnumArgs(source); @@ -2006,11 +2026,6 @@ source = source.replace(/^( *)var eachIteratorOptions *= *[\s\S]+?\n\1};\n/m, function(match) { return match.replace(/(^ *'arrays':)[^,]+/m, '$1 false'); }); - - // remove `toString.call` use from `_.isArray` - source = source.replace(matchFunction(source, 'isArray'), function(match) { - return match.replace(/\s*\(nativeIsArray.+/, ' nativeIsArray(value);'); - }); } } if (isUnderscore) { @@ -2535,14 +2550,6 @@ return match.replace(/\bisEqual\(([^,]+), *([^,]+)[^)]+\)/, '$1 === $2'); }); - // remove `instanceof` use from `_.isDate`, `_.isFunction`, and `_.isRegExp` - _.each(['isDate', 'isFunction', 'isRegExp'], function(methodName) { - var snippet = methodName == 'isFunction' ? getIsFunctionFallback(source) : matchFunction(source, methodName); - source = source.replace(snippet, function(match) { - return match.replace(/\w+\s+instanceof\s+\w+\s*\|\|\s*/g, ''); - }); - }); - // remove conditional `charCodeCallback` use from `_.max` and `_.min` _.each(['max', 'min'], function(methodName) { source = source.replace(matchFunction(source, methodName), function(match) { diff --git a/lodash.js b/lodash.js index 63ee29cac7..9bfcb5ce39 100644 --- a/lodash.js +++ b/lodash.js @@ -943,6 +943,26 @@ }; } + /** + * Checks if `value` is an array. + * + * @static + * @memberOf _ + * @category Objects + * @param {Mixed} value The value to check. + * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`. + * @example + * + * (function() { return _.isArray(arguments); })(); + * // => false + * + * _.isArray([1, 2, 3]); + * // => true + */ + var isArray = nativeIsArray || function(value) { + return value && typeof value == 'object' && toString.call(value) == arrayClass; + }; + /** * A fallback implementation of `Object.keys` which produces an array of the * given object's own enumerable property names. @@ -1416,29 +1436,6 @@ return result; } - /** - * Checks if `value` is an array. - * - * @static - * @memberOf _ - * @category Objects - * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`. - * @example - * - * (function() { return _.isArray(arguments); })(); - * // => false - * - * _.isArray([1, 2, 3]); - * // => true - */ - function isArray(value) { - // `instanceof` may cause a memory leak in IE 7 if `value` is a host object - // http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak - return (support.argsObject && value instanceof Array) || - (nativeIsArray ? nativeIsArray(value) : toString.call(value) == arrayClass); - } - /** * Checks if `value` is a boolean value. * @@ -1470,7 +1467,7 @@ * // => true */ function isDate(value) { - return value instanceof Date || toString.call(value) == dateClass; + return value ? typeof value == 'object' && toString.call(value) == dateClass : false; } /** @@ -1774,7 +1771,7 @@ // fallback for older versions of Chrome and Safari if (isFunction(/x/)) { isFunction = function(value) { - return value instanceof Function || toString.call(value) == funcClass; + return typeof value == 'function' && toString.call(value) == funcClass; }; } @@ -1924,7 +1921,7 @@ * // => true */ function isRegExp(value) { - return value instanceof RegExp || toString.call(value) == regexpClass; + return value ? typeof value == 'object' && toString.call(value) == regexpClass : false; } /** diff --git a/test/test-build.js b/test/test-build.js index f61d5e75e8..939f237afd 100644 --- a/test/test-build.js +++ b/test/test-build.js @@ -961,11 +961,6 @@ strictEqual(actual, false, '_.isEqual should ignore `callback` and `thisArg`: ' + basename); - _.each(['isArray', 'isBoolean', 'isDate', 'isFunction', 'isNumber', 'isRegExp', 'isString'], function(methodName) { - var proto = global[methodName.slice(2)].prototype; - strictEqual(lodash[methodName](Object.create(proto)), false, '_.' + methodName + ' returns `false` for subclassed values: ' + basename); - }); - equal(lodash.max('abc'), -Infinity, '_.max should return `-Infinity` for strings: ' + basename); equal(lodash.min('abc'), Infinity, '_.min should return `Infinity` for strings: ' + basename); diff --git a/test/test.js b/test/test.js index ffdaa18363..683923a981 100644 --- a/test/test.js +++ b/test/test.js @@ -1611,6 +1611,15 @@ equal(typeof func({ 'a': 1 }), expected); equal(typeof func('a'), expected); }); + + test('should return `false` for subclassed values', function() { + _.each(['isArray', 'isBoolean', 'isDate', 'isFunction', 'isNumber', 'isRegExp', 'isString'], function(methodName) { + function Foo() {} + Foo.prototype = window[methodName.slice(2)].prototype; + + strictEqual(_[methodName](new Foo), false, '_.' + methodName + ' returns `false`'); + }); + }); }); /*--------------------------------------------------------------------------*/ From 038b1bcf7bfe9c97859279f933f66219e9dbc1f0 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 19 Apr 2013 01:02:36 -0700 Subject: [PATCH 09/38] Update `_.debounce` and `_.throttle` doc examples and rebuild. Former-commit-id: fc094e857aeae0ab9581ad56dca894cc96bc7b2e --- dist/lodash.compat.js | 58 +++++---- dist/lodash.compat.min.js | 79 +++++++------ dist/lodash.js | 53 +++++---- dist/lodash.min.js | 72 ++++++------ dist/lodash.underscore.js | 55 +++++---- dist/lodash.underscore.min.js | 57 ++++----- doc/README.md | 215 ++++++++++++++++++---------------- lodash.js | 9 ++ 8 files changed, 319 insertions(+), 279 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 05d9fe6449..551fbb2b59 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -934,6 +934,26 @@ }; } + /** + * Checks if `value` is an array. + * + * @static + * @memberOf _ + * @category Objects + * @param {Mixed} value The value to check. + * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`. + * @example + * + * (function() { return _.isArray(arguments); })(); + * // => false + * + * _.isArray([1, 2, 3]); + * // => true + */ + var isArray = nativeIsArray || function(value) { + return value && typeof value == 'object' && toString.call(value) == arrayClass; + }; + /** * A fallback implementation of `Object.keys` which produces an array of the * given object's own enumerable property names. @@ -1406,29 +1426,6 @@ return result; } - /** - * Checks if `value` is an array. - * - * @static - * @memberOf _ - * @category Objects - * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`. - * @example - * - * (function() { return _.isArray(arguments); })(); - * // => false - * - * _.isArray([1, 2, 3]); - * // => true - */ - function isArray(value) { - // `instanceof` may cause a memory leak in IE 7 if `value` is a host object - // http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak - return (support.argsObject && value instanceof Array) || - (nativeIsArray ? nativeIsArray(value) : toString.call(value) == arrayClass); - } - /** * Checks if `value` is a boolean value. * @@ -1460,7 +1457,7 @@ * // => true */ function isDate(value) { - return value instanceof Date || toString.call(value) == dateClass; + return value ? typeof value == 'object' && toString.call(value) == dateClass : false; } /** @@ -1764,7 +1761,7 @@ // fallback for older versions of Chrome and Safari if (isFunction(/x/)) { isFunction = function(value) { - return value instanceof Function || toString.call(value) == funcClass; + return typeof value == 'function' && toString.call(value) == funcClass; }; } @@ -1914,7 +1911,7 @@ * // => true */ function isRegExp(value) { - return value instanceof RegExp || toString.call(value) == regexpClass; + return value ? typeof value == 'object' && toString.call(value) == regexpClass : false; } /** @@ -4469,6 +4466,11 @@ * * var lazyLayout = _.debounce(calculateLayout, 300); * jQuery(window).on('resize', lazyLayout); + * + * jQuery('.postbox').on('click', _.debounce(sendMail, 200, { + * 'leading': true, + * 'trailing': false + * }); */ function debounce(func, wait, options) { var args, @@ -4692,6 +4694,10 @@ * * var throttled = _.throttle(updatePosition, 100); * jQuery(window).on('scroll', throttled); + * + * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { + * 'trailing': false + * })); */ function throttle(func, wait, options) { var args, diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index a04bc7edc5..95135b1384 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -4,43 +4,44 @@ * Build: `lodash -o ./dist/lodash.compat.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ -;(function(n){function t(r){function a(n){return n&&typeof n=="object"&&!Z(n)&&Qt.call(n,"__wrapped__")?n:new U(n)}function F(n){var t=n.length,e=t>=l;if(e)for(var r={},u=-1;++ut||typeof n=="undefined")return 1;if(nu;u++)r+="i='"+t.g[u]+"';if(","constructor"==t.g[u]&&(r+="!(f&&f.prototype===m)&&"),r+="h.call(m,i)){"+t.f+"}"}return(t.b||ve.nonEnumArgs)&&(r+="}"),r+=t.c+";return u",e("h,j,k,l,o,p,r","return function("+n+"){"+r+"}")(Qt,Q,Z,ut,de,a,$) -}function L(n){return"\\"+q[n]}function K(n){return _e[n]}function M(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function U(n){this.__wrapped__=n}function V(){}function G(n){var t=!1;if(!n||Zt.call(n)!=A||!ve.argsClass&&Q(n))return t;var e=n.constructor;return(tt(e)?e instanceof e:ve.nodeClass||!M(n))?ve.ownLast?(ke(n,function(n,e,r){return t=Qt.call(r,e),!1}),!0===t):(ke(n,function(n,e){t=e}),!1===t||Qt.call(n,t)):t}function H(n,t,e){t||(t=0),typeof e=="undefined"&&(e=n?n.length:0); -var r=-1;e=e-t||0;for(var u=It(0>e?0:e);++re?ae(0,u+e):e)||0,typeof u=="number"?a=-1<(ut(n)?n.indexOf(t,e):_t(n,t,e)):be(n,function(n){return++ru&&(u=i)}}else t=!t&&ut(n)?R:a.createCallback(t,e),be(n,function(n,e,a){e=t(n,e,a),e>r&&(r=e,u=n) -});return u}function gt(n,t,e,r){var u=3>arguments.length;if(t=a.createCallback(t,r,4),Z(n)){var o=-1,i=n.length;for(u&&(e=n[++o]);++oarguments.length;if(typeof o!="number")var f=de(n),o=f.length;else ve.unindexedChars&&ut(n)&&(u=n.split(""));return t=a.createCallback(t,r,4),pt(n,function(n,r,a){r=f?f[--o]:--o,e=i?(i=!1,u[r]):t(e,u[r],r,a)}),e}function yt(n,t,e){var r;if(t=a.createCallback(t,e),Z(n)){e=-1; -for(var u=n.length;++ee?ae(0,u+e):e||0)-1;else if(e)return r=Ct(n,t),n[r]===t?r:-1;for(;++r>>1,e(n[r])=l;if(p)var s={};for(null!=e&&(c=[],e=a.createCallback(e,r));++u_t(c,v))&&((e||p)&&c.push(v),i.push(r))}return i}function kt(n,t){for(var e=-1,r=n?n.length:0,u={};++e/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:y,variable:"",imports:{_:a}};var ge={a:"q,w,g",h:"var a=arguments,b=0,c=typeof g=='number'?2:a.length;while(++b":">",'"':""","'":"'"},we=Y(_e),Ce=z(ge,{h:ge.h.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=p.createCallback(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),f:"u[i]=d?d(u[i],m[i]):m[i]"}),je=z(ge),ke=z(he,ye,{i:!1}),xe=z(he,ye); -tt(/x/)&&(tt=function(n){return n instanceof $t||Zt.call(n)==E});var Oe=Jt?function(n){if(!n||Zt.call(n)!=A||!ve.argsClass&&Q(n))return!1;var t=n.valueOf,e=typeof t=="function"&&(e=Jt(t))&&Jt(e);return e?n==e||Jt(n)==e:G(n)}:G;pe&&u&&typeof Xt=="function"&&(Ot=xt(Xt,r));var Ee=8==ie("08")?ie:function(n,t){return ie(ut(n)?n.replace(m,""):n,t||0)};return a.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},a.assign=Ce,a.at=function(n){var t=-1,e=Gt.apply(zt,le.call(arguments,1)),r=e.length,u=It(r); -for(ve.unindexedChars&&ut(n)&&(n=n.split(""));++t=l,i=[],c=i;n:for(;++u_t(c,p)){o&&c.push(p); -for(var v=e;--v;)if(!(r[v]||(r[v]=F(t[v])))(p))continue n;i.push(p)}}return i},a.invert=Y,a.invoke=function(n,t){var e=le.call(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=It(typeof a=="number"?a:0);return pt(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},a.keys=de,a.map=st,a.max=vt,a.memoize=function(n,t){var e={};return function(){var r=f+(t?t.apply(this,arguments):arguments[0]);return Qt.call(e,r)?e[r]:e[r]=n.apply(this,arguments)}},a.merge=at,a.min=function(n,t,e){var r=1/0,u=r; -if(!t&&Z(n)){e=-1;for(var o=n.length;++e_t(o,e))&&(u[e]=n)}),u},a.once=function(n){var t,e;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e)}},a.pairs=function(n){for(var t=-1,e=de(n),r=e.length,u=It(r);++te?ae(0,r+e):oe(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},a.mixin=St,a.noConflict=function(){return r._=Kt,this},a.parseInt=Ee,a.random=function(n,t){return null==n&&null==t&&(t=1),n=+n||0,null==t&&(t=n,n=0),n+Ht(fe()*((+t||0)-n+1))},a.reduce=gt,a.reduceRight=ht,a.result=function(n,t){var r=n?n[t]:e;return tt(r)?n[t]():r},a.runInContext=t,a.size=function(n){var t=n?n.length:0; -return typeof t=="number"?t:de(n).length},a.some=yt,a.sortedIndex=Ct,a.template=function(n,t,r){var u=a.templateSettings;n||(n=""),r=je({},r,u);var o,i=je({},r.imports,u.imports),u=de(i),i=ot(i),f=0,l=r.interpolate||d,v="__p+='",l=Rt((r.escape||d).source+"|"+l.source+"|"+(l===y?g:d).source+"|"+(r.evaluate||d).source+"|$","g");n.replace(l,function(t,e,r,u,a,i){return r||(r=u),v+=n.slice(f,i).replace(_,L),e&&(v+="'+__e("+e+")+'"),a&&(o=!0,v+="';"+a+";__p+='"),r&&(v+="'+((__t=("+r+"))==null?'':__t)+'"),f=i+t.length,t -}),v+="';\n",l=r=r.variable,l||(r="obj",v="with("+r+"){"+v+"}"),v=(o?v.replace(c,""):v).replace(p,"$1").replace(s,"$1;"),v="function("+r+"){"+(l?"":r+"||("+r+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+v+"return __p}";try{var h=$t(u,"return "+v).apply(e,i)}catch(m){throw m.source=v,m}return t?h(t):(h.source=v,h)},a.unescape=function(n){return null==n?"":Tt(n).replace(v,J)},a.uniqueId=function(n){var t=++o;return Tt(null==n?"":n)+t -},a.all=ft,a.any=yt,a.detect=ct,a.foldl=gt,a.foldr=ht,a.include=it,a.inject=gt,xe(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(){var t=[this.__wrapped__];return Wt.apply(t,arguments),n.apply(a,t)})}),a.first=dt,a.last=function(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;for(t=a.createCallback(t,e);o--&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n[u-1];return H(n,ae(0,u-r))}},a.take=dt,a.head=dt,xe(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e); -return null==t||e&&typeof t!="function"?r:new U(r)})}),a.VERSION="1.2.0",a.prototype.toString=function(){return Tt(this.__wrapped__)},a.prototype.value=At,a.prototype.valueOf=At,be(["join","pop","shift"],function(n){var t=zt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),be(["push","reverse","sort","unshift"],function(n){var t=zt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),be(["concat","slice","splice"],function(n){var t=zt[n];a.prototype[n]=function(){return new U(t.apply(this.__wrapped__,arguments)) -}}),ve.spliceObjects||be(["pop","shift","splice"],function(n){var t=zt[n],e="splice"==n;a.prototype[n]=function(){var n=this.__wrapped__,r=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new U(r):r}}),a}var e,r=typeof exports=="object"&&exports,u=typeof module=="object"&&module&&module.exports==r&&module,a=typeof global=="object"&&global;(a.global===a||a.window===a)&&(n=a);var o=0,i={},f=+new Date+"",l=200,c=/\b__p\+='';/g,p=/\b(__p\+=)''\+/g,s=/(__e\(.*?\)|\b__t\))\+'';/g,v=/&(?:amp|lt|gt|quot|#39);/g,g=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,h=/\w*$/,y=/<%=([\s\S]+?)%>/g,m=/^0+(?=.$)/,d=/($^)/,b=/[&<>"']/g,_=/['\n\r\t\u2028\u2029\\]/g,w="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),C="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),j="[object Arguments]",k="[object Array]",x="[object Boolean]",O="[object Date]",E="[object Function]",S="[object Number]",A="[object Object]",I="[object RegExp]",P="[object String]",N={}; +;(function(n){function t(r){function a(n){return n&&typeof n=="object"&&!he(n)&&Jt.call(n,"__wrapped__")?n:new U(n)}function F(n){var t=n.length,e=t>=l;if(e)for(var r={},u=-1;++ut||typeof n=="undefined")return 1;if(nu;u++)r+="i='"+t.g[u]+"';if(","constructor"==t.g[u]&&(r+="!(f&&f.prototype===m)&&"),r+="h.call(m,i)){"+t.f+"}"}return(t.b||se.nonEnumArgs)&&(r+="}"),r+=t.c+";return u",e("h,j,k,l,o,p,r","return function("+n+"){"+r+"}")(Jt,Q,he,rt,de,a,$) +}function L(n){return"\\"+q[n]}function K(n){return _e[n]}function M(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function U(n){this.__wrapped__=n}function V(){}function G(n){var t=!1;if(!n||Yt.call(n)!=A||!se.argsClass&&Q(n))return t;var e=n.constructor;return(nt(e)?e instanceof e:se.nodeClass||!M(n))?se.ownLast?(ke(n,function(n,e,r){return t=Jt.call(r,e),!1}),!0===t):(ke(n,function(n,e){t=e}),!1===t||Jt.call(n,t)):t}function H(n,t,e){t||(t=0),typeof e=="undefined"&&(e=n?n.length:0); +var r=-1;e=e-t||0;for(var u=At(0>e?0:e);++re?ue(0,u+e):e)||0,typeof u=="number"?a=-1<(rt(n)?n.indexOf(t,e):bt(n,t,e)):be(n,function(n){return++ru&&(u=i)}}else t=!t&&rt(n)?R:a.createCallback(t,e),be(n,function(n,e,a){e=t(n,e,a),e>r&&(r=e,u=n) +});return u}function vt(n,t,e,r){var u=3>arguments.length;if(t=a.createCallback(t,r,4),he(n)){var o=-1,i=n.length;for(u&&(e=n[++o]);++oarguments.length;if(typeof o!="number")var f=de(n),o=f.length;else se.unindexedChars&&rt(n)&&(u=n.split(""));return t=a.createCallback(t,r,4),ct(n,function(n,r,a){r=f?f[--o]:--o,e=i?(i=!1,u[r]):t(e,u[r],r,a)}),e}function yt(n,t,e){var r; +if(t=a.createCallback(t,e),he(n)){e=-1;for(var u=n.length;++ee?ue(0,u+e):e||0)-1;else if(e)return r=wt(n,t),n[r]===t?r:-1;for(;++r>>1,e(n[r])=l;if(p)var s={};for(null!=e&&(c=[],e=a.createCallback(e,r));++ubt(c,v))&&((e||p)&&c.push(v),i.push(r))}return i}function jt(n,t){for(var e=-1,r=n?n.length:0,u={};++e/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:h,variable:"",imports:{_:a}};var ve={a:"q,w,g",h:"var a=arguments,b=0,c=typeof g=='number'?2:a.length;while(++b":">",'"':""","'":"'"},we=Y(_e),Ce=z(ve,{h:ve.h.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=p.createCallback(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),f:"u[i]=d?d(u[i],m[i]):m[i]"}),je=z(ve),ke=z(ge,ye,{i:!1}),xe=z(ge,ye); +nt(/x/)&&(nt=function(n){return typeof n=="function"&&Yt.call(n)==E});var Oe=Ht?function(n){if(!n||Yt.call(n)!=A||!se.argsClass&&Q(n))return!1;var t=n.valueOf,e=typeof t=="function"&&(e=Ht(t))&&Ht(e);return e?n==e||Ht(n)==e:G(n)}:G;ce&&u&&typeof Wt=="function"&&(xt=kt(Wt,r));var Ee=8==oe("08")?oe:function(n,t){return oe(rt(n)?n.replace(m,""):n,t||0)};return a.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},a.assign=Ce,a.at=function(n){var t=-1,e=Vt.apply(Dt,fe.call(arguments,1)),r=e.length,u=At(r); +for(se.unindexedChars&&rt(n)&&(n=n.split(""));++t=l,i=[],c=i;n:for(;++ubt(c,p)){o&&c.push(p); +for(var v=e;--v;)if(!(r[v]||(r[v]=F(t[v])))(p))continue n;i.push(p)}}return i},a.invert=Y,a.invoke=function(n,t){var e=fe.call(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=At(typeof a=="number"?a:0);return ct(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},a.keys=de,a.map=pt,a.max=st,a.memoize=function(n,t){var e={};return function(){var r=f+(t?t.apply(this,arguments):arguments[0]);return Jt.call(e,r)?e[r]:e[r]=n.apply(this,arguments)}},a.merge=ut,a.min=function(n,t,e){var r=1/0,u=r; +if(!t&&he(n)){e=-1;for(var o=n.length;++ebt(o,e))&&(u[e]=n)}),u},a.once=function(n){var t,e;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e)}},a.pairs=function(n){for(var t=-1,e=de(n),r=e.length,u=At(r);++te?ue(0,r+e):ae(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},a.mixin=Et,a.noConflict=function(){return r._=Lt,this},a.parseInt=Ee,a.random=function(n,t){return null==n&&null==t&&(t=1),n=+n||0,null==t&&(t=n,n=0),n+Gt(ie()*((+t||0)-n+1))},a.reduce=vt,a.reduceRight=gt,a.result=function(n,t){var r=n?n[t]:e;return nt(r)?n[t]():r},a.runInContext=t,a.size=function(n){var t=n?n.length:0; +return typeof t=="number"?t:de(n).length},a.some=yt,a.sortedIndex=wt,a.template=function(n,t,r){var u=a.templateSettings;n||(n=""),r=je({},r,u);var o,i=je({},r.imports,u.imports),u=de(i),i=at(i),f=0,l=r.interpolate||d,v="__p+='",l=Ft((r.escape||d).source+"|"+l.source+"|"+(l===h?g:d).source+"|"+(r.evaluate||d).source+"|$","g");n.replace(l,function(t,e,r,u,a,i){return r||(r=u),v+=n.slice(f,i).replace(_,L),e&&(v+="'+__e("+e+")+'"),a&&(o=!0,v+="';"+a+";__p+='"),r&&(v+="'+((__t=("+r+"))==null?'':__t)+'"),f=i+t.length,t +}),v+="';\n",l=r=r.variable,l||(r="obj",v="with("+r+"){"+v+"}"),v=(o?v.replace(c,""):v).replace(p,"$1").replace(s,"$1;"),v="function("+r+"){"+(l?"":r+"||("+r+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+v+"return __p}";try{var y=Nt(u,"return "+v).apply(e,i)}catch(m){throw m.source=v,m}return t?y(t):(y.source=v,y)},a.unescape=function(n){return null==n?"":Rt(n).replace(v,J)},a.uniqueId=function(n){var t=++o;return Rt(null==n?"":n)+t +},a.all=it,a.any=yt,a.detect=lt,a.foldl=vt,a.foldr=gt,a.include=ot,a.inject=vt,xe(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(){var t=[this.__wrapped__];return Qt.apply(t,arguments),n.apply(a,t)})}),a.first=mt,a.last=function(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;for(t=a.createCallback(t,e);o--&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n[u-1];return H(n,ue(0,u-r))}},a.take=mt,a.head=mt,xe(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e); +return null==t||e&&typeof t!="function"?r:new U(r)})}),a.VERSION="1.2.0",a.prototype.toString=function(){return Rt(this.__wrapped__)},a.prototype.value=St,a.prototype.valueOf=St,be(["join","pop","shift"],function(n){var t=Dt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),be(["push","reverse","sort","unshift"],function(n){var t=Dt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),be(["concat","slice","splice"],function(n){var t=Dt[n];a.prototype[n]=function(){return new U(t.apply(this.__wrapped__,arguments)) +}}),se.spliceObjects||be(["pop","shift","splice"],function(n){var t=Dt[n],e="splice"==n;a.prototype[n]=function(){var n=this.__wrapped__,r=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new U(r):r}}),a}var e,r=typeof exports=="object"&&exports,u=typeof module=="object"&&module&&module.exports==r&&module,a=typeof global=="object"&&global;(a.global===a||a.window===a)&&(n=a);var o=0,i={},f=+new Date+"",l=200,c=/\b__p\+='';/g,p=/\b(__p\+=)''\+/g,s=/(__e\(.*?\)|\b__t\))\+'';/g,v=/&(?:amp|lt|gt|quot|#39);/g,g=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,y=/\w*$/,h=/<%=([\s\S]+?)%>/g,m=/^0+(?=.$)/,d=/($^)/,b=/[&<>"']/g,_=/['\n\r\t\u2028\u2029\\]/g,w="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),C="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),j="[object Arguments]",k="[object Array]",x="[object Boolean]",O="[object Date]",E="[object Function]",S="[object Number]",A="[object Object]",I="[object RegExp]",P="[object String]",N={}; N[E]=!1,N[j]=N[k]=N[x]=N[O]=N[S]=N[A]=N[I]=N[P]=!0;var $={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},q={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},B=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=B,define(function(){return B})):r&&!r.nodeType?u?(u.exports=B)._=B:r._=B:n._=B})(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index 3a5a5d70b1..c7557a2d67 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -618,6 +618,24 @@ return toString.call(value) == argsClass; } + /** + * Checks if `value` is an array. + * + * @static + * @memberOf _ + * @category Objects + * @param {Mixed} value The value to check. + * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`. + * @example + * + * (function() { return _.isArray(arguments); })(); + * // => false + * + * _.isArray([1, 2, 3]); + * // => true + */ + var isArray = nativeIsArray; + /** * A fallback implementation of `Object.keys` which produces an array of the * given object's own enumerable property names. @@ -1148,28 +1166,6 @@ return result; } - /** - * Checks if `value` is an array. - * - * @static - * @memberOf _ - * @category Objects - * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`. - * @example - * - * (function() { return _.isArray(arguments); })(); - * // => false - * - * _.isArray([1, 2, 3]); - * // => true - */ - function isArray(value) { - // `instanceof` may cause a memory leak in IE 7 if `value` is a host object - // http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak - return value instanceof Array || nativeIsArray(value); - } - /** * Checks if `value` is a boolean value. * @@ -1201,7 +1197,7 @@ * // => true */ function isDate(value) { - return value instanceof Date || toString.call(value) == dateClass; + return value ? typeof value == 'object' && toString.call(value) == dateClass : false; } /** @@ -1648,7 +1644,7 @@ * // => true */ function isRegExp(value) { - return value instanceof RegExp || toString.call(value) == regexpClass; + return value ? typeof value == 'object' && toString.call(value) == regexpClass : false; } /** @@ -4210,6 +4206,11 @@ * * var lazyLayout = _.debounce(calculateLayout, 300); * jQuery(window).on('resize', lazyLayout); + * + * jQuery('.postbox').on('click', _.debounce(sendMail, 200, { + * 'leading': true, + * 'trailing': false + * }); */ function debounce(func, wait, options) { var args, @@ -4433,6 +4434,10 @@ * * var throttled = _.throttle(updatePosition, 100); * jQuery(window).on('scroll', throttled); + * + * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { + * 'trailing': false + * })); */ function throttle(func, wait, options) { var args, diff --git a/dist/lodash.min.js b/dist/lodash.min.js index ae90a92991..c931c15bc4 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -4,41 +4,41 @@ * Build: `lodash modern -o ./dist/lodash.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ -;(function(n){function t(o){function f(n){if(!n||ue.call(n)!=S)return a;var t=n.valueOf,e=typeof t=="function"&&(e=Zt(t))&&Zt(e);return e?n==e||Zt(n)==e:X(n)}function q(n,t,e){if(!n||!F[typeof n])return n;t=t&&typeof e=="undefined"?t:M.createCallback(t,e);for(var r=-1,u=F[typeof n]?me(n):[],o=u.length;++r=s;if(e)for(var r={},u=-1;++ut||typeof n=="undefined")return 1;if(ne?0:e);++re?le(0,u+e):e)||0,typeof u=="number"?o=-1<(ft(n)?n.indexOf(t,e):xt(n,t,e)):q(n,function(n){return++ru&&(u=o)}}else t=!t&&ft(n)?V:M.createCallback(t,e),yt(n,function(n,e,a){e=t(n,e,a),e>r&&(r=e,u=n)});return u}function bt(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Rt(r);++earguments.length;t=M.createCallback(t,r,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(e=n[++o]);++oarguments.length;if(typeof u!="number")var i=me(n),u=i.length;return t=M.createCallback(t,r,4),yt(n,function(r,f,c){f=i?i[--u]:--u,e=o?(o=a,n[f]):t(e,n[f],f,c)}),e}function kt(n,t,e){var r;t=M.createCallback(t,e),e=-1;var u=n?n.length:0; -if(typeof u=="number")for(;++ee?le(0,u+e):e||0)-1;else if(e)return r=Nt(n,t),n[r]===t?r:-1;for(;++r>>1,e(n[r])=s;if(l)var v={};for(e!=u&&(c=[],e=M.createCallback(e,r));++oxt(c,g))&&((e||l)&&c.push(g),f.push(r))}return f}function It(n,t){for(var e=-1,r=n?n.length:0,u={};++e/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:d,variable:"",imports:{_:M}},Q.prototype=M.prototype;var me=ce?function(n){return ot(n)?ce(n):[]}:K,be={"&":"&","<":"<",">":">",'"':""","'":"'"},de=et(be);return zt&&i&&typeof ee=="function"&&(At=St(ee,o)),Tt=8==se("08")?se:function(n,t){return se(ft(n)?n.replace(_,""):n,t||0)},M.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 -}},M.assign=P,M.at=function(n){for(var t=-1,e=Xt.apply(Gt,ge.call(arguments,1)),r=e.length,u=Rt(r);++t=s,i=[],f=i;n:for(;++uxt(f,c)){o&&f.push(c); -for(var v=e;--v;)if(!(r[v]||(r[v]=U(t[v])))(c))continue n;i.push(c)}}return i},M.invert=et,M.invoke=function(n,t){var e=ge.call(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Rt(typeof a=="number"?a:0);return yt(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},M.keys=me,M.map=ht,M.max=mt,M.memoize=function(n,t){var e={};return function(){var r=p+(t?t.apply(this,arguments):arguments[0]);return ne.call(e,r)?e[r]:e[r]=n.apply(this,arguments)}},M.merge=ct,M.min=function(n,t,e){var r=1/0,u=r; -if(!t&&rt(n)){e=-1;for(var a=n.length;++ext(a,e))&&(u[e]=n)}),u},M.once=function(n){var t,e;return function(){return t?e:(t=r,e=n.apply(this,arguments),n=u,e)}},M.pairs=function(n){for(var t=-1,e=me(n),r=e.length,u=Rt(r);++te?le(0,r+e):pe(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},M.mixin=Bt,M.noConflict=function(){return o._=Jt,this},M.parseInt=Tt,M.random=function(n,t){return n==u&&t==u&&(t=1),n=+n||0,t==u&&(t=n,n=0),n+Yt(ve()*((+t||0)-n+1))},M.reduce=dt,M.reduceRight=_t,M.result=function(n,t){var r=n?n[t]:e;return at(r)?n[t]():r},M.runInContext=t,M.size=function(n){var t=n?n.length:0; -return typeof t=="number"?t:me(n).length},M.some=kt,M.sortedIndex=Nt,M.template=function(n,t,u){var a=M.templateSettings;n||(n=""),u=z({},u,a);var o,i=z({},u.imports,a.imports),a=me(i),i=lt(i),f=0,c=u.interpolate||k,l="__p+='",c=Mt((u.escape||k).source+"|"+c.source+"|"+(c===d?m:k).source+"|"+(u.evaluate||k).source+"|$","g");n.replace(c,function(t,e,u,a,i,c){return u||(u=a),l+=n.slice(f,c).replace(C,J),e&&(l+="'+__e("+e+")+'"),i&&(o=r,l+="';"+i+";__p+='"),u&&(l+="'+((__t=("+u+"))==null?'':__t)+'"),f=c+t.length,t -}),l+="';\n",c=u=u.variable,c||(u="obj",l="with("+u+"){"+l+"}"),l=(o?l.replace(v,""):l).replace(g,"$1").replace(y,"$1;"),l="function("+u+"){"+(c?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}";try{var p=Dt(a,"return "+l).apply(e,i)}catch(s){throw s.source=l,s}return t?p(t):(p.source=l,p)},M.unescape=function(n){return n==u?"":Ut(n).replace(h,Z)},M.uniqueId=function(n){var t=++c;return Ut(n==u?"":n)+t -},M.all=st,M.any=kt,M.detect=gt,M.foldl=dt,M.foldr=_t,M.include=pt,M.inject=dt,q(M,function(n,t){M.prototype[t]||(M.prototype[t]=function(){var t=[this.__wrapped__];return te.apply(t,arguments),n.apply(M,t)})}),M.first=Ct,M.last=function(n,t,e){if(n){var r=0,a=n.length;if(typeof t!="number"&&t!=u){var o=a;for(t=M.createCallback(t,e);o--&&t(n[o],o,n);)r++}else if(r=t,r==u||e)return n[a-1];return Y(n,le(0,a-r))}},M.take=Ct,M.head=Ct,q(M,function(n,t){M.prototype[t]||(M.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e); -return t==u||e&&typeof t!="function"?r:new Q(r)})}),M.VERSION="1.2.0",M.prototype.toString=function(){return Ut(this.__wrapped__)},M.prototype.value=Ft,M.prototype.valueOf=Ft,yt(["join","pop","shift"],function(n){var t=Gt[n];M.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),yt(["push","reverse","sort","unshift"],function(n){var t=Gt[n];M.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),yt(["concat","slice","splice"],function(n){var t=Gt[n];M.prototype[n]=function(){return new Q(t.apply(this.__wrapped__,arguments)) +;(function(n){function t(o){function f(n){if(!n||re.call(n)!=S)return a;var t=n.valueOf,e=typeof t=="function"&&(e=Yt(t))&&Yt(e);return e?n==e||Yt(n)==e:X(n)}function q(n,t,e){if(!n||!F[typeof n])return n;t=t&&typeof e=="undefined"?t:M.createCallback(t,e);for(var r=-1,u=F[typeof n]?me(n):[],o=u.length;++r=s;if(e)for(var r={},u=-1;++ut||typeof n=="undefined")return 1;if(ne?0:e);++re?ce(0,u+e):e)||0,typeof u=="number"?o=-1<(it(n)?n.indexOf(t,e):jt(n,t,e)):q(n,function(n){return++ru&&(u=o)}}else t=!t&&it(n)?V:M.createCallback(t,e),gt(n,function(n,e,a){e=t(n,e,a),e>r&&(r=e,u=n)});return u}function mt(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Ft(r);++earguments.length;t=M.createCallback(t,r,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(e=n[++o]);++oarguments.length;if(typeof u!="number")var i=me(n),u=i.length;return t=M.createCallback(t,r,4),gt(n,function(r,f,c){f=i?i[--u]:--u,e=o?(o=a,n[f]):t(e,n[f],f,c)}),e}function _t(n,t,e){var r;t=M.createCallback(t,e),e=-1;var u=n?n.length:0; +if(typeof u=="number")for(;++ee?ce(0,u+e):e||0)-1;else if(e)return r=Ot(n,t),n[r]===t?r:-1;for(;++r>>1,e(n[r])=s;if(l)var v={};for(e!=u&&(c=[],e=M.createCallback(e,r));++ojt(c,g))&&((e||l)&&c.push(g),f.push(r))}return f}function Et(n,t){for(var e=-1,r=n?n.length:0,u={};++e/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:d,variable:"",imports:{_:M}},Q.prototype=M.prototype;var he=ae,me=fe?function(n){return at(n)?fe(n):[]}:K,be={"&":"&","<":"<",">":">",'"':""","'":"'"},de=et(be);return Dt&&i&&typeof te=="function"&&(St=It(te,o)),Rt=8==pe("08")?pe:function(n,t){return pe(it(n)?n.replace(_,""):n,t||0)},M.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 +}},M.assign=P,M.at=function(n){for(var t=-1,e=Wt.apply(Vt,ve.call(arguments,1)),r=e.length,u=Ft(r);++t=s,i=[],f=i;n:for(;++ujt(f,c)){o&&f.push(c); +for(var v=e;--v;)if(!(r[v]||(r[v]=U(t[v])))(c))continue n;i.push(c)}}return i},M.invert=et,M.invoke=function(n,t){var e=ve.call(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Ft(typeof a=="number"?a:0);return gt(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},M.keys=me,M.map=yt,M.max=ht,M.memoize=function(n,t){var e={};return function(){var r=p+(t?t.apply(this,arguments):arguments[0]);return Zt.call(e,r)?e[r]:e[r]=n.apply(this,arguments)}},M.merge=ft,M.min=function(n,t,e){var r=1/0,u=r; +if(!t&&he(n)){e=-1;for(var a=n.length;++ejt(a,e))&&(u[e]=n)}),u},M.once=function(n){var t,e;return function(){return t?e:(t=r,e=n.apply(this,arguments),n=u,e)}},M.pairs=function(n){for(var t=-1,e=me(n),r=e.length,u=Ft(r);++te?ce(0,r+e):le(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},M.mixin=$t,M.noConflict=function(){return o._=Ht,this},M.parseInt=Rt,M.random=function(n,t){return n==u&&t==u&&(t=1),n=+n||0,t==u&&(t=n,n=0),n+Xt(se()*((+t||0)-n+1))},M.reduce=bt,M.reduceRight=dt,M.result=function(n,t){var r=n?n[t]:e;return ut(r)?n[t]():r},M.runInContext=t,M.size=function(n){var t=n?n.length:0; +return typeof t=="number"?t:me(n).length},M.some=_t,M.sortedIndex=Ot,M.template=function(n,t,u){var a=M.templateSettings;n||(n=""),u=z({},u,a);var o,i=z({},u.imports,a.imports),a=me(i),i=ct(i),f=0,c=u.interpolate||k,l="__p+='",c=Kt((u.escape||k).source+"|"+c.source+"|"+(c===d?m:k).source+"|"+(u.evaluate||k).source+"|$","g");n.replace(c,function(t,e,u,a,i,c){return u||(u=a),l+=n.slice(f,c).replace(C,J),e&&(l+="'+__e("+e+")+'"),i&&(o=r,l+="';"+i+";__p+='"),u&&(l+="'+((__t=("+u+"))==null?'':__t)+'"),f=c+t.length,t +}),l+="';\n",c=u=u.variable,c||(u="obj",l="with("+u+"){"+l+"}"),l=(o?l.replace(v,""):l).replace(g,"$1").replace(y,"$1;"),l="function("+u+"){"+(c?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}";try{var p=qt(a,"return "+l).apply(e,i)}catch(s){throw s.source=l,s}return t?p(t):(p.source=l,p)},M.unescape=function(n){return n==u?"":Mt(n).replace(h,Z)},M.uniqueId=function(n){var t=++c;return Mt(n==u?"":n)+t +},M.all=pt,M.any=_t,M.detect=vt,M.foldl=bt,M.foldr=dt,M.include=lt,M.inject=bt,q(M,function(n,t){M.prototype[t]||(M.prototype[t]=function(){var t=[this.__wrapped__];return ne.apply(t,arguments),n.apply(M,t)})}),M.first=wt,M.last=function(n,t,e){if(n){var r=0,a=n.length;if(typeof t!="number"&&t!=u){var o=a;for(t=M.createCallback(t,e);o--&&t(n[o],o,n);)r++}else if(r=t,r==u||e)return n[a-1];return Y(n,ce(0,a-r))}},M.take=wt,M.head=wt,q(M,function(n,t){M.prototype[t]||(M.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e); +return t==u||e&&typeof t!="function"?r:new Q(r)})}),M.VERSION="1.2.0",M.prototype.toString=function(){return Mt(this.__wrapped__)},M.prototype.value=Bt,M.prototype.valueOf=Bt,gt(["join","pop","shift"],function(n){var t=Vt[n];M.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),gt(["push","reverse","sort","unshift"],function(n){var t=Vt[n];M.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),gt(["concat","slice","splice"],function(n){var t=Vt[n];M.prototype[n]=function(){return new Q(t.apply(this.__wrapped__,arguments)) }}),M}var e,r=!0,u=null,a=!1,o=typeof exports=="object"&&exports,i=typeof module=="object"&&module&&module.exports==o&&module,f=typeof global=="object"&&global;(f.global===f||f.window===f)&&(n=f);var c=0,l={},p=+new Date+"",s=200,v=/\b__p\+='';/g,g=/\b(__p\+=)''\+/g,y=/(__e\(.*?\)|\b__t\))\+'';/g,h=/&(?:amp|lt|gt|quot|#39);/g,m=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,b=/\w*$/,d=/<%=([\s\S]+?)%>/g,_=/^0+(?=.$)/,k=/($^)/,w=/[&<>"']/g,C=/['\n\r\t\u2028\u2029\\]/g,j="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),x="[object Arguments]",O="[object Array]",N="[object Boolean]",E="[object Date]",I="[object Number]",S="[object Object]",A="[object RegExp]",$="[object String]",B={"[object Function]":a}; B[x]=B[O]=B[N]=B[E]=B[I]=B[S]=B[A]=B[$]=r;var F={"boolean":a,"function":r,object:r,number:a,string:a,undefined:a},R={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},T=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=T,define(function(){return T})):o&&!o.nodeType?i?(i.exports=T)._=T:o._=T:n._=T})(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index 0248391940..5797d42ab3 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -483,6 +483,26 @@ }; } + /** + * Checks if `value` is an array. + * + * @static + * @memberOf _ + * @category Objects + * @param {Mixed} value The value to check. + * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`. + * @example + * + * (function() { return _.isArray(arguments); })(); + * // => false + * + * _.isArray([1, 2, 3]); + * // => true + */ + var isArray = nativeIsArray || function(value) { + return toString.call(value) == arrayClass; + }; + /** * A fallback implementation of `Object.keys` which produces an array of the * given object's own enumerable property names. @@ -820,26 +840,6 @@ return result; } - /** - * Checks if `value` is an array. - * - * @static - * @memberOf _ - * @category Objects - * @param {Mixed} value The value to check. - * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`. - * @example - * - * (function() { return _.isArray(arguments); })(); - * // => false - * - * _.isArray([1, 2, 3]); - * // => true - */ - var isArray = nativeIsArray || function(value) { - return toString.call(value) == arrayClass; - }; - /** * Checks if `value` is a boolean value. * @@ -871,7 +871,7 @@ * // => true */ function isDate(value) { - return toString.call(value) == dateClass; + return value ? typeof value == 'object' && toString.call(value) == dateClass : false; } /** @@ -1116,7 +1116,7 @@ // fallback for older versions of Chrome and Safari if (isFunction(/x/)) { isFunction = function(value) { - return toString.call(value) == funcClass; + return typeof value == 'function' && toString.call(value) == funcClass; }; } @@ -1230,7 +1230,7 @@ * // => true */ function isRegExp(value) { - return toString.call(value) == regexpClass; + return value ? typeof value == 'object' && toString.call(value) == regexpClass : false; } /** @@ -3485,6 +3485,11 @@ * * var lazyLayout = _.debounce(calculateLayout, 300); * jQuery(window).on('resize', lazyLayout); + * + * jQuery('.postbox').on('click', _.debounce(sendMail, 200, { + * 'leading': true, + * 'trailing': false + * }); */ function debounce(func, wait, immediate) { var args, @@ -3664,6 +3669,10 @@ * * var throttled = _.throttle(updatePosition, 100); * jQuery(window).on('scroll', throttled); + * + * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { + * 'trailing': false + * })); */ function throttle(func, wait) { var args, diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index b773bf8f3f..013b86b237 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -4,31 +4,32 @@ * Build: `lodash underscore exports="amd,commonjs,global,node" -o ./dist/lodash.underscore.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ -;(function(n){function r(n){return n instanceof r?n:new i(n)}function t(n,r){var t=n.b,e=r.b;if(n=n.a,r=r.a,n!==r){if(n>r||typeof n=="undefined")return 1;if(ne&&(e=t,u=n)});else for(;++ou&&(u=t);return u}function N(n,r){var t=-1,e=n?n.length:0; -if(typeof e=="number")for(var u=Array(e);++targuments.length;r=P(r,e,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(t=n[++o]);++oarguments.length;if(typeof u!="number")var i=Fr(n),u=i.length;return r=P(r,e,4),O(n,function(e,a,f){a=i?i[--u]:--u,t=o?(o=!1,n[a]):r(t,n[a],a,f)}),t}function q(n,r,t){var e; -r=P(r,t),t=-1;var u=n?n.length:0;if(typeof u=="number")for(;++tT(e,o)&&u.push(o)}return u}function D(n,r,t){if(n){var e=0,u=n.length;if(typeof r!="number"&&null!=r){var o=-1;for(r=P(r,t);++ot?Er(0,u+t):t||0)-1;else if(t)return e=I(n,r),n[e]===r?e:-1;for(;++e>>1,t(n[e])T(a,f))&&(t&&a.push(f),i.push(e))}return i}function C(n,r){return qr.fastBind||jr&&2"']/g,Z=/['\n\r\t\u2028\u2029\\]/g,nr="[object Arguments]",rr="[object Array]",tr="[object Boolean]",er="[object Date]",ur="[object Number]",or="[object Object]",ir="[object RegExp]",ar="[object String]",fr={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},lr={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},cr=[],H={},pr=n._,sr=RegExp("^"+(H.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),vr=Math.ceil,gr=n.clearTimeout,hr=cr.concat,yr=Math.floor,mr=H.hasOwnProperty,_r=cr.push,br=n.setTimeout,dr=H.toString,jr=sr.test(jr=dr.bind)&&jr,wr=sr.test(wr=Array.isArray)&&wr,Ar=n.isFinite,xr=n.isNaN,Or=sr.test(Or=Object.keys)&&Or,Er=Math.max,Sr=Math.min,Nr=Math.random,Br=cr.slice,H=sr.test(n.attachEvent),kr=jr&&!/\n|true/.test(jr+H),qr={}; -(function(){var n={0:1,length:1};qr.argsObject=arguments.constructor==Object&&!(arguments instanceof Array),qr.fastBind=jr&&!kr,qr.spliceObjects=(cr.splice.call(n,0,1),!n[0])})(1),r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},i.prototype=r.prototype,l(arguments)||(l=function(n){return n?mr.call(n,"callee"):!1});var H=function(n){var r,t=[];if(!n||!fr[typeof n])return t;for(r in n)mr.call(n,r)&&t.push(r);return t},Fr=Or?function(n){return m(n)?Or(n):[] -}:H,Rr={"&":"&","<":"<",">":">",'"':""","'":"'"},Dr=v(Rr),Mr=function(n,r){var t;if(!n||!fr[typeof n])return n;for(t in n)if(r(n[t],t,n)===K)break;return n},Tr=function(n,r){var t;if(!n||!fr[typeof n])return n;for(t in n)if(mr.call(n,t)&&r(n[t],t,n)===K)break;return n},$r=wr||function(n){return dr.call(n)==rr};y(/x/)&&(y=function(n){return"[object Function]"==dr.call(n)}),r.after=function(n,r){return 1>n?r():function(){return 1>--n?r.apply(this,arguments):void 0}},r.bind=C,r.bindAll=function(n){for(var r=1T(o,i)){for(var a=t;--a;)if(0>T(r[a],i))continue n;o.push(i)}}return o},r.invert=v,r.invoke=function(n,r){var t=Br.call(arguments,2),e=-1,u=typeof r=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return O(n,function(n){i[++e]=(u?r:n[r]).apply(n,t)}),i},r.keys=Fr,r.map=E,r.max=S,r.memoize=function(n,r){var t={};return function(){var e=L+(r?r.apply(this,arguments):arguments[0]); -return mr.call(t,e)?t[e]:t[e]=n.apply(this,arguments)}},r.min=function(n,r,t){var e=1/0,u=e,o=-1,i=n?n.length:0;if(r||typeof i!="number")r=P(r,t),O(n,function(n,t,o){t=r(n,t,o),tT(r,e)&&(t[e]=n)}),t},r.once=function(n){var r,t;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},r.pairs=function(n){for(var r=-1,t=Fr(n),e=t.length,u=Array(e);++rt?Er(0,e+t):Sr(t,e-1))+1);e--;)if(n[e]===r)return e; -return-1},r.mixin=V,r.noConflict=function(){return n._=pr,this},r.random=function(n,r){return null==n&&null==r&&(r=1),n=+n||0,null==r&&(r=n,n=0),n+yr(Nr()*((+r||0)-n+1))},r.reduce=B,r.reduceRight=k,r.result=function(n,r){var t=n?n[r]:null;return y(t)?n[r]():t},r.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:Fr(n).length},r.some=q,r.sortedIndex=I,r.template=function(n,t,e){n||(n=""),e=p({},e,r.templateSettings);var o=0,i="__p+='",a=e.variable;n.replace(RegExp((e.escape||X).source+"|"+(e.interpolate||X).source+"|"+(e.evaluate||X).source+"|$","g"),function(r,t,e,a,f){return i+=n.slice(o,f).replace(Z,u),t&&(i+="'+_['escape']("+t+")+'"),a&&(i+="';"+a+";__p+='"),e&&(i+="'+((__t=("+e+"))==null?'':__t)+'"),o=f+r.length,r -}),i+="';\n",a||(a="obj",i="with("+a+"||{}){"+i+"}"),i="function("+a+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+i+"return __p}";try{var f=Function("_","return "+i)(r)}catch(l){throw l.source=i,l}return t?f(t):(f.source=i,f)},r.unescape=function(n){return null==n?"":(n+"").replace(Q,f)},r.uniqueId=function(n){var r=++J+"";return n?n+r:r},r.all=w,r.any=q,r.detect=x,r.foldl=B,r.foldr=k,r.include=j,r.inject=B,r.first=D,r.last=function(n,r,t){if(n){var e=0,u=n.length; -if(typeof r!="number"&&null!=r){var o=u;for(r=P(r,t);o--&&r(n[o],o,n);)e++}else if(e=r,null==e||t)return n[u-1];return Br.call(n,Er(0,u-e))}},r.take=D,r.head=D,r.chain=function(n){return n=new i(n),n.__chain__=!0,n},r.VERSION="1.2.0",V(r),r.prototype.chain=function(){return this.__chain__=!0,this},r.prototype.value=function(){return this.__wrapped__},O("pop push reverse shift sort splice unshift".split(" "),function(n){var t=cr[n];r.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),!qr.spliceObjects&&0===n.length&&delete n[0],this -}}),O(["concat","join","slice"],function(n){var t=cr[n];r.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new i(n),n.__chain__=!0),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):W&&!W.nodeType?G?(G.exports=r)._=r:W._=r:n._=r})(this); \ No newline at end of file +;(function(n){function t(n){return n instanceof t?n:new i(n)}function r(n,t){var r=n.b,e=t.b;if(n=n.a,t=t.a,n!==t){if(n>t||typeof n=="undefined")return 1;if(ne&&(e=r,u=n)});else for(;++ou&&(u=r);return u}function N(n,t){var r=-1,e=n?n.length:0; +if(typeof e=="number")for(var u=Array(e);++rarguments.length;t=P(t,e,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(r=n[++o]);++oarguments.length;if(typeof u!="number")var i=Rt(n),u=i.length;return t=P(t,e,4),O(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=!1,n[a]):t(r,n[a],a,f)}),r}function q(n,t,r){var e; +t=P(t,r),r=-1;var u=n?n.length:0;if(typeof u=="number")for(;++rT(e,o)&&u.push(o)}return u}function D(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&null!=t){var o=-1;for(t=P(t,r);++or?Et(0,u+r):r||0)-1;else if(r)return e=I(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])T(a,f))&&(r&&a.push(f),i.push(e))}return i}function C(n,t){return qt.fastBind||jt&&2"']/g,Z=/['\n\r\t\u2028\u2029\\]/g,nt="[object Arguments]",tt="[object Array]",rt="[object Boolean]",et="[object Date]",ut="[object Number]",ot="[object Object]",it="[object RegExp]",at="[object String]",ft={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},ct={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},lt=[],H={},pt=n._,st=RegExp("^"+(H.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),vt=Math.ceil,gt=n.clearTimeout,ht=lt.concat,yt=Math.floor,mt=H.hasOwnProperty,_t=lt.push,bt=n.setTimeout,dt=H.toString,jt=st.test(jt=dt.bind)&&jt,wt=st.test(wt=Array.isArray)&&wt,At=n.isFinite,xt=n.isNaN,Ot=st.test(Ot=Object.keys)&&Ot,Et=Math.max,St=Math.min,Nt=Math.random,Bt=lt.slice,H=st.test(n.attachEvent),kt=jt&&!/\n|true/.test(jt+H),qt={}; +(function(){var n={0:1,length:1};qt.argsObject=arguments.constructor==Object&&!(arguments instanceof Array),qt.fastBind=jt&&!kt,qt.spliceObjects=(lt.splice.call(n,0,1),!n[0])})(1),t.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},i.prototype=t.prototype,c(arguments)||(c=function(n){return n?mt.call(n,"callee"):!1});var Ft=wt||function(n){return dt.call(n)==tt},wt=function(n){var t,r=[];if(!n||!ft[typeof n])return r;for(t in n)mt.call(n,t)&&r.push(t); +return r},Rt=Ot?function(n){return m(n)?Ot(n):[]}:wt,Dt={"&":"&","<":"<",">":">",'"':""","'":"'"},Mt=v(Dt),Tt=function(n,t){var r;if(!n||!ft[typeof n])return n;for(r in n)if(t(n[r],r,n)===K)break;return n},$t=function(n,t){var r;if(!n||!ft[typeof n])return n;for(r in n)if(mt.call(n,r)&&t(n[r],r,n)===K)break;return n};y(/x/)&&(y=function(n){return typeof n=="function"&&"[object Function]"==dt.call(n)}),t.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 +}},t.bind=C,t.bindAll=function(n){for(var t=1T(o,i)){for(var a=r;--a;)if(0>T(t[a],i))continue n;o.push(i)}}return o},t.invert=v,t.invoke=function(n,t){var r=Bt.call(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0); +return O(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},t.keys=Rt,t.map=E,t.max=S,t.memoize=function(n,t){var r={};return function(){var e=L+(t?t.apply(this,arguments):arguments[0]);return mt.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},t.min=function(n,t,r){var e=1/0,u=e,o=-1,i=n?n.length:0;if(t||typeof i!="number")t=P(t,r),O(n,function(n,r,o){r=t(n,r,o),rT(t,e)&&(r[e]=n) +}),r},t.once=function(n){var t,r;return function(){return t?r:(t=!0,r=n.apply(this,arguments),n=null,r)}},t.pairs=function(n){for(var t=-1,r=Rt(n),e=r.length,u=Array(e);++tr?Et(0,e+r):St(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},t.mixin=V,t.noConflict=function(){return n._=pt,this},t.random=function(n,t){return null==n&&null==t&&(t=1),n=+n||0,null==t&&(t=n,n=0),n+yt(Nt()*((+t||0)-n+1))},t.reduce=B,t.reduceRight=k,t.result=function(n,t){var r=n?n[t]:null;return y(r)?n[t]():r},t.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Rt(n).length +},t.some=q,t.sortedIndex=I,t.template=function(n,r,e){n||(n=""),e=p({},e,t.templateSettings);var o=0,i="__p+='",a=e.variable;n.replace(RegExp((e.escape||X).source+"|"+(e.interpolate||X).source+"|"+(e.evaluate||X).source+"|$","g"),function(t,r,e,a,f){return i+=n.slice(o,f).replace(Z,u),r&&(i+="'+_['escape']("+r+")+'"),a&&(i+="';"+a+";__p+='"),e&&(i+="'+((__t=("+e+"))==null?'':__t)+'"),o=f+t.length,t}),i+="';\n",a||(a="obj",i="with("+a+"||{}){"+i+"}"),i="function("+a+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+i+"return __p}"; +try{var f=Function("_","return "+i)(t)}catch(c){throw c.source=i,c}return r?f(r):(f.source=i,f)},t.unescape=function(n){return null==n?"":(n+"").replace(Q,f)},t.uniqueId=function(n){var t=++J+"";return n?n+t:t},t.all=w,t.any=q,t.detect=x,t.foldl=B,t.foldr=k,t.include=j,t.inject=B,t.first=D,t.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;for(t=P(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,null==e||r)return n[u-1];return Bt.call(n,Et(0,u-e))}},t.take=D,t.head=D,t.chain=function(n){return n=new i(n),n.__chain__=!0,n +},t.VERSION="1.2.0",V(t),t.prototype.chain=function(){return this.__chain__=!0,this},t.prototype.value=function(){return this.__wrapped__},O("pop push reverse shift sort splice unshift".split(" "),function(n){var r=lt[n];t.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),!qt.spliceObjects&&0===n.length&&delete n[0],this}}),O(["concat","join","slice"],function(n){var r=lt[n];t.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new i(n),n.__chain__=!0),n +}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=t,define(function(){return t})):W&&!W.nodeType?G?(G.exports=t)._=t:W._=t:n._=t})(this); \ No newline at end of file diff --git a/doc/README.md b/doc/README.md index 89f57f6023..07cd2e4d34 100644 --- a/doc/README.md +++ b/doc/README.md @@ -214,7 +214,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3283 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3280 "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. @@ -238,7 +238,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3313 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3310 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -263,7 +263,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.findIndex(array [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3349 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3346 "View in source") [Ⓣ][1] This method is similar to `_.find`, except that it returns the index of the element that passes the callback check, instead of the element itself. @@ -291,7 +291,7 @@ _.findIndex(['apple', 'banana', 'beet'], function(food) { ### `_.first(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3419 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3416 "View in source") [Ⓣ][1] Gets the first element of the `array`. If a number `n` is passed, the first `n` elements of the `array` are returned. If a `callback` function is passed, elements at the beginning of the array are returned as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -351,7 +351,7 @@ _.first(food, { 'type': 'fruit' }); ### `_.flatten(array [, isShallow=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3481 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3478 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `isShallow` is truthy, `array` will only be flattened a single level. If `callback` is passed, each element of `array` is passed through a callback` before flattening. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -394,7 +394,7 @@ _.flatten(stooges, 'quotes'); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3534 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3531 "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. @@ -426,7 +426,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#L3608 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3605 "View in source") [Ⓣ][1] Gets all but the last element of `array`. If a number `n` is passed, the last `n` elements are excluded from the result. If a `callback` function is passed, elements at the end of the array are excluded from the result as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -483,7 +483,7 @@ _.initial(food, { 'type': 'vegetable' }); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3642 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3639 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -507,7 +507,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#L3734 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3731 "View in source") [Ⓣ][1] Gets the last element of the `array`. If a number `n` is passed, the last `n` elements of the `array` are returned. If a `callback` function is passed, elements at the end of the array are returned as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments;(value, index, array). @@ -564,7 +564,7 @@ _.last(food, { 'type': 'vegetable' }); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3775 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3772 "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. @@ -593,7 +593,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3816 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3813 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. @@ -631,7 +631,7 @@ _.range(0); ### `_.rest(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3895 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3892 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. If a number `n` is passed, the first `n` values are excluded from the result. If a `callback` function is passed, elements at the beginning of the array are excluded from the result as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -691,7 +691,7 @@ _.rest(food, { 'type': 'fruit' }); ### `_.sortedIndex(array, value [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3959 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3956 "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)*. @@ -740,7 +740,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3991 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3988 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -764,7 +764,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#L4041 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4038 "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)*. @@ -811,7 +811,7 @@ _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); ### `_.unzip(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4099 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4096 "View in source") [Ⓣ][1] The inverse of `_.zip`, this method splits groups of elements into arrays composed of elements from each group at their corresponding indexes. @@ -835,7 +835,7 @@ _.unzip([['moe', 30, true], ['larry', 40, false]]); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4131 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4128 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -860,7 +860,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4151 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4148 "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. @@ -884,7 +884,7 @@ _.zip(['moe', 'larry'], [30, 40], [true, false]); ### `_.zipObject(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4180 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4177 "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`. @@ -972,7 +972,7 @@ _.isArray(squares.value()); ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5235 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5241 "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. @@ -1002,7 +1002,7 @@ _([1, 2, 3, 4]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5252 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5258 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -1023,7 +1023,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5269 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5275 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -1054,7 +1054,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2272 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2269 "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. @@ -1082,7 +1082,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2314 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2311 "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. @@ -1120,7 +1120,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2368 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2365 "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)*. @@ -1156,7 +1156,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2420 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2417 "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)*. @@ -1202,7 +1202,7 @@ _.every(stooges, { 'age': 50 }); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2481 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2478 "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)*. @@ -1248,7 +1248,7 @@ _.filter(food, { 'type': 'fruit' }); ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2548 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2545 "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)*. @@ -1297,7 +1297,7 @@ _.find(food, 'organic'); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2595 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2592 "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`. @@ -1329,7 +1329,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2645 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2642 "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)*. @@ -1366,7 +1366,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2678 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2675 "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`. @@ -1395,7 +1395,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2730 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2727 "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)*. @@ -1440,7 +1440,7 @@ _.map(stooges, 'name'); ### `_.max(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2787 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2784 "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)*. @@ -1482,7 +1482,7 @@ _.max(stooges, 'age'); ### `_.min(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2856 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2853 "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)*. @@ -1524,7 +1524,7 @@ _.min(stooges, 'age'); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2906 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2903 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1554,7 +1554,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2938 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2935 "View in source") [Ⓣ][1] Reduces a `collection` to a value which is the accumulated result of running each element in the `collection` through the `callback`, where each successive `callback` execution consumes the return value of the previous execution. If `accumulator` is not 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)*. @@ -1592,7 +1592,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#L2981 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2978 "View in source") [Ⓣ][1] This method is similar to `_.reduce`, except that it iterates over a `collection` from right to left. @@ -1623,7 +1623,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#L3041 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3038 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1666,7 +1666,7 @@ _.reject(food, { 'type': 'fruit' }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3062 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3059 "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. @@ -1690,7 +1690,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3095 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3092 "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. @@ -1720,7 +1720,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3142 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3139 "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)*. @@ -1766,7 +1766,7 @@ _.some(food, { 'type': 'meat' }); ### `_.sortBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3198 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3195 "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)*. @@ -1803,7 +1803,7 @@ _.sortBy(['banana', 'strawberry', 'apple'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3233 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3230 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1827,7 +1827,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3265 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3262 "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. @@ -1864,7 +1864,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4220 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4217 "View in source") [Ⓣ][1] If `n` is greater than `0`, a function is created that is restricted to executing `func`, with the `this` binding and arguments of the created function, only after it is called `n` times. If `n` is less than `1`, `func` is executed immediately, without a `this` binding or additional arguments, and its result is returned. @@ -1892,7 +1892,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4253 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4250 "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. @@ -1923,7 +1923,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4284 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4281 "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. @@ -1954,7 +1954,7 @@ jQuery('#docs').on('click', view.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4330 "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 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. @@ -1995,7 +1995,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4353 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4350 "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. @@ -2022,7 +2022,7 @@ welcome('moe'); ### `_.createCallback([func=identity, thisArg, argCount=3])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4412 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4409 "View in source") [Ⓣ][1] Produces a callback bound to an optional `thisArg`. If `func` is a property name, the created callback will return the property value for a given element. If `func` is an object, the created callback will return `true` for elements that contain the equivalent object properties, otherwise it will return `false`. @@ -2076,7 +2076,7 @@ _.toLookup(stooges, 'name'); ### `_.debounce(func, wait, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4483 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4485 "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 an `options` object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -2094,6 +2094,11 @@ Note: If `leading` and `trailing` options are `true`, `func` will be called on t ```js var lazyLayout = _.debounce(calculateLayout, 300); jQuery(window).on('resize', lazyLayout); + +jQuery('.postbox').on('click', _.debounce(sendMail, 200, { + 'leading': true, + 'trailing': false +}); ``` * * * @@ -2104,7 +2109,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4534 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4536 "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. @@ -2129,7 +2134,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4560 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4562 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -2156,7 +2161,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4584 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4586 "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. @@ -2182,7 +2187,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4611 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4613 "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. @@ -2208,7 +2213,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4646 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4648 "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. @@ -2235,7 +2240,7 @@ hi('moe'); ### `_.partialRight(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4677 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4679 "View in source") [Ⓣ][1] This method is similar to `_.partial`, except that `partial` arguments are appended to those passed to the new function. @@ -2272,7 +2277,7 @@ options.imports ### `_.throttle(func, wait, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4706 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4712 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. Pass an `options` object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -2290,6 +2295,10 @@ Note: If `leading` and `trailing` options are `true`, `func` will be called on t ```js var throttled = _.throttle(updatePosition, 100); jQuery(window).on('scroll', throttled); + +jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { + 'trailing': false +})); ``` * * * @@ -2300,7 +2309,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4771 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4777 "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. @@ -2336,7 +2345,7 @@ hello(); ### `_.assign(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1054 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1074 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the destination object. Subsequent sources will overwrite property assignments of previous sources. If a `callback` 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)*. @@ -2374,7 +2383,7 @@ defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.clone(value [, deep=false, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1109 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1129 "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)*. @@ -2421,7 +2430,7 @@ clone.childNodes.length; ### `_.cloneDeep(value [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1234 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1254 "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 `undefined`, cloning will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. @@ -2467,7 +2476,7 @@ clone.node == view.node; ### `_.defaults(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1258 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1278 "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. @@ -2493,7 +2502,7 @@ _.defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.findKey(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1281 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1301 "View in source") [Ⓣ][1] This method is similar to `_.find`, except that it returns the key of the element that passes the callback check, instead of the element itself. @@ -2521,7 +2530,7 @@ _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1322 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1342 "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`. @@ -2557,7 +2566,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1347 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1367 "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`. @@ -2585,7 +2594,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1364 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1384 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2612,7 +2621,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1389 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1409 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2637,7 +2646,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1406 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1426 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2688,7 +2697,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1435 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L962 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2715,7 +2724,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1455 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1452 "View in source") [Ⓣ][1] Checks if `value` is a boolean value. @@ -2739,7 +2748,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1472 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1469 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2763,7 +2772,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1489 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1486 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2787,7 +2796,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1514 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1511 "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". @@ -2817,7 +2826,7 @@ _.isEmpty(''); ### `_.isEqual(a, b [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1573 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1570 "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)*. @@ -2862,7 +2871,7 @@ _.isEqual(words, otherWords, function(a, b) { ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1754 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1751 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2900,7 +2909,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1771 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1768 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2924,7 +2933,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1834 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1831 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -2959,7 +2968,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1856 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1853 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2986,7 +2995,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1873 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1870 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -3010,7 +3019,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1801 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1798 "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('')`)* @@ -3040,7 +3049,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1901 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1898 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -3075,7 +3084,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1926 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1923 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -3099,7 +3108,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1943 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1940 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -3123,7 +3132,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1960 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1957 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -3147,7 +3156,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L976 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L996 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -3171,7 +3180,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2019 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2016 "View in source") [Ⓣ][1] Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the destination object. Subsequent sources will overwrite property assignments of previous sources. If a `callback` 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)*. @@ -3227,7 +3236,7 @@ _.merge(food, otherFood, function(a, b) { ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2128 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2125 "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)*. @@ -3258,7 +3267,7 @@ _.omit({ 'name': 'moe', 'age': 40 }, function(value) { ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2162 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2159 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -3282,7 +3291,7 @@ _.pairs({ 'moe': 30, 'larry': 40 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2200 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2197 "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)*. @@ -3313,7 +3322,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2237 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2234 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -3344,7 +3353,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4795 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4801 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -3368,7 +3377,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4813 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4819 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -3393,7 +3402,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4839 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4845 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -3423,7 +3432,7 @@ _('moe').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4868 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4874 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -3443,7 +3452,7 @@ var lodash = _.noConflict(); ### `_.parseInt(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4889 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4895 "View in source") [Ⓣ][1] Converts the given `value` into an integer of the specified `radix`. @@ -3469,7 +3478,7 @@ _.parseInt('08'); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4912 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4918 "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. @@ -3497,7 +3506,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4951 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4957 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function, it will be invoked with the `this` binding of `object` and its result returned, else the property value is returned. If `object` is falsey, then `undefined` is returned. @@ -3550,7 +3559,7 @@ Create a new `lodash` function using the given `context` object. ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5035 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5041 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -3632,7 +3641,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5160 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5166 "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)*. @@ -3664,7 +3673,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5187 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5193 "View in source") [Ⓣ][1] The inverse of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3688,7 +3697,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5207 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5213 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3741,7 +3750,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5444 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5450 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index 9bfcb5ce39..3c32e0c142 100644 --- a/lodash.js +++ b/lodash.js @@ -4476,6 +4476,11 @@ * * var lazyLayout = _.debounce(calculateLayout, 300); * jQuery(window).on('resize', lazyLayout); + * + * jQuery('.postbox').on('click', _.debounce(sendMail, 200, { + * 'leading': true, + * 'trailing': false + * }); */ function debounce(func, wait, options) { var args, @@ -4699,6 +4704,10 @@ * * var throttled = _.throttle(updatePosition, 100); * jQuery(window).on('scroll', throttled); + * + * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { + * 'trailing': false + * })); */ function throttle(func, wait, options) { var args, From 4a19d90d4865cbef9829cbc8510eea25f1022537 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 19 Apr 2013 01:03:09 -0700 Subject: [PATCH 10/38] Add `_.isObject` to the isType benchmark. Former-commit-id: 4e2a61fab31b506bac1d5ce7ad47f7bb2d9e11b6 --- perf/perf.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/perf/perf.js b/perf/perf.js index 37c3edcf38..8c187e0955 100644 --- a/perf/perf.js +++ b/perf/perf.js @@ -1199,7 +1199,7 @@ /*--------------------------------------------------------------------------*/ suites.push( - Benchmark.Suite('`_.isArguments`, `_.isDate`, `_.isFunction`, `_.isNumber`, `_.isRegExp`') + Benchmark.Suite('`_.isArguments`, `_.isDate`, `_.isFunction`, `_.isNumber`, `_.isObject`, `_.isRegExp`') .add(buildName, '\ lodash.isArguments(arguments);\ lodash.isArguments(object);\ @@ -1209,6 +1209,8 @@ lodash.isFunction(object);\ lodash.isNumber(1);\ lodash.isNumber(object);\ + lodash.isObject(object);\ + lodash.isObject(1);\ lodash.isRegExp(regexp);\ lodash.isRegExp(object);' ) @@ -1221,6 +1223,8 @@ _.isFunction(object);\ _.isNumber(1);\ _.isNumber(object);\ + _.isObject(object);\ + _.isObject(1);\ _.isRegExp(regexp);\ _.isRegExp(object);' ) From 0b6993bb7c9a993aaf89bca09fa732d8c67115d0 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 19 Apr 2013 09:07:55 -0700 Subject: [PATCH 11/38] Fix `_.debounce` doc typo. Former-commit-id: e2659ca38818d15a4080aa8dd605fed99a9eaa43 --- dist/lodash.compat.js | 4 ++-- dist/lodash.js | 4 ++-- dist/lodash.underscore.js | 4 ++-- doc/README.md | 4 ++-- lodash.js | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 551fbb2b59..9c5368f522 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -4450,7 +4450,7 @@ * function will return the result of the last `func` call. * * Note: If `leading` and `trailing` options are `true`, `func` will be called - * on the trailing edge of the timeout only if the the throttled function is + * on the trailing edge of the timeout only if the the debounced function is * invoked more than once during the `wait` timeout. * * @static @@ -4467,7 +4467,7 @@ * var lazyLayout = _.debounce(calculateLayout, 300); * jQuery(window).on('resize', lazyLayout); * - * jQuery('.postbox').on('click', _.debounce(sendMail, 200, { + * jQuery('#postbox').on('click', _.debounce(sendMail, 200, { * 'leading': true, * 'trailing': false * }); diff --git a/dist/lodash.js b/dist/lodash.js index c7557a2d67..707ace4ac1 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -4190,7 +4190,7 @@ * function will return the result of the last `func` call. * * Note: If `leading` and `trailing` options are `true`, `func` will be called - * on the trailing edge of the timeout only if the the throttled function is + * on the trailing edge of the timeout only if the the debounced function is * invoked more than once during the `wait` timeout. * * @static @@ -4207,7 +4207,7 @@ * var lazyLayout = _.debounce(calculateLayout, 300); * jQuery(window).on('resize', lazyLayout); * - * jQuery('.postbox').on('click', _.debounce(sendMail, 200, { + * jQuery('#postbox').on('click', _.debounce(sendMail, 200, { * 'leading': true, * 'trailing': false * }); diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index 5797d42ab3..1e3d0d0961 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -3469,7 +3469,7 @@ * function will return the result of the last `func` call. * * Note: If `leading` and `trailing` options are `true`, `func` will be called - * on the trailing edge of the timeout only if the the throttled function is + * on the trailing edge of the timeout only if the the debounced function is * invoked more than once during the `wait` timeout. * * @static @@ -3486,7 +3486,7 @@ * var lazyLayout = _.debounce(calculateLayout, 300); * jQuery(window).on('resize', lazyLayout); * - * jQuery('.postbox').on('click', _.debounce(sendMail, 200, { + * jQuery('#postbox').on('click', _.debounce(sendMail, 200, { * 'leading': true, * 'trailing': false * }); diff --git a/doc/README.md b/doc/README.md index 07cd2e4d34..4d12bb57a7 100644 --- a/doc/README.md +++ b/doc/README.md @@ -2080,7 +2080,7 @@ _.toLookup(stooges, 'name'); Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass an `options` object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. -Note: If `leading` and `trailing` options are `true`, `func` will be called on the trailing edge of the timeout only if the the throttled function is invoked more than once during the `wait` timeout. +Note: If `leading` and `trailing` options are `true`, `func` will be called on the trailing edge of the timeout only if the the debounced function is invoked more than once during the `wait` timeout. #### Arguments 1. `func` *(Function)*: The function to debounce. @@ -2095,7 +2095,7 @@ Note: If `leading` and `trailing` options are `true`, `func` will be called on t var lazyLayout = _.debounce(calculateLayout, 300); jQuery(window).on('resize', lazyLayout); -jQuery('.postbox').on('click', _.debounce(sendMail, 200, { +jQuery('#postbox').on('click', _.debounce(sendMail, 200, { 'leading': true, 'trailing': false }); diff --git a/lodash.js b/lodash.js index 3c32e0c142..8308b86c73 100644 --- a/lodash.js +++ b/lodash.js @@ -4460,7 +4460,7 @@ * function will return the result of the last `func` call. * * Note: If `leading` and `trailing` options are `true`, `func` will be called - * on the trailing edge of the timeout only if the the throttled function is + * on the trailing edge of the timeout only if the the debounced function is * invoked more than once during the `wait` timeout. * * @static @@ -4477,7 +4477,7 @@ * var lazyLayout = _.debounce(calculateLayout, 300); * jQuery(window).on('resize', lazyLayout); * - * jQuery('.postbox').on('click', _.debounce(sendMail, 200, { + * jQuery('#postbox').on('click', _.debounce(sendMail, 200, { * 'leading': true, * 'trailing': false * }); From 0562228e9a1f1715f6534093466eb224930351e9 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 20 Apr 2013 19:40:48 -0700 Subject: [PATCH 12/38] Ensure the `modern` build version of `_.isPlainObject` doesn't error when passed an object created via `Object.create`. [closes #248] Former-commit-id: d24641ed2562925fbbd2b64653e8e93ab1aa02bc --- build.js | 2 +- dist/lodash.js | 2 +- dist/lodash.min.js | 54 ++++++++++++++++++++-------------------- test/test.js | 62 ++++++++++++++++++++++++++++------------------ 4 files changed, 67 insertions(+), 53 deletions(-) diff --git a/build.js b/build.js index 458a82fd92..b66559f634 100755 --- a/build.js +++ b/build.js @@ -1176,7 +1176,7 @@ // remove `support.nodeClass` from `shimIsPlainObject` source = source.replace(matchFunction(source, 'shimIsPlainObject'), function(match) { - return match.replace(/ *&& *\(support\.nodeClass[\s\S]+?\)\)/, ''); + return match.replace(/\(support\.nodeClass[\s\S]+?\)\)/, 'true'); }); // remove `support.nodeClass` from `_.clone` diff --git a/dist/lodash.js b/dist/lodash.js index 707ace4ac1..c23f95e48a 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -545,7 +545,7 @@ // check that the constructor is `Object` (i.e. `Object instanceof Object`) var ctor = value.constructor; - if (isFunction(ctor) ? ctor instanceof ctor : (support.nodeClass || !isNode(value))) { + if (isFunction(ctor) ? ctor instanceof ctor : true) { // In most environments an object's own properties are iterated before // its inherited properties. If the last iterated property is an object's // own property then there are no inherited enumerable properties. diff --git a/dist/lodash.min.js b/dist/lodash.min.js index c931c15bc4..727945e9a8 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -7,38 +7,38 @@ ;(function(n){function t(o){function f(n){if(!n||re.call(n)!=S)return a;var t=n.valueOf,e=typeof t=="function"&&(e=Yt(t))&&Yt(e);return e?n==e||Yt(n)==e:X(n)}function q(n,t,e){if(!n||!F[typeof n])return n;t=t&&typeof e=="undefined"?t:M.createCallback(t,e);for(var r=-1,u=F[typeof n]?me(n):[],o=u.length;++r=s;if(e)for(var r={},u=-1;++ut||typeof n=="undefined")return 1;if(ne?0:e);++re?ce(0,u+e):e)||0,typeof u=="number"?o=-1<(it(n)?n.indexOf(t,e):jt(n,t,e)):q(n,function(n){return++ru&&(u=o)}}else t=!t&&it(n)?V:M.createCallback(t,e),gt(n,function(n,e,a){e=t(n,e,a),e>r&&(r=e,u=n)});return u}function mt(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Ft(r);++earguments.length;t=M.createCallback(t,r,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(e=n[++o]);++oarguments.length;if(typeof u!="number")var i=me(n),u=i.length;return t=M.createCallback(t,r,4),gt(n,function(r,f,c){f=i?i[--u]:--u,e=o?(o=a,n[f]):t(e,n[f],f,c)}),e}function _t(n,t,e){var r;t=M.createCallback(t,e),e=-1;var u=n?n.length:0; -if(typeof u=="number")for(;++ee?ce(0,u+e):e||0)-1;else if(e)return r=Ot(n,t),n[r]===t?r:-1;for(;++r>>1,e(n[r])=s;if(l)var v={};for(e!=u&&(c=[],e=M.createCallback(e,r));++ojt(c,g))&&((e||l)&&c.push(g),f.push(r))}return f}function Et(n,t){for(var e=-1,r=n?n.length:0,u={};++e/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:d,variable:"",imports:{_:M}},Q.prototype=M.prototype;var he=ae,me=fe?function(n){return at(n)?fe(n):[]}:K,be={"&":"&","<":"<",">":">",'"':""","'":"'"},de=et(be);return Dt&&i&&typeof te=="function"&&(St=It(te,o)),Rt=8==pe("08")?pe:function(n,t){return pe(it(n)?n.replace(_,""):n,t||0)},M.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 -}},M.assign=P,M.at=function(n){for(var t=-1,e=Wt.apply(Vt,ve.call(arguments,1)),r=e.length,u=Ft(r);++tt||typeof n=="undefined")return 1;if(ne?0:e);++re?ce(0,u+e):e)||0,typeof u=="number"?o=-1<(it(n)?n.indexOf(t,e):Ct(n,t,e)):q(n,function(n){return++ru&&(u=o) +}}else t=!t&&it(n)?V:M.createCallback(t,e),gt(n,function(n,e,a){e=t(n,e,a),e>r&&(r=e,u=n)});return u}function mt(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Ft(r);++earguments.length;t=M.createCallback(t,r,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(e=n[++o]);++oarguments.length; +if(typeof u!="number")var i=me(n),u=i.length;return t=M.createCallback(t,r,4),gt(n,function(r,f,c){f=i?i[--u]:--u,e=o?(o=a,n[f]):t(e,n[f],f,c)}),e}function _t(n,t,e){var r;t=M.createCallback(t,e),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++ee?ce(0,u+e):e||0)-1;else if(e)return r=Ot(n,t),n[r]===t?r:-1;for(;++r>>1,e(n[r])=s;if(l)var v={};for(e!=u&&(c=[],e=M.createCallback(e,r));++oCt(c,g))&&((e||l)&&c.push(g),f.push(r))}return f}function It(n,t){for(var e=-1,r=n?n.length:0,u={};++e/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:d,variable:"",imports:{_:M}},Q.prototype=M.prototype;var he=ae,me=fe?function(n){return at(n)?fe(n):[]}:K,be={"&":"&","<":"<",">":">",'"':""","'":"'"},de=et(be);return Dt&&i&&typeof te=="function"&&(St=Nt(te,o)),Rt=8==pe("08")?pe:function(n,t){return pe(it(n)?n.replace(_,""):n,t||0)},M.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 +}},M.assign=P,M.at=function(n){for(var t=-1,e=Wt.apply(Vt,ve.call(arguments,1)),r=e.length,u=Ft(r);++t=s,i=[],f=i;n:for(;++ujt(f,c)){o&&f.push(c); +}:function(e,r,u){return n.call(t,e,r,u)}:n},M.debounce=function(n,t,e){function o(){f=p=u,s&&(c=n.apply(l,i))}var i,f,c,l,p,s=r;if(e===r)var v=r,s=a;else e&&F[typeof e]&&(v=e.leading,s="trailing"in e?e.trailing:s);return function(){return i=arguments,l=this,Qt(p),!f&&v?(f=r,c=n.apply(l,i)):p=ee(o,t),c}},M.defaults=z,M.defer=St,M.delay=function(n,t){var r=ve.call(arguments,2);return ee(function(){n.apply(e,r)},t)},M.difference=kt,M.filter=st,M.flatten=jt,M.forEach=gt,M.forIn=D,M.forOwn=q,M.functions=tt,M.groupBy=function(n,t,e){var r={}; +return t=M.createCallback(t,e),gt(n,function(n,e,u){e=Mt(t(n,e,u)),(Zt.call(r,e)?r[e]:r[e]=[]).push(n)}),r},M.initial=function(n,t,e){if(!n)return[];var r=0,a=n.length;if(typeof t!="number"&&t!=u){var o=a;for(t=M.createCallback(t,e);o--&&t(n[o],o,n);)r++}else r=t==u||e?1:t||r;return Y(n,0,le(ce(0,a-r),a))},M.intersection=function(n){var t=arguments,e=t.length,r={0:{}},u=-1,a=n?n.length:0,o=a>=s,i=[],f=i;n:for(;++uCt(f,c)){o&&f.push(c); for(var v=e;--v;)if(!(r[v]||(r[v]=U(t[v])))(c))continue n;i.push(c)}}return i},M.invert=et,M.invoke=function(n,t){var e=ve.call(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Ft(typeof a=="number"?a:0);return gt(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},M.keys=me,M.map=yt,M.max=ht,M.memoize=function(n,t){var e={};return function(){var r=p+(t?t.apply(this,arguments):arguments[0]);return Zt.call(e,r)?e[r]:e[r]=n.apply(this,arguments)}},M.merge=ft,M.min=function(n,t,e){var r=1/0,u=r; -if(!t&&he(n)){e=-1;for(var a=n.length;++ejt(a,e))&&(u[e]=n)}),u},M.once=function(n){var t,e;return function(){return t?e:(t=r,e=n.apply(this,arguments),n=u,e)}},M.pairs=function(n){for(var t=-1,e=me(n),r=e.length,u=Ft(r);++tCt(a,e))&&(u[e]=n)}),u},M.once=function(n){var t,e;return function(){return t?e:(t=r,e=n.apply(this,arguments),n=u,e)}},M.pairs=function(n){for(var t=-1,e=me(n),r=e.length,u=Ft(r);++te?ce(0,r+e):le(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},M.mixin=$t,M.noConflict=function(){return o._=Ht,this},M.parseInt=Rt,M.random=function(n,t){return n==u&&t==u&&(t=1),n=+n||0,t==u&&(t=n,n=0),n+Xt(se()*((+t||0)-n+1))},M.reduce=bt,M.reduceRight=dt,M.result=function(n,t){var r=n?n[t]:e;return ut(r)?n[t]():r},M.runInContext=t,M.size=function(n){var t=n?n.length:0; -return typeof t=="number"?t:me(n).length},M.some=_t,M.sortedIndex=Ot,M.template=function(n,t,u){var a=M.templateSettings;n||(n=""),u=z({},u,a);var o,i=z({},u.imports,a.imports),a=me(i),i=ct(i),f=0,c=u.interpolate||k,l="__p+='",c=Kt((u.escape||k).source+"|"+c.source+"|"+(c===d?m:k).source+"|"+(u.evaluate||k).source+"|$","g");n.replace(c,function(t,e,u,a,i,c){return u||(u=a),l+=n.slice(f,c).replace(C,J),e&&(l+="'+__e("+e+")+'"),i&&(o=r,l+="';"+i+";__p+='"),u&&(l+="'+((__t=("+u+"))==null?'':__t)+'"),f=c+t.length,t +return typeof t=="number"?t:me(n).length},M.some=_t,M.sortedIndex=Ot,M.template=function(n,t,u){var a=M.templateSettings;n||(n=""),u=z({},u,a);var o,i=z({},u.imports,a.imports),a=me(i),i=ct(i),f=0,c=u.interpolate||k,l="__p+='",c=Kt((u.escape||k).source+"|"+c.source+"|"+(c===d?m:k).source+"|"+(u.evaluate||k).source+"|$","g");n.replace(c,function(t,e,u,a,i,c){return u||(u=a),l+=n.slice(f,c).replace(j,J),e&&(l+="'+__e("+e+")+'"),i&&(o=r,l+="';"+i+";__p+='"),u&&(l+="'+((__t=("+u+"))==null?'':__t)+'"),f=c+t.length,t }),l+="';\n",c=u=u.variable,c||(u="obj",l="with("+u+"){"+l+"}"),l=(o?l.replace(v,""):l).replace(g,"$1").replace(y,"$1;"),l="function("+u+"){"+(c?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}";try{var p=qt(a,"return "+l).apply(e,i)}catch(s){throw s.source=l,s}return t?p(t):(p.source=l,p)},M.unescape=function(n){return n==u?"":Mt(n).replace(h,Z)},M.uniqueId=function(n){var t=++c;return Mt(n==u?"":n)+t },M.all=pt,M.any=_t,M.detect=vt,M.foldl=bt,M.foldr=dt,M.include=lt,M.inject=bt,q(M,function(n,t){M.prototype[t]||(M.prototype[t]=function(){var t=[this.__wrapped__];return ne.apply(t,arguments),n.apply(M,t)})}),M.first=wt,M.last=function(n,t,e){if(n){var r=0,a=n.length;if(typeof t!="number"&&t!=u){var o=a;for(t=M.createCallback(t,e);o--&&t(n[o],o,n);)r++}else if(r=t,r==u||e)return n[a-1];return Y(n,ce(0,a-r))}},M.take=wt,M.head=wt,q(M,function(n,t){M.prototype[t]||(M.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e); return t==u||e&&typeof t!="function"?r:new Q(r)})}),M.VERSION="1.2.0",M.prototype.toString=function(){return Mt(this.__wrapped__)},M.prototype.value=Bt,M.prototype.valueOf=Bt,gt(["join","pop","shift"],function(n){var t=Vt[n];M.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),gt(["push","reverse","sort","unshift"],function(n){var t=Vt[n];M.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),gt(["concat","slice","splice"],function(n){var t=Vt[n];M.prototype[n]=function(){return new Q(t.apply(this.__wrapped__,arguments)) -}}),M}var e,r=!0,u=null,a=!1,o=typeof exports=="object"&&exports,i=typeof module=="object"&&module&&module.exports==o&&module,f=typeof global=="object"&&global;(f.global===f||f.window===f)&&(n=f);var c=0,l={},p=+new Date+"",s=200,v=/\b__p\+='';/g,g=/\b(__p\+=)''\+/g,y=/(__e\(.*?\)|\b__t\))\+'';/g,h=/&(?:amp|lt|gt|quot|#39);/g,m=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,b=/\w*$/,d=/<%=([\s\S]+?)%>/g,_=/^0+(?=.$)/,k=/($^)/,w=/[&<>"']/g,C=/['\n\r\t\u2028\u2029\\]/g,j="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),x="[object Arguments]",O="[object Array]",N="[object Boolean]",E="[object Date]",I="[object Number]",S="[object Object]",A="[object RegExp]",$="[object String]",B={"[object Function]":a}; -B[x]=B[O]=B[N]=B[E]=B[I]=B[S]=B[A]=B[$]=r;var F={"boolean":a,"function":r,object:r,number:a,string:a,undefined:a},R={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},T=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=T,define(function(){return T})):o&&!o.nodeType?i?(i.exports=T)._=T:o._=T:n._=T})(this); \ No newline at end of file +}}),M}var e,r=!0,u=null,a=!1,o=typeof exports=="object"&&exports,i=typeof module=="object"&&module&&module.exports==o&&module,f=typeof global=="object"&&global;(f.global===f||f.window===f)&&(n=f);var c=0,l={},p=+new Date+"",s=200,v=/\b__p\+='';/g,g=/\b(__p\+=)''\+/g,y=/(__e\(.*?\)|\b__t\))\+'';/g,h=/&(?:amp|lt|gt|quot|#39);/g,m=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,b=/\w*$/,d=/<%=([\s\S]+?)%>/g,_=/^0+(?=.$)/,k=/($^)/,w=/[&<>"']/g,j=/['\n\r\t\u2028\u2029\\]/g,C="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),x="[object Arguments]",O="[object Array]",E="[object Boolean]",I="[object Date]",N="[object Number]",S="[object Object]",A="[object RegExp]",$="[object String]",B={"[object Function]":a}; +B[x]=B[O]=B[E]=B[I]=B[N]=B[S]=B[A]=B[$]=r;var F={"boolean":a,"function":r,object:r,number:a,string:a,undefined:a},R={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},T=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=T,define(function(){return T})):o&&!o.nodeType?i?(i.exports=T)._=T:o._=T:n._=T})(this); \ No newline at end of file diff --git a/test/test.js b/test/test.js index 683923a981..9f1fe16d47 100644 --- a/test/test.js +++ b/test/test.js @@ -1,17 +1,28 @@ ;(function(window, undefined) { 'use strict'; + /** Method and object shortcuts */ + var document = window.document, + amd = window.define && define.amd, + body = document && document.body, + create = Object.create, + freeze = Object.freeze, + phantom = window.phantom, + process = window.process, + slice = Array.prototype.slice, + system = window.system; + /** Use a single "load" function */ var load = typeof require == 'function' ? require : window.load; /** The file path of the Lo-Dash file to test */ var filePath = (function() { var min = 0; - var result = window.phantom + var result = phantom ? phantom.args - : (window.system + : (system ? (min = 1, system.args) - : (window.process ? (min = 2, process.argv) : (window.arguments || [])) + : (process ? (min = 2, process.argv) : (window.arguments || [])) ); var last = result[result.length - 1]; @@ -60,9 +71,6 @@ undefined ]; - /** Shortcut used to make object properties immutable */ - var freeze = Object.freeze; - /** Used to set property descriptors */ var setDescriptor = (function() { try { @@ -73,9 +81,6 @@ return result; }()); - /** Shortcut used to convert array-like objects to arrays */ - var slice = Array.prototype.slice; - /** Used to check problem JScript properties (a.k.a. the [[DontEnum]] bug) */ var shadowedProps = [ 'constructor', @@ -109,14 +114,13 @@ // add object from iframe (function() { - if (!window.document || window.phantom) { + if (!document || phantom) { return; } - var body = document.body, - iframe = document.createElement('iframe'); - + var iframe = document.createElement('iframe'); iframe.frameBorder = iframe.height = iframe.width = 0; body.appendChild(iframe); + var idoc = (idoc = iframe.contentDocument || iframe.contentWindow).document || idoc; idoc.write("