UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

27 lines (26 loc) 795 B
"use strict"; // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. Object.defineProperty(exports, "__esModule", { value: true }); class Varint { fileBytes; startIndex; byteLength = 0; value = 0; constructor(incomingBytes, startingIndex) { this.fileBytes = incomingBytes; this.startIndex = startingIndex; let i = 0; while (this.fileBytes[this.startIndex + i] >= 128 && this.startIndex + i < incomingBytes.length) { i++; } this.byteLength = i + 1; this.value = this.fileBytes[this.startIndex + i]; while (i > 0) { this.value *= 128; this.value += this.fileBytes[this.startIndex + i - 1] - 128; i--; } } } exports.default = Varint;