UNPKG

734 BTypeScriptView Raw
1/// <reference types="bn.js" />
2import type { NumberOptions, ToBn } from '../types.js';
3import type { BN } from './bn.js';
4/**
5 * @name bnToU8a
6 * @summary Creates a Uint8Array object from a BN.
7 * @description
8 * `null`/`undefined`/`NaN` inputs returns an empty `Uint8Array` result. `BN` input values return the actual bytes value converted to a `Uint8Array`. Optionally convert using little-endian format if `isLE` is set.
9 * @example
10 * <BR>
11 *
12 * ```javascript
13 * import { bnToU8a } from '@polkadot/util';
14 *
15 * bnToU8a(new BN(0x1234)); // => [0x12, 0x34]
16 * ```
17 */
18export declare function bnToU8a<ExtToBn extends ToBn>(value?: ExtToBn | BN | bigint | number | null, { bitLength, isLe, isNegative }?: NumberOptions): Uint8Array;