pushInt method

void pushInt(
  1. int majorTag,
  2. int value
)

Append an integer value with a specified major tag to the byte sequence in the buffer.

Implementation

void pushInt(
  int majorTag,
  int value,
) {
  majorTag <<= 5;
  if (value < 24) {
    pushUInt8(majorTag | value);
    return;
  } else if (value <= mask8) {
    pushUInt8(majorTag | NumBytes.one);
    pushUInt8(value);
    return;
  } else if (value <= mask16) {
    pushUInt8(majorTag | NumBytes.two);
    pushUint16Be(value);
  } else if (value <= mask32) {
    pushUInt8(majorTag | NumBytes.four);
    pushUint32Be(value);
  } else {
    pushUInt8(majorTag | NumBytes.eight);
    pushBigint(BigInt.from(value));
  }
}