Switch null use for clearing vars to undefined.

This commit is contained in:
jdalton
2015-06-07 13:16:51 -07:00
parent ba082b74a7
commit f8ec95d872

View File

@@ -1857,7 +1857,7 @@
if (isObject(prototype)) { if (isObject(prototype)) {
object.prototype = prototype; object.prototype = prototype;
var result = new object; var result = new object;
object.prototype = null; object.prototype = undefined;
} }
return result || {}; return result || {};
}; };
@@ -1899,7 +1899,7 @@
var index = -1, var index = -1,
indexOf = getIndexOf(), indexOf = getIndexOf(),
isCommon = indexOf == baseIndexOf, isCommon = indexOf == baseIndexOf,
cache = (isCommon && values.length >= LARGE_ARRAY_SIZE) ? createCache(values) : null, cache = (isCommon && values.length >= LARGE_ARRAY_SIZE) ? createCache(values) : undefined,
valuesLength = values.length; valuesLength = values.length;
if (cache) { if (cache) {
@@ -2462,7 +2462,7 @@
return object; return object;
} }
var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)), var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)),
props = isSrcArr ? null : keys(source); props = isSrcArr ? undefined : keys(source);
arrayEach(props || source, function(srcValue, key) { arrayEach(props || source, function(srcValue, key) {
if (props) { if (props) {
@@ -2775,7 +2775,7 @@
length = array.length, length = array.length,
isCommon = indexOf == baseIndexOf, isCommon = indexOf == baseIndexOf,
isLarge = isCommon && length >= LARGE_ARRAY_SIZE, isLarge = isCommon && length >= LARGE_ARRAY_SIZE,
seen = isLarge ? createCache() : null, seen = isLarge ? createCache() : undefined,
result = []; result = [];
if (seen) { if (seen) {
@@ -3288,9 +3288,9 @@
function createCurry(flag) { function createCurry(flag) {
function curryFunc(func, arity, guard) { function curryFunc(func, arity, guard) {
if (guard && isIterateeCall(func, arity, guard)) { if (guard && isIterateeCall(func, arity, guard)) {
arity = null; arity = undefined;
} }
var result = createWrapper(func, flag, null, null, null, null, null, arity); var result = createWrapper(func, flag, undefined, undefined, undefined, undefined, undefined, arity);
result.placeholder = curryFunc.placeholder; result.placeholder = curryFunc.placeholder;
return result; return result;
} }
@@ -3308,7 +3308,7 @@
function createExtremum(comparator, exValue) { function createExtremum(comparator, exValue) {
return function(collection, iteratee, thisArg) { return function(collection, iteratee, thisArg) {
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
iteratee = null; iteratee = undefined;
} }
iteratee = getCallback(iteratee, thisArg, 3); iteratee = getCallback(iteratee, thisArg, 3);
if (iteratee.length == 1) { if (iteratee.length == 1) {
@@ -3401,7 +3401,7 @@
func = funcs[index]; func = funcs[index];
var funcName = getFuncName(func), var funcName = getFuncName(func),
data = funcName == 'wrapper' ? getData(func) : null; data = funcName == 'wrapper' ? getData(func) : undefined;
if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) { if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) {
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
@@ -3521,7 +3521,7 @@
function createPartial(flag) { function createPartial(flag) {
var partialFunc = restParam(function(func, partials) { var partialFunc = restParam(function(func, partials) {
var holders = replaceHolders(partials, partialFunc.placeholder); var holders = replaceHolders(partials, partialFunc.placeholder);
return createWrapper(func, flag, null, partials, holders); return createWrapper(func, flag, undefined, partials, holders);
}); });
return partialFunc; return partialFunc;
} }
@@ -3567,7 +3567,7 @@
isCurry = bitmask & CURRY_FLAG, isCurry = bitmask & CURRY_FLAG,
isCurryBound = bitmask & CURRY_BOUND_FLAG, isCurryBound = bitmask & CURRY_BOUND_FLAG,
isCurryRight = bitmask & CURRY_RIGHT_FLAG, isCurryRight = bitmask & CURRY_RIGHT_FLAG,
Ctor = isBindKey ? null : createCtorWrapper(func); Ctor = isBindKey ? undefined : createCtorWrapper(func);
function wrapper() { function wrapper() {
// Avoid `arguments` object use disqualifying optimizations by // Avoid `arguments` object use disqualifying optimizations by
@@ -3591,12 +3591,12 @@
length -= argsHolders.length; length -= argsHolders.length;
if (length < arity) { if (length < arity) {
var newArgPos = argPos ? arrayCopy(argPos) : null, var newArgPos = argPos ? arrayCopy(argPos) : undefined,
newArity = nativeMax(arity - length, 0), newArity = nativeMax(arity - length, 0),
newsHolders = isCurry ? argsHolders : null, newsHolders = isCurry ? argsHolders : undefined,
newHoldersRight = isCurry ? null : argsHolders, newHoldersRight = isCurry ? undefined : argsHolders,
newPartials = isCurry ? args : null, newPartials = isCurry ? args : undefined,
newPartialsRight = isCurry ? null : args; newPartialsRight = isCurry ? undefined : args;
bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG); bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG);
bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG); bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG);
@@ -3739,16 +3739,16 @@
var length = partials ? partials.length : 0; var length = partials ? partials.length : 0;
if (!length) { if (!length) {
bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG); bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG);
partials = holders = null; partials = holders = undefined;
} }
length -= (holders ? holders.length : 0); length -= (holders ? holders.length : 0);
if (bitmask & PARTIAL_RIGHT_FLAG) { if (bitmask & PARTIAL_RIGHT_FLAG) {
var partialsRight = partials, var partialsRight = partials,
holdersRight = holders; holdersRight = holders;
partials = holders = null; partials = holders = undefined;
} }
var data = isBindKey ? null : getData(func), var data = isBindKey ? undefined : getData(func),
newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity]; newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
if (data) { if (data) {
@@ -5093,7 +5093,7 @@
while (othIndex--) { while (othIndex--) {
var value = arrays[othIndex] = isArrayLike(value = arrays[othIndex]) ? value : []; var value = arrays[othIndex] = isArrayLike(value = arrays[othIndex]) ? value : [];
caches[othIndex] = (isCommon && value.length >= 120) ? createCache(othIndex && value) : null; caches[othIndex] = (isCommon && value.length >= 120) ? createCache(othIndex && value) : undefined;
} }
var array = arrays[0], var array = arrays[0],
index = -1, index = -1,
@@ -5698,7 +5698,7 @@
} }
if (isSorted != null && typeof isSorted != 'boolean') { if (isSorted != null && typeof isSorted != 'boolean') {
thisArg = iteratee; thisArg = iteratee;
iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted; iteratee = isIterateeCall(array, isSorted, thisArg) ? undefined : isSorted;
isSorted = false; isSorted = false;
} }
var callback = getCallback(); var callback = getCallback();
@@ -6332,7 +6332,7 @@
function every(collection, predicate, thisArg) { function every(collection, predicate, thisArg) {
var func = isArray(collection) ? arrayEvery : baseEvery; var func = isArray(collection) ? arrayEvery : baseEvery;
if (thisArg && isIterateeCall(collection, predicate, thisArg)) { if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
predicate = null; predicate = undefined;
} }
if (typeof predicate != 'function' || thisArg !== undefined) { if (typeof predicate != 'function' || thisArg !== undefined) {
predicate = getCallback(predicate, thisArg, 3); predicate = getCallback(predicate, thisArg, 3);
@@ -6731,7 +6731,7 @@
result = isArrayLike(collection) ? Array(collection.length) : []; result = isArrayLike(collection) ? Array(collection.length) : [];
baseEach(collection, function(value) { baseEach(collection, function(value) {
var func = isFunc ? path : ((isProp && value != null) ? value[path] : null); var func = isFunc ? path : ((isProp && value != null) ? value[path] : undefined);
result[++index] = func ? func.apply(value, args) : invokePath(value, path, args); result[++index] = func ? func.apply(value, args) : invokePath(value, path, args);
}); });
return result; return result;
@@ -7131,7 +7131,7 @@
function some(collection, predicate, thisArg) { function some(collection, predicate, thisArg) {
var func = isArray(collection) ? arraySome : baseSome; var func = isArray(collection) ? arraySome : baseSome;
if (thisArg && isIterateeCall(collection, predicate, thisArg)) { if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
predicate = null; predicate = undefined;
} }
if (typeof predicate != 'function' || thisArg !== undefined) { if (typeof predicate != 'function' || thisArg !== undefined) {
predicate = getCallback(predicate, thisArg, 3); predicate = getCallback(predicate, thisArg, 3);
@@ -7192,7 +7192,7 @@
return []; return [];
} }
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
iteratee = null; iteratee = undefined;
} }
var index = -1; var index = -1;
iteratee = getCallback(iteratee, thisArg, 3); iteratee = getCallback(iteratee, thisArg, 3);
@@ -7288,7 +7288,7 @@
return []; return [];
} }
if (guard && isIterateeCall(iteratees, orders, guard)) { if (guard && isIterateeCall(iteratees, orders, guard)) {
orders = null; orders = undefined;
} }
if (!isArray(iteratees)) { if (!isArray(iteratees)) {
iteratees = iteratees == null ? [] : [iteratees]; iteratees = iteratees == null ? [] : [iteratees];
@@ -7413,10 +7413,10 @@
*/ */
function ary(func, n, guard) { function ary(func, n, guard) {
if (guard && isIterateeCall(func, n, guard)) { if (guard && isIterateeCall(func, n, guard)) {
n = null; n = undefined;
} }
n = (func && n == null) ? func.length : nativeMax(+n || 0, 0); n = (func && n == null) ? func.length : nativeMax(+n || 0, 0);
return createWrapper(func, ARY_FLAG, null, null, null, null, n); return createWrapper(func, ARY_FLAG, undefined, undefined, undefined, undefined, n);
} }
/** /**
@@ -7451,7 +7451,7 @@
result = func.apply(this, arguments); result = func.apply(this, arguments);
} }
if (n <= 1) { if (n <= 1) {
func = null; func = undefined;
} }
return result; return result;
}; };
@@ -7786,7 +7786,7 @@
lastCalled = now(); lastCalled = now();
result = func.apply(thisArg, args); result = func.apply(thisArg, args);
if (!timeoutId && !maxTimeoutId) { if (!timeoutId && !maxTimeoutId) {
args = thisArg = null; args = thisArg = undefined;
} }
} }
} else { } else {
@@ -7803,7 +7803,7 @@
lastCalled = now(); lastCalled = now();
result = func.apply(thisArg, args); result = func.apply(thisArg, args);
if (!timeoutId && !maxTimeoutId) { if (!timeoutId && !maxTimeoutId) {
args = thisArg = null; args = thisArg = undefined;
} }
} }
} }
@@ -7845,7 +7845,7 @@
result = func.apply(thisArg, args); result = func.apply(thisArg, args);
} }
if (isCalled && !timeoutId && !maxTimeoutId) { if (isCalled && !timeoutId && !maxTimeoutId) {
args = thisArg = null; args = thisArg = undefined;
} }
return result; return result;
} }
@@ -8199,7 +8199,7 @@
* // => [3, 6, 9] * // => [3, 6, 9]
*/ */
var rearg = restParam(function(func, indexes) { var rearg = restParam(function(func, indexes) {
return createWrapper(func, REARG_FLAG, null, null, null, baseFlatten(indexes)); return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes));
}); });
/** /**
@@ -8371,7 +8371,7 @@
*/ */
function wrap(value, wrapper) { function wrap(value, wrapper) {
wrapper = wrapper == null ? identity : wrapper; wrapper = wrapper == null ? identity : wrapper;
return createWrapper(wrapper, PARTIAL_FLAG, null, [value], []); return createWrapper(wrapper, PARTIAL_FLAG, undefined, [value], []);
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
@@ -9296,7 +9296,7 @@
function create(prototype, properties, guard) { function create(prototype, properties, guard) {
var result = baseCreate(prototype); var result = baseCreate(prototype);
if (guard && isIterateeCall(prototype, properties, guard)) { if (guard && isIterateeCall(prototype, properties, guard)) {
properties = null; properties = undefined;
} }
return properties ? baseAssign(result, properties) : result; return properties ? baseAssign(result, properties) : result;
} }
@@ -9653,7 +9653,7 @@
*/ */
function invert(object, multiValue, guard) { function invert(object, multiValue, guard) {
if (guard && isIterateeCall(object, multiValue, guard)) { if (guard && isIterateeCall(object, multiValue, guard)) {
multiValue = null; multiValue = undefined;
} }
var index = -1, var index = -1,
props = keys(object), props = keys(object),
@@ -9706,7 +9706,7 @@
* // => ['0', '1'] * // => ['0', '1']
*/ */
var keys = !nativeKeys ? shimKeys : function(object) { var keys = !nativeKeys ? shimKeys : function(object) {
var Ctor = object == null ? null : object.constructor; var Ctor = object == null ? undefined : object.constructor;
if ((typeof Ctor == 'function' && Ctor.prototype === object) || if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
(typeof object == 'function' ? lodash.support.enumPrototypes : isArrayLike(object))) { (typeof object == 'function' ? lodash.support.enumPrototypes : isArrayLike(object))) {
return shimKeys(object); return shimKeys(object);
@@ -10138,7 +10138,7 @@
if (isArr) { if (isArr) {
accumulator = isArray(object) ? new Ctor : []; accumulator = isArray(object) ? new Ctor : [];
} else { } else {
accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : null); accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined);
} }
} else { } else {
accumulator = {}; accumulator = {};
@@ -10279,7 +10279,7 @@
*/ */
function random(min, max, floating) { function random(min, max, floating) {
if (floating && isIterateeCall(min, max, floating)) { if (floating && isIterateeCall(min, max, floating)) {
max = floating = null; max = floating = undefined;
} }
var noMin = min == null, var noMin = min == null,
noMax = max == null; noMax = max == null;
@@ -10833,7 +10833,7 @@
var settings = lodash.templateSettings; var settings = lodash.templateSettings;
if (otherOptions && isIterateeCall(string, options, otherOptions)) { if (otherOptions && isIterateeCall(string, options, otherOptions)) {
options = otherOptions = null; options = otherOptions = undefined;
} }
string = baseToString(string); string = baseToString(string);
options = assignWith(baseAssign({}, otherOptions || options), settings, assignOwnDefaults); options = assignWith(baseAssign({}, otherOptions || options), settings, assignOwnDefaults);
@@ -11069,7 +11069,7 @@
*/ */
function trunc(string, options, guard) { function trunc(string, options, guard) {
if (guard && isIterateeCall(string, options, guard)) { if (guard && isIterateeCall(string, options, guard)) {
options = null; options = undefined;
} }
var length = DEFAULT_TRUNC_LENGTH, var length = DEFAULT_TRUNC_LENGTH,
omission = DEFAULT_TRUNC_OMISSION; omission = DEFAULT_TRUNC_OMISSION;
@@ -11164,7 +11164,7 @@
*/ */
function words(string, pattern, guard) { function words(string, pattern, guard) {
if (guard && isIterateeCall(string, pattern, guard)) { if (guard && isIterateeCall(string, pattern, guard)) {
pattern = null; pattern = undefined;
} }
string = baseToString(string); string = baseToString(string);
return string.match(pattern || reWords) || []; return string.match(pattern || reWords) || [];
@@ -11240,7 +11240,7 @@
*/ */
function callback(func, thisArg, guard) { function callback(func, thisArg, guard) {
if (guard && isIterateeCall(func, thisArg, guard)) { if (guard && isIterateeCall(func, thisArg, guard)) {
thisArg = null; thisArg = undefined;
} }
return isObjectLike(func) return isObjectLike(func)
? matches(func) ? matches(func)
@@ -11441,8 +11441,8 @@
function mixin(object, source, options) { function mixin(object, source, options) {
if (options == null) { if (options == null) {
var isObj = isObject(source), var isObj = isObject(source),
props = isObj ? keys(source) : null, props = isObj ? keys(source) : undefined,
methodNames = (props && props.length) ? baseFunctions(source, props) : null; methodNames = (props && props.length) ? baseFunctions(source, props) : undefined;
if (!(methodNames ? methodNames.length : isObj)) { if (!(methodNames ? methodNames.length : isObj)) {
methodNames = false; methodNames = false;
@@ -11611,7 +11611,7 @@
*/ */
function range(start, end, step) { function range(start, end, step) {
if (step && isIterateeCall(start, end, step)) { if (step && isIterateeCall(start, end, step)) {
end = step = null; end = step = undefined;
} }
start = +start || 0; start = +start || 0;
step = step == null ? 1 : (+step || 0); step = step == null ? 1 : (+step || 0);
@@ -11857,7 +11857,7 @@
*/ */
function sum(collection, iteratee, thisArg) { function sum(collection, iteratee, thisArg) {
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
iteratee = null; iteratee = undefined;
} }
var callback = getCallback(), var callback = getCallback(),
noIteratee = iteratee == null; noIteratee = iteratee == null;
@@ -12348,7 +12348,7 @@
} }
}); });
realNames[createHybridWrapper(null, BIND_KEY_FLAG).name] = [{ 'name': 'wrapper', 'func': null }]; realNames[createHybridWrapper(undefined, BIND_KEY_FLAG).name] = [{ 'name': 'wrapper', 'func': undefined }];
// Add functions to the lazy wrapper. // Add functions to the lazy wrapper.
LazyWrapper.prototype.clone = lazyClone; LazyWrapper.prototype.clone = lazyClone;