source: imaps-frontend/node_modules/lodash-es/_compareAscending.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[d565449]1import isSymbol from './isSymbol.js';
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 */
11function 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
41export default compareAscending;
Note: See TracBrowser for help on using the repository browser.