532866c137e9d06eb05153eb608740f9191edf00
[yaffs-website] / node_modules / grunt-legacy-util / node_modules / lodash / _compareAscending.js
1 /**
2  * Compares values to sort them in ascending order.
3  *
4  * @private
5  * @param {*} value The value to compare.
6  * @param {*} other The other value to compare.
7  * @returns {number} Returns the sort order indicator for `value`.
8  */
9 function compareAscending(value, other) {
10   if (value !== other) {
11     var valIsNull = value === null,
12         valIsUndef = value === undefined,
13         valIsReflexive = value === value;
14
15     var othIsNull = other === null,
16         othIsUndef = other === undefined,
17         othIsReflexive = other === other;
18
19     if ((value > other && !othIsNull) || !valIsReflexive ||
20         (valIsNull && !othIsUndef && othIsReflexive) ||
21         (valIsUndef && othIsReflexive)) {
22       return 1;
23     }
24     if ((value < other && !valIsNull) || !othIsReflexive ||
25         (othIsNull && !valIsUndef && valIsReflexive) ||
26         (othIsUndef && valIsReflexive)) {
27       return -1;
28     }
29   }
30   return 0;
31 }
32
33 module.exports = compareAscending;