mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Cleanup compareAscending and createBound.
Former-commit-id: e783a68666aaea16d917fa1db74d2092e5dcaa9a
This commit is contained in:
36
dist/lodash.compat.js
vendored
36
dist/lodash.compat.js
vendored
@@ -238,19 +238,16 @@
|
||||
* @returns {Number} Returns the sort order indicator of `1` or `-1`.
|
||||
*/
|
||||
function compareAscending(a, b) {
|
||||
var ai = a.index,
|
||||
bi = b.index;
|
||||
|
||||
a = a.criteria;
|
||||
b = b.criteria;
|
||||
var ac = a.criteria;
|
||||
bc = b.criteria;
|
||||
|
||||
// ensure a stable sort in V8 and other engines
|
||||
// http://code.google.com/p/v8/issues/detail?id=90
|
||||
if (a !== b) {
|
||||
if (a > b || typeof a == 'undefined') {
|
||||
if (ac !== bc) {
|
||||
if (ac > bc || typeof ac == 'undefined') {
|
||||
return 1;
|
||||
}
|
||||
if (a < b || typeof b == 'undefined') {
|
||||
if (ac < bc || typeof bc == 'undefined') {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -258,7 +255,7 @@
|
||||
// `Array#sort` implementation that causes it, under certain circumstances,
|
||||
// to return the same value for `a` and `b`.
|
||||
// See https://github.com/jashkenas/underscore/pull/1247
|
||||
return ai < bi ? -1 : (ai > bi ? 1 : 0);
|
||||
return a.index - b.index;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1399,8 +1396,9 @@
|
||||
* 1 - `_.bind`
|
||||
* 2 - `_.bindKey`
|
||||
* 4 - `_.curry`
|
||||
* 8 - `_.partial`
|
||||
* 16 - `_.partialRight`
|
||||
* 8 - `_.curry` (bound)
|
||||
* 16 - `_.partial`
|
||||
* 32 - `_.partialRight`
|
||||
* @param {Array} [partialArgs] An array of arguments to prepend to those
|
||||
* provided to the new function.
|
||||
* @param {Array} [partialRightArgs] An array of arguments to append to those
|
||||
@@ -1413,8 +1411,9 @@
|
||||
var isBind = bitmask & 1,
|
||||
isBindKey = bitmask & 2,
|
||||
isCurry = bitmask & 4,
|
||||
isPartial = bitmask & 8,
|
||||
isPartialRight = bitmask & 16;
|
||||
isCurryBound = bitmask & 8,
|
||||
isPartial = bitmask & 16,
|
||||
isPartialRight = bitmask & 32;
|
||||
|
||||
if (!isBindKey && !isFunction(func)) {
|
||||
throw new TypeError;
|
||||
@@ -1441,7 +1440,8 @@
|
||||
push.apply(args, partialRightArgs);
|
||||
}
|
||||
if (isCurry && args.length < arity) {
|
||||
return createBound(func, 12, args, null, null, arity);
|
||||
bitmask |= 16 & ~32
|
||||
return createBound(func, (isCurryBound ? bitmask : bitmask & ~3), args, null, thisArg, arity);
|
||||
}
|
||||
if (isBindKey) {
|
||||
func = thisBinding[key];
|
||||
@@ -5017,7 +5017,7 @@
|
||||
* // => 'hi moe'
|
||||
*/
|
||||
function bind(func, thisArg) {
|
||||
return createBound(func, 9, nativeSlice.call(arguments, 2), null, thisArg);
|
||||
return createBound(func, 17, nativeSlice.call(arguments, 2), null, thisArg);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5091,7 +5091,7 @@
|
||||
* // => 'hi, moe!'
|
||||
*/
|
||||
function bindKey(object, key) {
|
||||
return createBound(object, 11, nativeSlice.call(arguments, 2), null, key);
|
||||
return createBound(object, 19, nativeSlice.call(arguments, 2), null, key);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5518,7 +5518,7 @@
|
||||
* // => 'hi moe'
|
||||
*/
|
||||
function partial(func) {
|
||||
return createBound(func, 8, nativeSlice.call(arguments, 1));
|
||||
return createBound(func, 16, nativeSlice.call(arguments, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5549,7 +5549,7 @@
|
||||
* // => { '_': _, 'jq': $ }
|
||||
*/
|
||||
function partialRight(func) {
|
||||
return createBound(func, 16, null, nativeSlice.call(arguments, 1));
|
||||
return createBound(func, 32, null, nativeSlice.call(arguments, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user