UNPKG

1.59 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.decodeInt64 = decodeInt64;
7exports.decodeUInt64 = decodeUInt64;
8exports.decodeInt32 = decodeInt32;
9exports.decodeUInt32 = decodeUInt32;
10exports.encodeU32 = encodeU32;
11exports.encodeI32 = encodeI32;
12exports.encodeI64 = encodeI64;
13exports.MAX_NUMBER_OF_BYTE_U64 = exports.MAX_NUMBER_OF_BYTE_U32 = void 0;
14
15var _leb = _interopRequireDefault(require("./leb"));
16
17function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
18
19/**
20 * According to https://webassembly.github.io/spec/core/binary/values.html#binary-int
21 * max = ceil(32/7)
22 */
23var MAX_NUMBER_OF_BYTE_U32 = 5;
24/**
25 * According to https://webassembly.github.io/spec/core/binary/values.html#binary-int
26 * max = ceil(64/7)
27 */
28
29exports.MAX_NUMBER_OF_BYTE_U32 = MAX_NUMBER_OF_BYTE_U32;
30var MAX_NUMBER_OF_BYTE_U64 = 10;
31exports.MAX_NUMBER_OF_BYTE_U64 = MAX_NUMBER_OF_BYTE_U64;
32
33function decodeInt64(encodedBuffer, index) {
34 return _leb["default"].decodeInt64(encodedBuffer, index);
35}
36
37function decodeUInt64(encodedBuffer, index) {
38 return _leb["default"].decodeUInt64(encodedBuffer, index);
39}
40
41function decodeInt32(encodedBuffer, index) {
42 return _leb["default"].decodeInt32(encodedBuffer, index);
43}
44
45function decodeUInt32(encodedBuffer, index) {
46 return _leb["default"].decodeUInt32(encodedBuffer, index);
47}
48
49function encodeU32(v) {
50 return _leb["default"].encodeUInt32(v);
51}
52
53function encodeI32(v) {
54 return _leb["default"].encodeInt32(v);
55}
56
57function encodeI64(v) {
58 return _leb["default"].encodeInt64(v);
59}
\No newline at end of file