UNPKG

1.94 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.compactToU8a = exports.compactStripLength = exports.compactFromU8aLim = exports.compactFromU8a = exports.compactAddLength = void 0;
4/**
5 * @description
6 * Encoding and decoding of parity-codec compact numbers. The codec is created
7 * to take up the least amount of space for a specific number. It performs the
8 * same function as Length, however differs in that it uses a variable number of
9 * bytes to do the actual encoding. From the Rust implementation for compact
10 * encoding:
11 *
12 * 0b00 00 00 00 / 00 00 00 00 / 00 00 00 00 / 00 00 00 00
13 * (0 ... 2**6 - 1) (u8)
14 * xx xx xx 00
15 * (2**6 ... 2**14 - 1) (u8, u16) low LH high
16 * yL yL yL 01 / yH yH yH yL
17 * (2**14 ... 2**30 - 1) (u16, u32) low LMMH high
18 * zL zL zL 10 / zM zM zM zL / zM zM zM zM / zH zH zH zM
19 * (2**30 ... 2**536 - 1) (u32, u64, u128, U256, U512, U520) straight LE-encoded
20 * nn nn nn 11 [ / zz zz zz zz ]{4 + n}
21 *
22 * Note: we use *LOW BITS* of the LSB in LE encoding to encode the 2 bit key.
23 */
24var addLength_js_1 = require("./addLength.js");
25Object.defineProperty(exports, "compactAddLength", { enumerable: true, get: function () { return addLength_js_1.compactAddLength; } });
26var fromU8a_js_1 = require("./fromU8a.js");
27Object.defineProperty(exports, "compactFromU8a", { enumerable: true, get: function () { return fromU8a_js_1.compactFromU8a; } });
28Object.defineProperty(exports, "compactFromU8aLim", { enumerable: true, get: function () { return fromU8a_js_1.compactFromU8aLim; } });
29var stripLength_js_1 = require("./stripLength.js");
30Object.defineProperty(exports, "compactStripLength", { enumerable: true, get: function () { return stripLength_js_1.compactStripLength; } });
31var toU8a_js_1 = require("./toU8a.js");
32Object.defineProperty(exports, "compactToU8a", { enumerable: true, get: function () { return toU8a_js_1.compactToU8a; } });