typesxml
Version:
Open source XML library written in TypeScript
36 lines • 1.17 kB
JavaScript
/*******************************************************************************
* 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
*******************************************************************************/
export 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
}
}
//# sourceMappingURL=StringReader.js.map