mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 19:07:49 +00:00
Cleanup var names and properties.
Former-commit-id: a3455f40184b61a7abe3f5749ea1c0a141c0e574
This commit is contained in:
30
build.js
30
build.js
@@ -224,6 +224,7 @@
|
|||||||
'init',
|
'init',
|
||||||
'loop',
|
'loop',
|
||||||
'shadowedProps',
|
'shadowedProps',
|
||||||
|
'support',
|
||||||
'top',
|
'top',
|
||||||
'useHas',
|
'useHas',
|
||||||
'useKeys'
|
'useKeys'
|
||||||
@@ -1044,7 +1045,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the all references to `varName` from `createIterator` in `source`.
|
* Removes all references to `identifier` from `createIterator` in `source`.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {String} source The source to process.
|
* @param {String} source The source to process.
|
||||||
@@ -1076,14 +1077,23 @@
|
|||||||
.replace(/,(?=\s*\))/, '');
|
.replace(/,(?=\s*\))/, '');
|
||||||
});
|
});
|
||||||
|
|
||||||
// remove property assignment from `getObject`
|
return removeFromGetObject(source, identifier);
|
||||||
source = source.replace(matchFunction(source, 'getObject'), function(match) {
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all references to `identifier` from `getObject` in `source`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {String} source The source to process.
|
||||||
|
* @param {String} identifier The name of the property to remove.
|
||||||
|
* @returns {String} Returns the modified source.
|
||||||
|
*/
|
||||||
|
function removeFromGetObject(source, identifier) {
|
||||||
|
return source.replace(matchFunction(source, 'getObject'), function(match) {
|
||||||
return match
|
return match
|
||||||
.replace(RegExp("^(?: *\\/\\/.*\\n)* *'" + identifier + "':.+\\n+", 'm'), '')
|
.replace(RegExp("^(?: *\\/\\/.*\\n)* *'" + identifier + "':.+\\n+", 'm'), '')
|
||||||
.replace(/,(?=\s*})/, '');
|
.replace(/,(?=\s*})/, '');
|
||||||
});
|
});
|
||||||
|
|
||||||
return source;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3014,6 +3024,10 @@
|
|||||||
if (isModern || isUnderscore) {
|
if (isModern || isUnderscore) {
|
||||||
source = removeFunction(source, 'createIterator');
|
source = removeFunction(source, 'createIterator');
|
||||||
|
|
||||||
|
iteratorOptions.forEach(function(prop) {
|
||||||
|
source = removeFromGetObject(source, prop);
|
||||||
|
});
|
||||||
|
|
||||||
// inline all functions defined with `createIterator`
|
// inline all functions defined with `createIterator`
|
||||||
_.functions(lodash).forEach(function(methodName) {
|
_.functions(lodash).forEach(function(methodName) {
|
||||||
// strip leading underscores to match pseudo private functions
|
// strip leading underscores to match pseudo private functions
|
||||||
@@ -3120,8 +3134,10 @@
|
|||||||
|
|
||||||
// prepend data object references to property names to avoid having to
|
// prepend data object references to property names to avoid having to
|
||||||
// use a with-statement
|
// use a with-statement
|
||||||
iteratorOptions.forEach(function(property) {
|
iteratorOptions.forEach(function(prop) {
|
||||||
snippet = snippet.replace(RegExp('([^\\w.])\\b' + property + '\\b', 'g'), '$1obj.' + property);
|
if (prop !== 'support') {
|
||||||
|
snippet = snippet.replace(RegExp('([^\\w.])\\b' + prop + '\\b', 'g'), '$1obj.' + prop);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// remove unnecessary code
|
// remove unnecessary code
|
||||||
|
|||||||
@@ -332,7 +332,7 @@
|
|||||||
'criteria',
|
'criteria',
|
||||||
'index',
|
'index',
|
||||||
'indexOf',
|
'indexOf',
|
||||||
'initArray',
|
'initedArray',
|
||||||
'release',
|
'release',
|
||||||
'value'
|
'value'
|
||||||
];
|
];
|
||||||
|
|||||||
37
lodash.js
37
lodash.js
@@ -167,6 +167,7 @@
|
|||||||
'args': null,
|
'args': null,
|
||||||
'array': null,
|
'array': null,
|
||||||
'arrays': null,
|
'arrays': null,
|
||||||
|
'bottom': null,
|
||||||
'contains': null,
|
'contains': null,
|
||||||
'criteria': null,
|
'criteria': null,
|
||||||
'false': null,
|
'false': null,
|
||||||
@@ -175,7 +176,8 @@
|
|||||||
'index': null,
|
'index': null,
|
||||||
'indexOf': null,
|
'indexOf': null,
|
||||||
'init': null,
|
'init': null,
|
||||||
'initArray': null,
|
'initedArray': null,
|
||||||
|
'loop': null,
|
||||||
'null': null,
|
'null': null,
|
||||||
'number': null,
|
'number': null,
|
||||||
'object': null,
|
'object': null,
|
||||||
@@ -184,6 +186,7 @@
|
|||||||
'shadowedProps': null,
|
'shadowedProps': null,
|
||||||
'string': null,
|
'string': null,
|
||||||
'support': null,
|
'support': null,
|
||||||
|
'top': null,
|
||||||
'true': null,
|
'true': null,
|
||||||
'undefined': null,
|
'undefined': null,
|
||||||
'useHas': null,
|
'useHas': null,
|
||||||
@@ -919,7 +922,7 @@
|
|||||||
|
|
||||||
function release() {
|
function release() {
|
||||||
var cache = this.cache;
|
var cache = this.cache;
|
||||||
if (cache.initArray) {
|
if (cache.initedArray) {
|
||||||
releaseArray(this.array);
|
releaseArray(this.array);
|
||||||
}
|
}
|
||||||
releaseObject(cache);
|
releaseObject(cache);
|
||||||
@@ -928,19 +931,20 @@
|
|||||||
return function(array) {
|
return function(array) {
|
||||||
var bailout,
|
var bailout,
|
||||||
index = -1,
|
index = -1,
|
||||||
initArray = !array && (array = getArray()),
|
indexOf = getIndexOf(),
|
||||||
|
initedArray = !array && (array = getArray()),
|
||||||
length = array.length,
|
length = array.length,
|
||||||
isLarge = length >= largeArraySize && lodash.indexOf != indexOf;
|
isLarge = length >= largeArraySize && lodash.indexOf !== indexOf;
|
||||||
|
|
||||||
var cache = getObject();
|
var cache = getObject();
|
||||||
cache.initArray = initArray;
|
cache.initedArray = initedArray;
|
||||||
cache['false'] = cache['function'] = cache['null'] = cache['true'] = cache['undefined'] = false;
|
cache['false'] = cache['function'] = cache['null'] = cache['true'] = cache['undefined'] = false;
|
||||||
|
|
||||||
var result = getObject();
|
var result = getObject();
|
||||||
result.array = array;
|
result.array = array;
|
||||||
result.indexOf = getIndexOf();
|
|
||||||
result.cache = cache;
|
result.cache = cache;
|
||||||
result.contains = cacheContains;
|
result.contains = cacheContains;
|
||||||
|
result.indexOf = indexOf;
|
||||||
result.push = cachePush;
|
result.push = cachePush;
|
||||||
result.release = release;
|
result.release = release;
|
||||||
|
|
||||||
@@ -1069,7 +1073,7 @@
|
|||||||
* @returns {Function} Returns the "indexOf" function.
|
* @returns {Function} Returns the "indexOf" function.
|
||||||
*/
|
*/
|
||||||
function getIndexOf(array, value, fromIndex) {
|
function getIndexOf(array, value, fromIndex) {
|
||||||
var result = (result = lodash.indexOf) == indexOf ? basicIndexOf : result;
|
var result = (result = lodash.indexOf) === indexOf ? basicIndexOf : result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1470,7 +1474,7 @@
|
|||||||
return ctor(result.source, reFlags.exec(result));
|
return ctor(result.source, reFlags.exec(result));
|
||||||
}
|
}
|
||||||
// check for circular references and return corresponding clone
|
// check for circular references and return corresponding clone
|
||||||
var initStack = !stackA;
|
var initedStack = !stackA;
|
||||||
stackA || (stackA = getArray());
|
stackA || (stackA = getArray());
|
||||||
stackB || (stackB = getArray());
|
stackB || (stackB = getArray());
|
||||||
|
|
||||||
@@ -1502,7 +1506,7 @@
|
|||||||
result[key] = clone(objValue, deep, callback, undefined, stackA, stackB);
|
result[key] = clone(objValue, deep, callback, undefined, stackA, stackB);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (initStack) {
|
if (initedStack) {
|
||||||
releaseArray(stackA);
|
releaseArray(stackA);
|
||||||
releaseArray(stackB);
|
releaseArray(stackB);
|
||||||
}
|
}
|
||||||
@@ -1952,7 +1956,7 @@
|
|||||||
// assume cyclic structures are equal
|
// assume cyclic structures are equal
|
||||||
// the algorithm for detecting cyclic structures is adapted from ES 5.1
|
// the algorithm for detecting cyclic structures is adapted from ES 5.1
|
||||||
// section 15.12.3, abstract operation `JO` (http://es5.github.com/#x15.12.3)
|
// section 15.12.3, abstract operation `JO` (http://es5.github.com/#x15.12.3)
|
||||||
var initStack = !stackA;
|
var initedStack = !stackA;
|
||||||
stackA || (stackA = getArray());
|
stackA || (stackA = getArray());
|
||||||
stackB || (stackB = getArray());
|
stackB || (stackB = getArray());
|
||||||
|
|
||||||
@@ -2016,7 +2020,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (initStack) {
|
if (initedStack) {
|
||||||
releaseArray(stackA);
|
releaseArray(stackA);
|
||||||
releaseArray(stackB);
|
releaseArray(stackB);
|
||||||
}
|
}
|
||||||
@@ -2329,7 +2333,7 @@
|
|||||||
stackA = args[4],
|
stackA = args[4],
|
||||||
stackB = args[5];
|
stackB = args[5];
|
||||||
} else {
|
} else {
|
||||||
var initStack = true;
|
var initedStack = true;
|
||||||
stackA = getArray();
|
stackA = getArray();
|
||||||
stackB = getArray();
|
stackB = getArray();
|
||||||
|
|
||||||
@@ -2398,7 +2402,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initStack) {
|
if (initedStack) {
|
||||||
releaseArray(stackA);
|
releaseArray(stackA);
|
||||||
releaseArray(stackB);
|
releaseArray(stackB);
|
||||||
}
|
}
|
||||||
@@ -3987,12 +3991,11 @@
|
|||||||
function intersection(array) {
|
function intersection(array) {
|
||||||
var args = arguments,
|
var args = arguments,
|
||||||
argsLength = args.length,
|
argsLength = args.length,
|
||||||
caches = getArray(),
|
|
||||||
index = -1,
|
index = -1,
|
||||||
length = array ? array.length : 0,
|
length = array ? array.length : 0,
|
||||||
isLarge = length >= largeArraySize,
|
|
||||||
result = [];
|
result = [];
|
||||||
|
|
||||||
|
var caches = getArray();
|
||||||
caches[0] = createCache();
|
caches[0] = createCache();
|
||||||
|
|
||||||
outer:
|
outer:
|
||||||
@@ -4385,9 +4388,9 @@
|
|||||||
*/
|
*/
|
||||||
var uniq = overloadWrapper(function(array, isSorted, callback) {
|
var uniq = overloadWrapper(function(array, isSorted, callback) {
|
||||||
var index = -1,
|
var index = -1,
|
||||||
|
indexOf = getIndexOf(),
|
||||||
length = array ? array.length : 0,
|
length = array ? array.length : 0,
|
||||||
isLarge = !isSorted && length >= largeArraySize,
|
isLarge = !isSorted && length >= largeArraySize && lodash.indexOf !== indexOf,
|
||||||
indexOf = isLarge || getIndexOf(),
|
|
||||||
result = [],
|
result = [],
|
||||||
seen = isLarge ? createCache() : (callback ? getArray() : result);
|
seen = isLarge ? createCache() : (callback ? getArray() : result);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user