@zkochan/pnpm
Version:
Fast, disk space efficient package manager
32 lines (29 loc) • 924 B
JavaScript
var _curry3 = /*#__PURE__*/require('./internal/_curry3');
/**
* Makes an ascending comparator function out of a function that returns a value
* that can be compared with `<` and `>`.
*
* @func
* @memberOf R
* @since v0.23.0
* @category Function
* @sig Ord b => (a -> b) -> a -> a -> Number
* @param {Function} fn A function of arity one that returns a value that can be compared
* @param {*} a The first item to be compared.
* @param {*} b The second item to be compared.
* @return {Number} `-1` if fn(a) < fn(b), `1` if fn(b) < fn(a), otherwise `0`
* @see R.descend
* @example
*
* var byAge = R.ascend(R.prop('age'));
* var people = [
* // ...
* ];
* var peopleByYoungestFirst = R.sort(byAge, people);
*/
var ascend = /*#__PURE__*/_curry3(function ascend(fn, a, b) {
var aa = fn(a);
var bb = fn(b);
return aa < bb ? -1 : aa > bb ? 1 : 0;
});
module.exports = ascend;