UNPKG

730 BJavaScriptView Raw
1import { createCmp } from '../bi/helpers.js';
2/**
3 * @name bnMax
4 * @summary Finds and returns the highest value in an array of BNs.
5 * @example
6 * <BR>
7 *
8 * ```javascript
9 * import BN from 'bn.js';
10 * import { bnMax } from '@polkadot/util';
11 *
12 * bnMax([new BN(1), new BN(3), new BN(2)]).toString(); // => '3'
13 * ```
14 */
15export const bnMax = /*#__PURE__*/ createCmp((a, b) => a.gt(b));
16/**
17 * @name bnMin
18 * @summary Finds and returns the smallest value in an array of BNs.
19 * @example
20 * <BR>
21 *
22 * ```javascript
23 * import BN from 'bn.js';
24 * import { bnMin } from '@polkadot/util';
25 *
26 * bnMin([new BN(1), new BN(3), new BN(2)]).toString(); // => '1'
27 * ```
28 */
29export const bnMin = /*#__PURE__*/ createCmp((a, b) => a.lt(b));
\No newline at end of file