index.js 1.6 KB

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