UNPKG

749 BTypeScriptView Raw
1import type { U8aLike } from '../types.js';
2import { BN } from '../bn/index.js';
3/**
4 * @name compactFromU8a
5 * @description Retrives the offset and encoded length from a compact-prefixed value
6 * @example
7 * <BR>
8 *
9 * ```javascript
10 * import { compactFromU8a } from '@polkadot/util';
11 *
12 * const [offset, length] = compactFromU8a(new Uint8Array([254, 255, 3, 0]));
13 *
14 * console.log('value offset=', offset, 'length=', length); // 4, 0xffff
15 * ```
16 */
17export declare function compactFromU8a(input: U8aLike): [number, BN];
18/**
19 * @name compactFromU8aLim
20 * @description A limited version of [[compactFromU8a]], accepting only Uint8Array inputs for values <= 48 bits
21 */
22export declare function compactFromU8aLim(u8a: Uint8Array): [number, number];