You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

23 lines
398 B

export function createCompareFunction(
a, b, winner, loser
){
if (a === b) return 0
return a < b ? winner : loser
}
export function ascend(
getFunction, a, b
){
if (arguments.length === 1){
return (_a, _b) => ascend(
getFunction, _a, _b
)
}
const aValue = getFunction(a)
const bValue = getFunction(b)
return createCompareFunction(
aValue, bValue, -1, 1
)
}