UNPKG

@node-dlc/wire

Version:
34 lines 833 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Checksum = void 0; const checksum_1 = require("@node-dlc/checksum"); /** * CRC32C checksum for the provided value */ class Checksum { static fromBuffer(buf) { return new Checksum((0, checksum_1.crc32c)(buf)); } static empty() { return new Checksum(0); } constructor(checksum) { this._checksum = checksum; } equals(other) { return this._checksum === other._checksum; } toNumber() { return this._checksum; } toBuffer() { const buf = Buffer.alloc(4); buf.writeUInt32BE(this._checksum, 0); return buf; } toString() { return this._checksum.toString(16); } } exports.Checksum = Checksum; //# sourceMappingURL=Checksum.js.map