Reduce the length of some lines.

This commit is contained in:
John-David Dalton
2016-02-14 19:14:17 -08:00
parent c006c28f55
commit cb96bf15b7

192
lodash.js
View File

@@ -334,10 +334,19 @@
freeParseInt = parseInt; freeParseInt = parseInt;
/** Detect free variable `exports`. */ /** Detect free variable `exports`. */
var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null; var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
? exports
: undefined;
/** Detect free variable `module`. */ /** Detect free variable `module`. */
var freeModule = (objectTypes[typeof module] && module && !module.nodeType) ? module : null; var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
? module
: undefined;
/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports = (freeModule && freeModule.exports === freeExports)
? freeExports
: undefined;
/** Detect free variable `global` from Node.js. */ /** Detect free variable `global` from Node.js. */
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global); var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
@@ -348,9 +357,6 @@
/** Detect free variable `window`. */ /** Detect free variable `window`. */
var freeWindow = checkGlobal(objectTypes[typeof window] && window); var freeWindow = checkGlobal(objectTypes[typeof window] && window);
/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null;
/** Detect `this` as the global object. */ /** Detect `this` as the global object. */
var thisGlobal = checkGlobal(objectTypes[typeof this] && this); var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
@@ -360,7 +366,9 @@
* The `this` value is used if it's the global object to avoid Greasemonkey's * The `this` value is used if it's the global object to avoid Greasemonkey's
* restricted `window` object, otherwise the `window` object is used. * restricted `window` object, otherwise the `window` object is used.
*/ */
var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')(); var root = freeGlobal ||
((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
freeSelf || thisGlobal || Function('return this')();
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
@@ -1645,7 +1653,8 @@
resIndex = 0, resIndex = 0,
takeCount = nativeMin(length, this.__takeCount__); takeCount = nativeMin(length, this.__takeCount__);
if (!isArr || arrLength < LARGE_ARRAY_SIZE || (arrLength == length && takeCount == length)) { if (!isArr || arrLength < LARGE_ARRAY_SIZE ||
(arrLength == length && takeCount == length)) {
return baseWrapperValue(array, this.__actions__); return baseWrapperValue(array, this.__actions__);
} }
var result = []; var result = [];
@@ -1769,7 +1778,11 @@
* @memberOf MapCache * @memberOf MapCache
*/ */
function mapClear() { function mapClear() {
this.__data__ = { 'hash': new Hash, 'map': Map ? new Map : [], 'string': new Hash }; this.__data__ = {
'hash': new Hash,
'map': Map ? new Map : [],
'string': new Hash
};
} }
/** /**
@@ -2735,11 +2748,17 @@
var value = array[index], var value = array[index],
computed = iteratee ? iteratee(value) : value; computed = iteratee ? iteratee(value) : value;
if (!(seen ? cacheHas(seen, computed) : includes(result, computed, comparator))) { if (!(seen
? cacheHas(seen, computed)
: includes(result, computed, comparator)
)) {
var othIndex = othLength; var othIndex = othLength;
while (--othIndex) { while (--othIndex) {
var cache = caches[othIndex]; var cache = caches[othIndex];
if (!(cache ? cacheHas(cache, computed) : includes(arrays[othIndex], computed, comparator))) { if (!(cache
? cacheHas(cache, computed)
: includes(arrays[othIndex], computed, comparator))
) {
continue outer; continue outer;
} }
} }
@@ -3062,7 +3081,10 @@
if (object === source) { if (object === source) {
return; return;
} }
var props = (isArray(source) || isTypedArray(source)) ? undefined : keysIn(source); var props = (isArray(source) || isTypedArray(source))
? undefined
: keysIn(source);
arrayEach(props || source, function(srcValue, key) { arrayEach(props || source, function(srcValue, key) {
if (props) { if (props) {
key = srcValue; key = srcValue;
@@ -3073,7 +3095,10 @@
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
} }
else { else {
var newValue = customizer ? customizer(object[key], srcValue, (key + ''), object, source, stack) : undefined; var newValue = customizer
? customizer(object[key], srcValue, (key + ''), object, source, stack)
: undefined;
if (newValue === undefined) { if (newValue === undefined) {
newValue = srcValue; newValue = srcValue;
} }
@@ -3105,8 +3130,11 @@
assignMergeValue(object, key, stacked); assignMergeValue(object, key, stacked);
return; return;
} }
var newValue = customizer ? customizer(objValue, srcValue, (key + ''), object, source, stack) : undefined, var newValue = customizer
isCommon = newValue === undefined; ? customizer(objValue, srcValue, (key + ''), object, source, stack)
: undefined;
var isCommon = newValue === undefined;
if (isCommon) { if (isCommon) {
newValue = srcValue; newValue = srcValue;
@@ -3382,7 +3410,9 @@
var objValue = nested[key]; var objValue = nested[key];
newValue = customizer ? customizer(objValue, key, nested) : undefined; newValue = customizer ? customizer(objValue, key, nested) : undefined;
if (newValue === undefined) { if (newValue === undefined) {
newValue = objValue == null ? (isIndex(path[index + 1]) ? [] : {}) : objValue; newValue = objValue == null
? (isIndex(path[index + 1]) ? [] : {})
: objValue;
} }
} }
assignValue(nested, key, newValue); assignValue(nested, key, newValue);
@@ -3831,10 +3861,11 @@
* @returns {Object} Returns the cloned typed array. * @returns {Object} Returns the cloned typed array.
*/ */
function cloneTypedArray(typedArray, isDeep) { function cloneTypedArray(typedArray, isDeep) {
var buffer = typedArray.buffer, var arrayBuffer = typedArray.buffer,
buffer = isDeep ? cloneArrayBuffer(arrayBuffer) : arrayBuffer,
Ctor = typedArray.constructor; Ctor = typedArray.constructor;
return new Ctor(isDeep ? cloneArrayBuffer(buffer) : buffer, typedArray.byteOffset, typedArray.length); return new Ctor(buffer, typedArray.byteOffset, typedArray.length);
} }
/** /**
@@ -3949,8 +3980,11 @@
length = props.length; length = props.length;
while (++index < length) { while (++index < length) {
var key = props[index], var key = props[index];
newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key];
var newValue = customizer
? customizer(object[key], source[key], key, object, source)
: source[key];
assignValue(object, key, newValue); assignValue(object, key, newValue);
} }
@@ -4000,7 +4034,10 @@
customizer = length > 1 ? sources[length - 1] : undefined, customizer = length > 1 ? sources[length - 1] : undefined,
guard = length > 2 ? sources[2] : undefined; guard = length > 2 ? sources[2] : undefined;
customizer = typeof customizer == 'function' ? (length--, customizer) : undefined; customizer = typeof customizer == 'function'
? (length--, customizer)
: undefined;
if (guard && isIterateeCall(sources[0], sources[1], guard)) { if (guard && isIterateeCall(sources[0], sources[1], guard)) {
customizer = length < 3 ? undefined : customizer; customizer = length < 3 ? undefined : customizer;
length = 1; length = 1;
@@ -4101,8 +4138,11 @@
return function(string) { return function(string) {
string = toString(string); string = toString(string);
var strSymbols = reHasComplexSymbol.test(string) ? stringToArray(string) : undefined, var strSymbols = reHasComplexSymbol.test(string)
chr = strSymbols ? strSymbols[0] : string.charAt(0), ? stringToArray(string)
: undefined;
var chr = strSymbols ? strSymbols[0] : string.charAt(0),
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1); trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
return chr[methodName]() + trailing; return chr[methodName]() + trailing;
@@ -4223,7 +4263,10 @@
var funcName = getFuncName(func), var funcName = getFuncName(func),
data = funcName == 'wrapper' ? getData(func) : undefined; 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]);
} else { } else {
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func); wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
@@ -4233,7 +4276,8 @@
var args = arguments, var args = arguments,
value = args[0]; value = args[0];
if (wrapper && args.length == 1 && isArray(value) && value.length >= LARGE_ARRAY_SIZE) { if (wrapper && args.length == 1 &&
isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
return wrapper.plant(value).value(); return wrapper.plant(value).value();
} }
var index = 0, var index = 0,
@@ -4293,7 +4337,10 @@
length -= argsHolders.length; length -= argsHolders.length;
if (length < arity) { if (length < arity) {
return createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, thisArg, args, argsHolders, argPos, ary, arity - length); return createRecurryWrapper(
func, bitmask, createHybridWrapper, placeholder, thisArg, args,
argsHolders, argPos, ary, arity - length
);
} }
} }
var thisBinding = isBind ? thisArg : this, var thisBinding = isBind ? thisArg : this,
@@ -4465,9 +4512,12 @@
if (!(bitmask & CURRY_BOUND_FLAG)) { if (!(bitmask & CURRY_BOUND_FLAG)) {
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
} }
var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, arity], var newData = [
result = wrapFunc.apply(undefined, newData); func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight,
newHoldersRight, newArgPos, ary, arity
];
var result = wrapFunc.apply(undefined, newData);
if (isLaziable(func)) { if (isLaziable(func)) {
setData(result, newData); setData(result, newData);
} }
@@ -4556,8 +4606,12 @@
partials = holders = undefined; partials = holders = undefined;
} }
var data = isBindKey ? undefined : getData(func), var data = isBindKey ? undefined : getData(func);
newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
var newData = [
func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
argPos, ary, arity
];
if (data) { if (data) {
mergeData(newData, data); mergeData(newData, data);
@@ -7193,11 +7247,16 @@
value = this.__wrapped__, value = this.__wrapped__,
interceptor = function(object) { return baseAt(object, paths); }; interceptor = function(object) { return baseAt(object, paths); };
if (length > 1 || this.__actions__.length || !(value instanceof LazyWrapper) || !isIndex(start)) { if (length > 1 || this.__actions__.length ||
!(value instanceof LazyWrapper) || !isIndex(start)) {
return this.thru(interceptor); return this.thru(interceptor);
} }
value = value.slice(start, +start + (length ? 1 : 0)); value = value.slice(start, +start + (length ? 1 : 0));
value.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); value.__actions__.push({
'func': thru,
'args': [interceptor],
'thisArg': undefined
});
return new LodashWrapper(value, this.__chain__).thru(function(array) { return new LodashWrapper(value, this.__chain__).thru(function(array) {
if (length && !array.length) { if (length && !array.length) {
array.push(undefined); array.push(undefined);
@@ -7408,7 +7467,11 @@
wrapped = new LazyWrapper(this); wrapped = new LazyWrapper(this);
} }
wrapped = wrapped.reverse(); wrapped = wrapped.reverse();
wrapped.__actions__.push({ 'func': thru, 'args': [reverse], 'thisArg': undefined }); wrapped.__actions__.push({
'func': thru,
'args': [reverse],
'thisArg': undefined
});
return new LodashWrapper(wrapped, this.__chain__); return new LodashWrapper(wrapped, this.__chain__);
} }
return this.thru(reverse); return this.thru(reverse);
@@ -8686,8 +8749,10 @@
if (!lastCalled && !maxTimeoutId && !leading) { if (!lastCalled && !maxTimeoutId && !leading) {
lastCalled = stamp; lastCalled = stamp;
} }
var remaining = maxWait - (stamp - lastCalled), var remaining = maxWait - (stamp - lastCalled);
isCalled = (remaining <= 0 || remaining > maxWait) && (leading || maxTimeoutId);
var isCalled = (remaining <= 0 || remaining > maxWait) &&
(leading || maxTimeoutId);
if (isCalled) { if (isCalled) {
if (maxTimeoutId) { if (maxTimeoutId) {
@@ -9193,7 +9258,11 @@
leading = 'leading' in options ? !!options.leading : leading; leading = 'leading' in options ? !!options.leading : leading;
trailing = 'trailing' in options ? !!options.trailing : trailing; trailing = 'trailing' in options ? !!options.trailing : trailing;
} }
return debounce(func, wait, { 'leading': leading, 'maxWait': wait, 'trailing': trailing }); return debounce(func, wait, {
'leading': leading,
'maxWait': wait,
'trailing': trailing
});
} }
/** /**
@@ -9708,7 +9777,8 @@
*/ */
function isEmpty(value) { function isEmpty(value) {
if (isArrayLike(value) && if (isArrayLike(value) &&
(isArray(value) || isString(value) || isFunction(value.splice) || isArguments(value))) { (isArray(value) || isString(value) ||
isFunction(value.splice) || isArguments(value))) {
return !value.length; return !value.length;
} }
for (var key in value) { for (var key in value) {
@@ -9918,7 +9988,8 @@
* // => false * // => false
*/ */
function isLength(value) { function isLength(value) {
return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; return typeof value == 'number' &&
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
} }
/** /**
@@ -10217,7 +10288,8 @@
* // => true * // => true
*/ */
function isPlainObject(value) { function isPlainObject(value) {
if (!isObjectLike(value) || objectToString.call(value) != objectTag || isHostObject(value)) { if (!isObjectLike(value) ||
objectToString.call(value) != objectTag || isHostObject(value)) {
return false; return false;
} }
var proto = objectProto; var proto = objectProto;
@@ -10360,7 +10432,8 @@
* // => false * // => false
*/ */
function isTypedArray(value) { function isTypedArray(value) {
return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objectToString.call(value)]; return isObjectLike(value) &&
isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
} }
/** /**
@@ -11040,7 +11113,9 @@
* // => logs 'a', 'b', then 'c' (iteration order is not guaranteed) * // => logs 'a', 'b', then 'c' (iteration order is not guaranteed)
*/ */
function forIn(object, iteratee) { function forIn(object, iteratee) {
return object == null ? object : baseFor(object, baseCastFunction(iteratee), keysIn); return object == null
? object
: baseFor(object, baseCastFunction(iteratee), keysIn);
} }
/** /**
@@ -11068,7 +11143,9 @@
* // => logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c' * // => logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'
*/ */
function forInRight(object, iteratee) { function forInRight(object, iteratee) {
return object == null ? object : baseForRight(object, baseCastFunction(iteratee), keysIn); return object == null
? object
: baseForRight(object, baseCastFunction(iteratee), keysIn);
} }
/** /**
@@ -12810,7 +12887,8 @@
'return __p\n}'; 'return __p\n}';
var result = attempt(function() { var result = attempt(function() {
return Function(importsKeys, sourceURL + 'return ' + source).apply(undefined, importsValues); return Function(importsKeys, sourceURL + 'return ' + source)
.apply(undefined, importsValues);
}); });
// Provide the compiled function's source by its `toString` method or // Provide the compiled function's source by its `toString` method or
@@ -12904,7 +12982,9 @@
var strSymbols = stringToArray(string), var strSymbols = stringToArray(string),
chrSymbols = stringToArray(chars); chrSymbols = stringToArray(chars);
return strSymbols.slice(charsStartIndex(strSymbols, chrSymbols), charsEndIndex(strSymbols, chrSymbols) + 1).join(''); return strSymbols
.slice(charsStartIndex(strSymbols, chrSymbols), charsEndIndex(strSymbols, chrSymbols) + 1)
.join('');
} }
/** /**
@@ -12938,7 +13018,9 @@
return string; return string;
} }
var strSymbols = stringToArray(string); var strSymbols = stringToArray(string);
return strSymbols.slice(0, charsEndIndex(strSymbols, stringToArray(chars)) + 1).join(''); return strSymbols
.slice(0, charsEndIndex(strSymbols, stringToArray(chars)) + 1)
.join('');
} }
/** /**
@@ -12972,7 +13054,9 @@
return string; return string;
} }
var strSymbols = stringToArray(string); var strSymbols = stringToArray(string);
return strSymbols.slice(charsStartIndex(strSymbols, stringToArray(chars))).join(''); return strSymbols
.slice(charsStartIndex(strSymbols, stringToArray(chars)))
.join('');
} }
/** /**
@@ -13368,7 +13452,8 @@
* Creates a function that invokes `func` with the arguments of the created * Creates a function that invokes `func` with the arguments of the created
* function. If `func` is a property name the created callback returns the * function. If `func` is a property name the created callback returns the
* property value for a given element. If `func` is an object the created * property value for a given element. If `func` is an object the created
* callback returns `true` for elements that contain the equivalent object properties, otherwise it returns `false`. * callback returns `true` for elements that contain the equivalent object
* properties, otherwise it returns `false`.
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -14580,7 +14665,10 @@
if (filtered) { if (filtered) {
result.__takeCount__ = nativeMin(n, result.__takeCount__); result.__takeCount__ = nativeMin(n, result.__takeCount__);
} else { } else {
result.__views__.push({ 'size': nativeMin(n, MAX_ARRAY_LENGTH), 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') }); result.__views__.push({
'size': nativeMin(n, MAX_ARRAY_LENGTH),
'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
});
} }
return result; return result;
}; };
@@ -14597,7 +14685,10 @@
LazyWrapper.prototype[methodName] = function(iteratee) { LazyWrapper.prototype[methodName] = function(iteratee) {
var result = this.clone(); var result = this.clone();
result.__iteratees__.push({ 'iteratee': getIteratee(iteratee, 3), 'type': type }); result.__iteratees__.push({
'iteratee': getIteratee(iteratee, 3),
'type': type
});
result.__filtered__ = result.__filtered__ || isFilter; result.__filtered__ = result.__filtered__ || isFilter;
return result; return result;
}; };
@@ -14749,7 +14840,10 @@
} }
}); });
realNames[createHybridWrapper(undefined, BIND_KEY_FLAG).name] = [{ 'name': 'wrapper', 'func': undefined }]; 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;