UNPKG

@animech-public/playcanvas

Version:
2 lines (1 loc) 1 kB
class t{constructor(t){this.arraybuffer=void 0,this.dataView=void 0,this.offset=0,this.arraybuffer=t,this.dataView=new DataView(t)}get remainingBytes(){return this.dataView.byteLength-this.offset}reset(t=0){this.offset=t}skip(t){this.offset+=t}align(t){this.offset=this.offset+t-1&~(t-1)}_inc(t){return this.offset+=t,this.offset-t}readChar(){return String.fromCharCode(this.dataView.getUint8(this.offset++))}readChars(t){let e="";for(let r=0;r<t;++r)e+=this.readChar();return e}readU8(){return this.dataView.getUint8(this.offset++)}readU16(){return this.dataView.getUint16(this._inc(2),!0)}readU32(){return this.dataView.getUint32(this._inc(4),!0)}readU64(){return this.readU32()+2**32*this.readU32()}readU32be(){return this.dataView.getUint32(this._inc(4),!1)}readArray(t){for(let e=0;e<t.length;++e)t[e]=this.readU8()}readLine(){const t=this.dataView;let e="";for(;!(this.offset>=t.byteLength);){const t=String.fromCharCode(this.readU8());if("\n"===t)break;e+=t}return e}}export{t as ReadStream};