23 lines
617 B
JavaScript
Raw Normal View History

2026-05-31 13:21:13 +02:00
//#region src/compat/_internal/compareValues.ts
function getPriority(a) {
if (typeof a === "symbol") return 1;
if (a === null) return 2;
if (a === void 0) return 3;
if (a !== a) return 4;
return 0;
}
const compareValues = (a, b, order) => {
if (a !== b) {
const aPriority = getPriority(a);
const bPriority = getPriority(b);
if (aPriority === bPriority && aPriority === 0) {
if (a < b) return order === "desc" ? 1 : -1;
if (a > b) return order === "desc" ? -1 : 1;
}
return order === "desc" ? bPriority - aPriority : aPriority - bPriority;
}
return 0;
};
//#endregion
export { compareValues };