Inline function for min/max creator (#1528)

This commit is contained in:
Jaco
2022-06-11 23:33:42 +03:00
committed by GitHub
parent 2fc26b5533
commit de5c9a1594
2 changed files with 4 additions and 24 deletions
+2 -12
View File
@@ -3,24 +3,14 @@
import { createCmp } from './helpers';
/** @internal */
function gt (a: bigint, b: bigint): boolean {
return a > b;
}
/** @internal */
function lt (a: bigint, b: bigint): boolean {
return a < b;
}
/**
* @name nMax
* @summary Finds and returns the highest value in an array of bigint.
*/
export const nMax = createCmp(gt);
export const nMax = createCmp<bigint>((a, b) => a > b);
/**
* @name nMin
* @summary Finds and returns the lowest value in an array of bigint.
*/
export const nMin = createCmp(lt);
export const nMin = createCmp<bigint>((a, b) => a < b);
+2 -12
View File
@@ -4,16 +4,6 @@
import { createCmp } from '../bi/helpers';
import { BN } from './bn';
/** @internal */
function gt (a: BN, b: BN): boolean {
return a.gt(b);
}
/** @internal */
function lt (a: BN, b: BN): boolean {
return a.lt(b);
}
/**
* @name bnMax
* @summary Finds and returns the highest value in an array of BNs.
@@ -27,7 +17,7 @@ function lt (a: BN, b: BN): boolean {
* bnMax([new BN(1), new BN(3), new BN(2)]).toString(); // => '3'
* ```
*/
export const bnMax = createCmp(gt);
export const bnMax = createCmp<BN>((a, b) => a.gt(b));
/**
* @name bnMin
@@ -42,4 +32,4 @@ export const bnMax = createCmp(gt);
* bnMin([new BN(1), new BN(3), new BN(2)]).toString(); // => '1'
* ```
*/
export const bnMin = createCmp(lt);
export const bnMin = createCmp<BN>((a, b) => a.lt(b));