You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 932B

12345678910111213141516171819202122232425262728293031323334
  1. import leb from "./leb";
  2. /**
  3. * According to https://webassembly.github.io/spec/core/binary/values.html#binary-int
  4. * max = ceil(32/7)
  5. */
  6. export var MAX_NUMBER_OF_BYTE_U32 = 5;
  7. /**
  8. * According to https://webassembly.github.io/spec/core/binary/values.html#binary-int
  9. * max = ceil(64/7)
  10. */
  11. export var MAX_NUMBER_OF_BYTE_U64 = 10;
  12. export function decodeInt64(encodedBuffer, index) {
  13. return leb.decodeInt64(encodedBuffer, index);
  14. }
  15. export function decodeUInt64(encodedBuffer, index) {
  16. return leb.decodeUInt64(encodedBuffer, index);
  17. }
  18. export function decodeInt32(encodedBuffer, index) {
  19. return leb.decodeInt32(encodedBuffer, index);
  20. }
  21. export function decodeUInt32(encodedBuffer, index) {
  22. return leb.decodeUInt32(encodedBuffer, index);
  23. }
  24. export function encodeU32(v) {
  25. return leb.encodeUInt32(v);
  26. }
  27. export function encodeI32(v) {
  28. return leb.encodeInt32(v);
  29. }
  30. export function encodeI64(v) {
  31. return leb.encodeInt64(v);
  32. }