/ cloudformation-templates / node_modules / lodash / _compareAscending.js
_compareAscending.js
 1  var isSymbol = require('./isSymbol');
 2  
 3  /**
 4   * Compares values to sort them in ascending order.
 5   *
 6   * @private
 7   * @param {*} value The value to compare.
 8   * @param {*} other The other value to compare.
 9   * @returns {number} Returns the sort order indicator for `value`.
10   */
11  function compareAscending(value, other) {
12    if (value !== other) {
13      var valIsDefined = value !== undefined,
14          valIsNull = value === null,
15          valIsReflexive = value === value,
16          valIsSymbol = isSymbol(value);
17  
18      var othIsDefined = other !== undefined,
19          othIsNull = other === null,
20          othIsReflexive = other === other,
21          othIsSymbol = isSymbol(other);
22  
23      if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
24          (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
25          (valIsNull && othIsDefined && othIsReflexive) ||
26          (!valIsDefined && othIsReflexive) ||
27          !valIsReflexive) {
28        return 1;
29      }
30      if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
31          (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
32          (othIsNull && valIsDefined && valIsReflexive) ||
33          (!othIsDefined && valIsReflexive) ||
34          !othIsReflexive) {
35        return -1;
36      }
37    }
38    return 0;
39  }
40  
41  module.exports = compareAscending;