UNPKG

@runejs/common

Version:

Common logging, networking, compression, and other miscellaneous functionality for RuneJS.

31 lines 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Crc32 = void 0; class Crc32 { static update(offset, size, data) { let crc = -1; for (let currentByte = offset; currentByte < size; currentByte++) { const tableIndex = 0xff & (crc ^ data[currentByte]); crc = this.crcLookupTable[tableIndex] ^ crc >>> 8; } crc ^= 0xffffffff; return crc; } static init() { for (let i = 0; i < 256; i++) { let currentByte = i; for (let bit = 0; bit < 8; bit++) { if ((currentByte & 0x1) !== 1) { currentByte >>>= 1; } else { currentByte = -306674912 ^ currentByte >>> 1; } } this.crcLookupTable[i] = currentByte; } } } exports.Crc32 = Crc32; Crc32.crcLookupTable = new Array(256); //# sourceMappingURL=crc32.js.map