MCPcopy Index your code
hub / github.com/python/cpython / readWriteHelper

Function readWriteHelper

Platforms/emscripten/streams.mjs:71–100  ·  view source on GitHub ↗
(stream, cb, method)

Source from the content-addressed store, hash-verified

69}
70
71function 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
102function asUint8Array(arg) {
103 if (ArrayBuffer.isView(arg)) {

Callers 1

streams.mjsFile · 0.85

Calls 5

handleEAGAINFunction · 0.85
isErrnoErrorFunction · 0.85
nowMethod · 0.80
errorMethod · 0.45
warnMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…