mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-22 05:38:03 +00:00
30 lines
729 B
JavaScript
30 lines
729 B
JavaScript
import { createCmp } from '../bi/helpers.js';
|
|
/**
|
|
* @name bnMax
|
|
* @summary Finds and returns the highest value in an array of BNs.
|
|
* @example
|
|
* <BR>
|
|
*
|
|
* ```javascript
|
|
* import BN from 'bn.js';
|
|
* import { bnMax } from '@pezkuwi/util';
|
|
*
|
|
* bnMax([new BN(1), new BN(3), new BN(2)]).toString(); // => '3'
|
|
* ```
|
|
*/
|
|
export const bnMax = /*#__PURE__*/ createCmp((a, b) => a.gt(b));
|
|
/**
|
|
* @name bnMin
|
|
* @summary Finds and returns the smallest value in an array of BNs.
|
|
* @example
|
|
* <BR>
|
|
*
|
|
* ```javascript
|
|
* import BN from 'bn.js';
|
|
* import { bnMin } from '@pezkuwi/util';
|
|
*
|
|
* bnMin([new BN(1), new BN(3), new BN(2)]).toString(); // => '1'
|
|
* ```
|
|
*/
|
|
export const bnMin = /*#__PURE__*/ createCmp((a, b) => a.lt(b));
|