mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 08:37:49 +00:00
44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
/**
|
|
* lodash 3.0.2 (Custom Build) <https://lodash.com/>
|
|
* Build: `lodash modern modularize exports="npm" -o ./`
|
|
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
* Available under MIT license <https://lodash.com/license>
|
|
*/
|
|
|
|
/**
|
|
* The base implementation of `compareAscending` which compares values and
|
|
* sorts them in ascending order without guaranteeing a stable sort.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to compare.
|
|
* @param {*} other The other value to compare.
|
|
* @returns {number} Returns the sort order indicator for `value`.
|
|
*/
|
|
function baseCompareAscending(value, other) {
|
|
if (value !== other) {
|
|
var valIsNull = value === null,
|
|
valIsUndef = value === undefined,
|
|
valIsReflexive = value === value;
|
|
|
|
var othIsNull = other === null,
|
|
othIsUndef = other === undefined,
|
|
othIsReflexive = other === other;
|
|
|
|
if ((value > other && !othIsNull) || !valIsReflexive ||
|
|
(valIsNull && !othIsUndef && othIsReflexive) ||
|
|
(valIsUndef && othIsReflexive)) {
|
|
return 1;
|
|
}
|
|
if ((value < other && !valIsNull) || !othIsReflexive ||
|
|
(othIsNull && !valIsUndef && valIsReflexive) ||
|
|
(othIsUndef && valIsReflexive)) {
|
|
return -1;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
module.exports = baseCompareAscending;
|