MCPcopy Create free account
hub / github.com/di-sukharev/opencommit / read

Method read

out/cli.cjs:11920–11969  ·  view source on GitHub ↗
(view, rawOptions = {})

Source from the content-addressed store, hash-verified

11918 return ReadableStreamReaderGenericCancel(this, reason);
11919 }
11920 read(view, rawOptions = {}) {
11921 if (!IsReadableStreamBYOBReader(this)) {
11922 return promiseRejectedWith(byobReaderBrandCheckException("read"));
11923 }
11924 if (!ArrayBuffer.isView(view)) {
11925 return promiseRejectedWith(new TypeError("view must be an array buffer view"));
11926 }
11927 if (view.byteLength === 0) {
11928 return promiseRejectedWith(new TypeError("view must have non-zero byteLength"));
11929 }
11930 if (view.buffer.byteLength === 0) {
11931 return promiseRejectedWith(new TypeError(`view's buffer must have non-zero byteLength`));
11932 }
11933 if (IsDetachedBuffer(view.buffer)) {
11934 return promiseRejectedWith(new TypeError("view's buffer has been detached"));
11935 }
11936 let options;
11937 try {
11938 options = convertByobReadOptions(rawOptions, "options");
11939 } catch (e3) {
11940 return promiseRejectedWith(e3);
11941 }
11942 const min = options.min;
11943 if (min === 0) {
11944 return promiseRejectedWith(new TypeError("options.min must be greater than 0"));
11945 }
11946 if (!isDataView(view)) {
11947 if (min > view.length) {
11948 return promiseRejectedWith(new RangeError("options.min must be less than or equal to view's length"));
11949 }
11950 } else if (min > view.byteLength) {
11951 return promiseRejectedWith(new RangeError("options.min must be less than or equal to view's byteLength"));
11952 }
11953 if (this._ownerReadableStream === void 0) {
11954 return promiseRejectedWith(readerLockException("read from"));
11955 }
11956 let resolvePromise;
11957 let rejectPromise;
11958 const promise = newPromise((resolve, reject) => {
11959 resolvePromise = resolve;
11960 rejectPromise = reject;
11961 });
11962 const readIntoRequest = {
11963 _chunkSteps: (chunk) => resolvePromise({ value: chunk, done: false }),
11964 _closeSteps: (chunk) => resolvePromise({ value: chunk, done: true }),
11965 _errorSteps: (e3) => rejectPromise(e3)
11966 };
11967 ReadableStreamBYOBReaderRead(this, view, min, readIntoRequest);
11968 return promise;
11969 }
11970 /**
11971 * Releases the reader's lock on the corresponding stream. After the lock is released, the reader is no longer active.
11972 * If the associated stream is errored when the lock is released, the reader will appear errored in the same way

Callers

nothing calls this directly

Calls 10

promiseRejectedWithFunction · 0.85
IsDetachedBufferFunction · 0.85
convertByobReadOptionsFunction · 0.85
isDataViewFunction · 0.85
readerLockExceptionFunction · 0.85
newPromiseFunction · 0.85
rejectPromiseFunction · 0.85

Tested by

no test coverage detected