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

Function openAsBlob

lib/fs.js:711–727  ·  view source on GitHub ↗

* @param {string | Buffer | URL } path * @param {{ * type?: string; * }} [options] * @returns {Promise }

(path, options = kEmptyObject)

Source from the content-addressed store, hash-verified

709 * @returns {Promise<Blob>}
710 */
711function openAsBlob(path, options = kEmptyObject) {
712 validateObject(options, 'options');
713 const type = options.type || '';
714 validateString(type, 'options.type');
715
716 const h = vfsState.handlers;
717 if (h !== null) {
718 const result = h.openAsBlob(path, options);
719 if (result !== undefined) return PromiseResolve(result);
720 }
721
722 // The underlying implementation here returns the Blob synchronously for now.
723 // To give ourselves flexibility to maybe return the Blob asynchronously,
724 // this API returns a Promise.
725 path = getValidatedPath(path);
726 return PromiseResolve(createBlobFromFilePath(path, { type }));
727}
728
729/**
730 * Reads file from the specified `fd` (file descriptor).

Callers 1

Calls 2

createBlobFromFilePathFunction · 0.85
openAsBlobMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…