source: node_modules/es-toolkit/dist/compat/_internal/compareValues.mjs

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 760 bytes
RevLine 
[a762898]1function getPriority(a) {
2 if (typeof a === 'symbol') {
3 return 1;
4 }
5 if (a === null) {
6 return 2;
7 }
8 if (a === undefined) {
9 return 3;
10 }
11 if (a !== a) {
12 return 4;
13 }
14 return 0;
15}
16const compareValues = (a, b, order) => {
17 if (a !== b) {
18 const aPriority = getPriority(a);
19 const bPriority = getPriority(b);
20 if (aPriority === bPriority && aPriority === 0) {
21 if (a < b) {
22 return order === 'desc' ? 1 : -1;
23 }
24 if (a > b) {
25 return order === 'desc' ? -1 : 1;
26 }
27 }
28 return order === 'desc' ? bPriority - aPriority : aPriority - bPriority;
29 }
30 return 0;
31};
32
33export { compareValues };
Note: See TracBrowser for help on using the repository browser.