UNPKG

beth-parser

Version:

Parser library for Bethesda's Creation Engine data files

34 lines 1.03 kB
"use strict"; exports.__esModule = true; /** * Simple Buffer based data source. */ var BufferSource = /** @class */ (function () { function BufferSource(buffer) { this.buffer = buffer; this.position = 0; } BufferSource.prototype.read = function (length) { var position = this.position; if (position + length > this.buffer.length) { throw new Error("EOF"); } this.position += length; return this.buffer.subarray(position, this.position); }; BufferSource.prototype.skip = function (length) { if (this.position + length > this.buffer.length) { throw new Error("EOF"); } this.position += length; }; BufferSource.prototype.close = function () { // nothing to close }; BufferSource.prototype.cursor = function () { return this.position; }; return BufferSource; }()); exports["default"] = BufferSource; //# sourceMappingURL=BufferSource.js.map