@@ -1446,29 +1446,18 @@ export class Volume implements FsCallbackApi, FsSynchronousApi {
14461446 public statfsSync : FsSynchronousApi [ 'statfsSync' ] = notImplemented ;
14471447 /** @todo Implement statfs */
14481448 public statfs : FsCallbackApi [ 'statfs' ] = notImplemented ;
1449- private readonly _openAsBlob = ( filename : string , options : opts . IOpenAsBlobOptions = { } ) : Blob => {
1449+ public openAsBlob = async ( path : PathLike , options ?: opts . IOpenAsBlobOptions ) : Promise < Blob > => {
1450+ const filename = pathToFilename ( path ) ;
14501451 const link = this . _core . getResolvedLinkOrThrow ( filename , 'open' ) ;
14511452 const node = link . getNode ( ) ;
14521453 if ( node . isDirectory ( ) ) throw createError ( ERROR_CODE . EISDIR , 'open' , link . getPath ( ) ) ;
14531454
14541455 const buffer = node . getBuffer ( ) ;
1455- const type = options . type || '' ;
1456+ const type = options ? .type || '' ;
14561457
14571458 return new Blob ( [ buffer ] , { type } ) ;
14581459 } ;
14591460
1460- public openAsBlob = ( path : PathLike , options ?: opts . IOpenAsBlobOptions ) : Promise < Blob > => {
1461- return new Promise ( ( resolve , reject ) => {
1462- try {
1463- const filename = pathToFilename ( path ) ;
1464- const blob = this . _openAsBlob ( filename , options ) ;
1465- resolve ( blob ) ;
1466- } catch ( err ) {
1467- reject ( err ) ;
1468- }
1469- } ) ;
1470- } ;
1471-
14721461 private readonly _opendir = ( filename : string , options : opts . IOpendirOptions ) : Dir => {
14731462 const link : Link = this . _core . getResolvedLinkOrThrow ( filename , 'scandir' ) ;
14741463 const node = link . getNode ( ) ;
0 commit comments