(stream, cb, method)
| 69 | } |
| 70 | |
| 71 | function readWriteHelper(stream, cb, method) { |
| 72 | let nbytes; |
| 73 | try { |
| 74 | nbytes = handleEAGAIN(cb); |
| 75 | } catch (e) { |
| 76 | if (e && e.code && Module.ERRNO_CODES[e.code]) { |
| 77 | throw new FS.ErrnoError(Module.ERRNO_CODES[e.code]); |
| 78 | } |
| 79 | if (isErrnoError(e)) { |
| 80 | // the handler set an errno, propagate it |
| 81 | throw e; |
| 82 | } |
| 83 | console.error("Error thrown in read:"); |
| 84 | console.error(e); |
| 85 | throw new FS.ErrnoError(Module.ERRNO_CODES.EIO); |
| 86 | } |
| 87 | if (nbytes === undefined) { |
| 88 | // Prevent an infinite loop caused by incorrect code that doesn't return a |
| 89 | // value. |
| 90 | // Maybe we should set nbytes = buffer.length here instead? |
| 91 | console.warn( |
| 92 | `${method} returned undefined; a correct implementation must return a number`, |
| 93 | ); |
| 94 | throw new FS.ErrnoError(Module.ERRNO_CODES.EIO); |
| 95 | } |
| 96 | if (nbytes !== 0) { |
| 97 | stream.node.timestamp = Date.now(); |
| 98 | } |
| 99 | return nbytes; |
| 100 | } |
| 101 | |
| 102 | function asUint8Array(arg) { |
| 103 | if (ArrayBuffer.isView(arg)) { |
no test coverage detected
searching dependent graphs…