mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 19:07:49 +00:00
Remove _.map and _.pluck dependency from _.sortBy and simplify method wrappers.
Former-commit-id: 915af96abd41e8da7bba88cd57eb703f8129107f
This commit is contained in:
@@ -226,9 +226,9 @@
|
|||||||
result = snippet;
|
result = snippet;
|
||||||
|
|
||||||
if (snippet) {
|
if (snippet) {
|
||||||
// minify property strings
|
// minify properties
|
||||||
properties.forEach(function(property, index) {
|
properties.forEach(function(property, index) {
|
||||||
result = result.replace(RegExp("'" + property + "'", 'g'), "'" + minNames[index] + "'");
|
result = result.replace(RegExp('\\b' + property + '\\b', 'g'), minNames[index]);
|
||||||
});
|
});
|
||||||
// replace with modified snippet
|
// replace with modified snippet
|
||||||
source = source.replace(snippet, result);
|
source = source.replace(snippet, result);
|
||||||
|
|||||||
37
lodash.js
37
lodash.js
@@ -1526,12 +1526,17 @@
|
|||||||
} else if (thisArg) {
|
} else if (thisArg) {
|
||||||
callback = iteratorBind(callback, thisArg);
|
callback = iteratorBind(callback, thisArg);
|
||||||
}
|
}
|
||||||
return pluck(map(array, function(value, index) {
|
var index = -1,
|
||||||
return {
|
length = array.length,
|
||||||
'criteria': callback(value, index, array),
|
result = Array(length);
|
||||||
'value': value
|
|
||||||
|
while (++index < length) {
|
||||||
|
result[index] = {
|
||||||
|
'criteria': callback(array[index], index, array),
|
||||||
|
'value': array[index]
|
||||||
};
|
};
|
||||||
}).sort(function(left, right) {
|
}
|
||||||
|
result.sort(function(left, right) {
|
||||||
var a = left.criteria,
|
var a = left.criteria,
|
||||||
b = right.criteria;
|
b = right.criteria;
|
||||||
|
|
||||||
@@ -1542,7 +1547,12 @@
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return a < b ? -1 : a > b ? 1 : 0;
|
return a < b ? -1 : a > b ? 1 : 0;
|
||||||
}), 'value');
|
});
|
||||||
|
|
||||||
|
while (length--) {
|
||||||
|
result[length] = result[length].value;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1921,7 +1931,7 @@
|
|||||||
/**
|
/**
|
||||||
* Creates a new function that is the composition of the passed functions,
|
* Creates a new function that is the composition of the passed functions,
|
||||||
* where each function consumes the return value of the function that follows.
|
* where each function consumes the return value of the function that follows.
|
||||||
* In math terms, composing thefunctions `f()`, `g()`, and `h()` produces `f(g(h()))`.
|
* In math terms, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
@@ -3025,7 +3035,7 @@
|
|||||||
if (arguments.length) {
|
if (arguments.length) {
|
||||||
push.apply(args, arguments);
|
push.apply(args, arguments);
|
||||||
}
|
}
|
||||||
var result = args.length == 1 ? func.call(lodash, args[0]) : func.apply(lodash, args);
|
var result = func.apply(lodash, args);
|
||||||
if (this._chain) {
|
if (this._chain) {
|
||||||
result = new LoDash(result);
|
result = new LoDash(result);
|
||||||
result._chain = true;
|
result._chain = true;
|
||||||
@@ -3061,7 +3071,7 @@
|
|||||||
* @category Utilities
|
* @category Utilities
|
||||||
* @param {Object} object The object to inspect.
|
* @param {Object} object The object to inspect.
|
||||||
* @param {String} property The property to get the result of.
|
* @param {String} property The property to get the result of.
|
||||||
* @returns {Mixed} Returns the resolved.
|
* @returns {Mixed} Returns the resolved value.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* var object = {
|
* var object = {
|
||||||
@@ -3455,11 +3465,8 @@
|
|||||||
|
|
||||||
LoDash.prototype[methodName] = function() {
|
LoDash.prototype[methodName] = function() {
|
||||||
var value = this._wrapped;
|
var value = this._wrapped;
|
||||||
if (arguments.length) {
|
func.apply(value, arguments);
|
||||||
func.apply(value, arguments);
|
|
||||||
} else {
|
|
||||||
func.call(value);
|
|
||||||
}
|
|
||||||
// IE compatibility mode and IE < 9 have buggy Array `shift()` and `splice()`
|
// IE compatibility mode and IE < 9 have buggy Array `shift()` and `splice()`
|
||||||
// functions that fail to remove the last element, `value[0]`, of
|
// functions that fail to remove the last element, `value[0]`, of
|
||||||
// array-like objects even though the `length` property is set to `0`.
|
// array-like objects even though the `length` property is set to `0`.
|
||||||
@@ -3482,7 +3489,7 @@
|
|||||||
|
|
||||||
LoDash.prototype[methodName] = function() {
|
LoDash.prototype[methodName] = function() {
|
||||||
var value = this._wrapped,
|
var value = this._wrapped,
|
||||||
result = arguments.length ? func.apply(value, arguments) : func.call(value);
|
result = func.apply(value, arguments);
|
||||||
|
|
||||||
if (this._chain) {
|
if (this._chain) {
|
||||||
result = new LoDash(result);
|
result = new LoDash(result);
|
||||||
|
|||||||
Reference in New Issue
Block a user