mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 10:17:48 +00:00
Move internal modules to “internal” folder.
This commit is contained in:
41
.internal/compareAscending.js
Normal file
41
.internal/compareAscending.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import isSymbol from './isSymbol.js';
|
||||
|
||||
/**
|
||||
* Compares values to sort them in ascending order.
|
||||
*
|
||||
* @private
|
||||
* @param {*} value The value to compare.
|
||||
* @param {*} other The other value to compare.
|
||||
* @returns {number} Returns the sort order indicator for `value`.
|
||||
*/
|
||||
function compareAscending(value, other) {
|
||||
if (value !== other) {
|
||||
const valIsDefined = value !== undefined;
|
||||
const valIsNull = value === null;
|
||||
const valIsReflexive = value === value;
|
||||
const valIsSymbol = isSymbol(value);
|
||||
|
||||
const othIsDefined = other !== undefined;
|
||||
const othIsNull = other === null;
|
||||
const othIsReflexive = other === other;
|
||||
const othIsSymbol = isSymbol(other);
|
||||
|
||||
if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
|
||||
(valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
|
||||
(valIsNull && othIsDefined && othIsReflexive) ||
|
||||
(!valIsDefined && othIsReflexive) ||
|
||||
!valIsReflexive) {
|
||||
return 1;
|
||||
}
|
||||
if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
|
||||
(othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
|
||||
(othIsNull && valIsDefined && valIsReflexive) ||
|
||||
(!othIsDefined && valIsReflexive) ||
|
||||
!othIsReflexive) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
export default compareAscending;
|
||||
Reference in New Issue
Block a user