MCPcopy Index your code
hub / github.com/nodejs/node / arrayBuffer

Function arrayBuffer

lib/internal/blob.js:415–441  ·  view source on GitHub ↗
(blob)

Source from the content-addressed store, hash-verified

413}
414
415function arrayBuffer(blob) {
416 const { promise, resolve, reject } = PromiseWithResolvers();
417 const reader = blob[kHandle].getReader();
418 const buffers = [];
419 const readNext = () => {
420 reader.pull((status, buffer) => {
421 if (status === 0) {
422 // EOS, concat & resolve
423 // buffer should be undefined here
424 resolve(concat(buffers));
425 return;
426 } else if (status < 0) {
427 // The read could fail for many different reasons when reading
428 // from a non-memory resident blob part (e.g. file-backed blob).
429 // The error details the system error code.
430 const error = lazyDOMException('The blob could not be read', 'NotReadableError');
431 reject(error);
432 return;
433 }
434 if (buffer !== undefined)
435 buffers.push(buffer);
436 queueMicrotask(() => readNext());
437 });
438 };
439 readNext();
440 return promise;
441}
442
443function createBlobReaderStream(reader) {
444 return new lazyReadableStream({

Callers 7

arrayBufferMethod · 0.70
textMethod · 0.70
bytesMethod · 0.70
testArrayBufferAsyncFunction · 0.50
testAsyncValidationFunction · 0.50
testArrayBufferAsyncSABFunction · 0.50

Calls 2

readNextFunction · 0.85
getReaderMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…