UNPKG

firestore-snapshot-utils

Version:
12 lines (11 loc) 388 B
export const ascCompare = (getValue) => (a, b) => { const av = getValue(a); const bv = getValue(b); if (typeof av === 'number' && typeof bv === 'number') { return av - bv; } else if (typeof av === 'string' && typeof bv === 'string') { return av.localeCompare(bv); } throw new Error('Trying to compare values that are not string or number'); };