From 35bd7c55d0e123632b2ccb413e39282e76274411 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 4 Mar 2013 01:40:55 -0800 Subject: [PATCH] Move `lodash` instance check up in `lodash` function and tweak chaining benchmark. Former-commit-id: 799ae05e5180ee87bb2a5249be3e442ed0425ef7 --- build.js | 6 +++--- dist/lodash.compat.js | 8 ++++---- dist/lodash.compat.min.js | 2 +- dist/lodash.js | 8 ++++---- dist/lodash.min.js | 2 +- dist/lodash.underscore.js | 6 +++--- dist/lodash.underscore.min.js | 2 +- lodash.js | 8 ++++---- perf/perf.js | 6 +++--- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/build.js b/build.js index 6da9ad9ce..d19102040 100755 --- a/build.js +++ b/build.js @@ -2017,12 +2017,12 @@ // replace `lodash` source = replaceFunction(source, 'lodash', [ 'function lodash(value) {', - ' if (value instanceof lodash) {', - ' return value;', - ' }', ' if (!(this instanceof lodash)) {', ' return new lodash(value);', ' }', + ' if (value instanceof lodash) {', + ' return value;', + ' }', ' this.__wrapped__ = value;', '}' ].join('\n')); diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index e4130af88..d7e6aa17c 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -320,14 +320,14 @@ * @returns {Object} Returns a `lodash` instance. */ function lodash(value) { - // exit early if already wrapped, even if wrapped by a different `lodash` constructor - if (value && typeof value == 'object' && hasOwnProperty.call(value, '__wrapped__')) { - return value; - } // allow invoking `lodash` without the `new` operator if (!(this instanceof lodash)) { return new lodash(value); } + // exit early if already wrapped, even if wrapped by a different `lodash` constructor + if (value && typeof value == 'object' && hasOwnProperty.call(value, '__wrapped__')) { + return value; + } this.__wrapped__ = value; } diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index e6c25da21..5c7cb601e 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -4,7 +4,7 @@ * 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"&&Jt.call(n,"__wrapped__")?n:this instanceof a?(this.__wrapped__=n,void 0):new a(n)}function q(n,t,e){t||(t=0);var r=n.length,u=r-t>=(e||f);if(u){var a={};for(e=t-1;++et||typeof n=="undefined")return 1; +;(function(n){function t(r){function a(n){return this instanceof a?n&&typeof n=="object"&&Jt.call(n,"__wrapped__")?n:(this.__wrapped__=n,void 0):new a(n)}function q(n,t,e){t||(t=0);var r=n.length,u=r-t>=(e||f);if(u){var a={};for(e=t-1;++et||typeof n=="undefined")return 1; if(nu;u++)r+="i='"+t.k[u]+"';if(","constructor"==t.k[u]&&(r+="!(f&&f.prototype===m)&&"),r+="h.call(m,i)){"+t.h+"}"}return(t.b||t.i)&&(r+="}"),r+=t.c+";return u",e("h,j,k,l,o,r,p","return function("+n+"){"+r+"}")(Jt,G,Ie,et,a,A,ue)}function P(n){var t=Ce(a.prototype);return t.__wrapped__=n,t}function z(n){return"\\"+$[n]}function M(n){return Ae[n]}function K(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function L(){}function U(n,t,e){t||(t=0),typeof e=="undefined"&&(e=n?n.length:0); var r=-1;e=e-t||0;for(var u=Nt(0>e?0:e);++r=(e||f);if(u){var a={};for(e=t-1;++et||typeof n=="undefined")return 1; +;(function(n){function t(r){function a(n){return this instanceof a?n&&typeof n=="object"&&Mt.call(n,"__wrapped__")?n:(this.__wrapped__=n,void 0):new a(n)}function $(n,t,e){t||(t=0);var r=n.length,u=r-t>=(e||f);if(u){var a={};for(e=t-1;++et||typeof n=="undefined")return 1; if(ne?0:e);++rr||typeof n=="undefined")return 1;if(nr||typeof n=="undefined")return 1;if(nt?0:t);++e