UNPKG

typesxml

Version:

Open source XML library written in TypeScript

40 lines 1.31 kB
"use strict"; /******************************************************************************* * Copyright (c) 2023-2026 Maxprograms. * * This program and the accompanying materials * are made available under the terms of the Eclipse License 1.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/org/documents/epl-v10.html * * Contributors: * Maxprograms - initial API and implementation *******************************************************************************/ Object.defineProperty(exports, "__esModule", { value: true }); exports.StringReader = void 0; class StringReader { data; offset = 0; chunkSize; constructor(data, chunkSize = 8192) { this.data = data; this.chunkSize = Math.max(chunkSize, 1); } read() { if (!this.dataAvailable()) { return ''; } const nextOffset = Math.min(this.offset + this.chunkSize, this.data.length); const chunk = this.data.substring(this.offset, nextOffset); this.offset = nextOffset; return chunk; } dataAvailable() { return this.offset < this.data.length; } closeFile() { // no resources to release } } exports.StringReader = StringReader; //# sourceMappingURL=StringReader.js.map