UNPKG

firestore-snapshot-utils

Version:

[![github license](https://img.shields.io/github/license/ericvera/firestore-snapshot-utils.svg?style=flat-square)](https://github.com/ericvera/firestore-snapshot-utils/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/firestore-snapshot-ut

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'); };