var System= core.System // ESto se hizo para reescribir el código de la clase BinaryReader // quitar validaciones no necesarioas y añadir soporte asíncrono class BinaryReader/* extends System.IO.Stream*/{ constructor(stream, encoding){ if(!(stream instanceof System.IO.Stream)){ throw new Error("El argumento stream debe ser del tipo System.IO.Stream"); } this.$stream=stream; this.baseStream=stream; this.$fbuf=new Buffer(16); if(!encoding){ encoding= System.Text.Encoding.utf8; } this.$encoding=this.encoding=encoding; } readByte(){ if(this.$stream.read(this.$fbuf, 0, 1)<1){ throw new Error("Se intentó leer más allá de la longitud") } return this.$fbuf[0] } async readByteAsync(){ if((await this.$stream.readAsync(this.$fbuf, 0, 1))<1){ throw new Error("Se intentó leer más allá de la longitud") } return this.$fbuf[0] } readBoolean(){ return !!this.readByte() } async readBooleanAsync(){ return !!(await this.readByte()) } readSbyte(){ if(this.$stream.read(this.$fbuf, 0, 1)<1){ throw new Error("Se intentó leer más allá de la longitud") } return this.$fbuf.readInt8(0) } async readSbyteAsync(){ if((await this.$stream.readAsync(this.$fbuf, 0, 1))<1){ throw new Error("Se intentó leer más allá de la longitud") } return this.$fbuf.readInt8(0) } readBytes(count){ var buf=new Buffer(count) if(this.$stream.read(buf, 0, count)