How to use the comparator function from ramda
Find comprehensive JavaScript ramda.comparator code examples handpicked from public code repositorys.
GitHub: ayush-rudani/npmBox
42 43 44 45 46 47 48 49 50 51 52
* * @return * returns boolean based on comparision done. */ const byAge = R.comparator((a, b) => a.age < b.age); const people = [ { name: 'Emma', age: 70 }, { name: 'Peter', age: 78 },
19
15
0
+ 5 other calls in file
1625 1626 1627 1628 1629 1630 1631 1632 1633 1634
* @sig (a, b -> Boolean) -> (a, b -> Number) * @param {Function} pred A predicate function of arity two. * @return {Function} A Function :: a -> b -> Int that returns `-1` if a < b, `1` if b < a, otherwise `0`. * @example * * var cmp = R.comparator((a, b) => a.age < b.age); * var people = [ * // ... * ]; * R.sort(cmp, people);
0
0
0
+ 17 other calls in file
1488 1489 1490 1491 1492 1493 1494 1495 1496 1497
* @param {Function} pred A predicate function of arity two which will return `true` if the first argument * is less than the second, `false` otherwise * @return {Function} A Function :: a -> b -> Int that returns `-1` if a < b, `1` if b < a, otherwise `0` * @example * * const byAge = R.comparator((a, b) => a.age < b.age); * const people = [ * { name: 'Emma', age: 70 }, * { name: 'Peter', age: 78 }, * { name: 'Mikhail', age: 62 },
0
0
2
+ 3 other calls in file
50 51 52 53 54 55 56 57 58 59
*/ const fileEnvToKey = (fileEnv) => R.filter( (key) => !!key, R.sort( R.comparator((a, b) => a < b), R.map(getKeys, getLines(fileEnv)) ) );
0
0
0
5 6 7 8 9 10 11 12 13 14 15 16 17
const transformSupervisors = (supervisors) => { // remove supervisors with numerical jurisdictions const filteredNumericalJurisdictions = R.filter(isStringInteger, supervisors); const jurisdictionComp = R.comparator((a, b) => a.jurisdiction < b.jurisdiction); const lastNameComp = R.comparator((a, b) => a.lastName < b.lastName); const firstNameComp = R.comparator((a, b) => a.firstName < b.firstName); // sort the filtered list by jurisdiction, last name, and first name
0
0
0
+ 5 other calls in file
ramda.clone is the most popular function in ramda (30311 examples)