(compare = ascending)
| 25 | } |
| 26 | |
| 27 | export function compareDefined(compare = ascending) { |
| 28 | if (compare === ascending) return ascendingDefined; |
| 29 | if (typeof compare !== "function") throw new TypeError("compare is not a function"); |
| 30 | return (a, b) => { |
| 31 | const x = compare(a, b); |
| 32 | if (x || x === 0) return x; |
| 33 | return (compare(b, b) === 0) - (compare(a, a) === 0); |
| 34 | }; |
| 35 | } |
| 36 | |
| 37 | export function ascendingDefined(a, b) { |
| 38 | return (a == null || !(a >= a)) - (b == null || !(b >= b)) || (a < b ? -1 : a > b ? 1 : 0); |
no outgoing calls
no test coverage detected
searching dependent graphs…