@dvcol/common-utils
Version:
Typescript library for common utility functions and constants
31 lines (29 loc) • 894 B
text/typescript
/**
* Null-safe string local compare.
* If a is falsy return 1.
* If b is falsy return -1.
* Else local compare a to b
* @param a
* @param b
*/
declare const stringCompare: (a?: string, b?: string) => number;
/**
* Null-safe string number compare.
* If a is falsy return 1.
* If b is falsy return -1.
* Else compare a to b
* @param a
* @param b
*/
declare const numberCompare: (a?: number, b?: number) => number;
/**
* Execute a null/undefined safe compare with the provided compare function.
* If both inputs are null/undefined return 0.
* If a is null/undefined but not b, returns 1.
* If b is null/undefined but not a, returns -1.
* Else execute compare;
* @param compareFn
* @param reverse
*/
declare const nullSafeCompare: <A, B>(compareFn: (a: A, b: B) => number, reverse?: boolean) => (a: A, b: B) => any;
export { nullSafeCompare, numberCompare, stringCompare };