* @param {string | Buffer | URL } path * @param {{ * type?: string; * }} [options] * @returns {Promise }
(path, options = kEmptyObject)
| 709 | * @returns {Promise<Blob>} |
| 710 | */ |
| 711 | function 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). |
no test coverage detected
searching dependent graphs…