lib-utils-ts
Version:
<img src="https://img.shields.io/npm/v/lib-utils-ts"/> <img src="https://img.shields.io/snyk/vulnerabilities/npm/lib-utils-ts"/> <img src="https://img.shields.io/npm/l/lib-utils-ts"/> <img src="https://img.shields.io/github/languages/top/devGnode/lib-util
30 lines (22 loc) • 634 B
text/typescript
import {Reader} from "./Reader";
import {EOFException} from "./EOFException";
export class StringReader extends Reader{
private readonly target:string;
private index:number = 0;
constructor(value:string) {
super();
this.target = value;
}
public read(): number {
if(this.target[this.index]===undefined) throw new EOFException();
return this.target.charCodeAt(this.index++);
}
public readByte(buffer:string[], off:number = 0, length:number):number{
return 0;
}
ready(): boolean {
return false;
}
close(): void {}
}
Object.package(this);