Skip to content

Commit

Permalink
feat(compare): add compareNumAsc/Desc numeric comparators
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Nov 11, 2019
1 parent bcd1e64 commit 2b8fafc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/compare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,19 @@ export const compare = (a: any, b: any): number => {
}
return a < b ? -1 : a > b ? 1 : 0;
};

/**
* Numeric comparator (ascending order)
*
* @param a
* @param b
*/
export const compareNumAsc = (a: number, b: number) => a - b;

/**
* Numeric comparator (descending order)
*
* @param a
* @param b
*/
export const compareNumDesc = (a: number, b: number) => b - a;

0 comments on commit 2b8fafc

Please sign in to comment.