source: node_modules/es-toolkit/dist/compat/_internal/compareValues.js@ ba17441

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

Added visualizations

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