descend

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
2
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
939 B
Makes a descending comparator function out of a function that returns a value that can be compared with `<` and `>`.
1 contributor
Install descend as a package?
Copied
npm i @bit/justin-capalbo.ramda.descend
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
descend (
fn:Function,
a:*,
b:*
) : Number

Makes a descending comparator function out of a function that returns a value that can be compared with < and >.

Example
const byAge = R.descend(R.prop('age'));
     const people = [
       { name: 'Emma', age: 70 },
       { name: 'Peter', age: 78 },
       { name: 'Mikhail', age: 62 },
     ];
     const peopleByOldestFirst = R.sort(byAge, people);
       //=> [{ name: 'Peter', age: 78 }, { name: 'Emma', age: 70 }, { name: 'Mikhail', age: 62 }]
Arguments
fn: Function

A function of arity one that returns a value that can be compared

a: *

The first item to be compared.

b: *

The second item to be compared.

Returns
Number

`-1` if fn(a) > fn(b), `1` if fn(b) > fn(a), otherwise `0`

Help and resources