@@ -18,26 +18,35 @@ class FileSystemDirectoryHandle extends FileSystemHandle {
1818 * @returns {Promise<FileSystemDirectoryHandle> }
1919 */
2020 async getDirectoryHandle ( name , options = { } ) {
21- if ( name === '' ) throw new TypeError ( `Name can't be an empty string.` )
22- if ( name === '.' || name === '..' || name . includes ( '/' ) ) throw new TypeError ( `Name contains invalid characters.` )
21+ if ( name === '' ) {
22+ throw new TypeError ( `Name can't be an empty string.` )
23+ }
24+ if ( name === '.' || name === '..' || name . includes ( '/' ) ) {
25+ throw new TypeError ( `Name contains invalid characters.` )
26+ }
2327 options . create = ! ! options . create
24- return new FileSystemDirectoryHandle ( await this [ kAdapter ] . getDirectoryHandle ( name , options ) )
28+ const handle = await this [ kAdapter ] . getDirectoryHandle ( name , options )
29+ return new FileSystemDirectoryHandle ( handle )
2530 }
2631
2732 /** @returns {AsyncGenerator<[string, FileSystemHandle | FileSystemDirectoryHandle]> } */
2833 async * entries ( ) {
2934 const { FileSystemFileHandle} = await import ( './FileSystemFileHandle.js' )
3035
3136 for await ( const [ _ , entry ] of this [ kAdapter ] . entries ( ) )
32- yield [ entry . name , entry . kind === 'file' ? new FileSystemFileHandle ( entry ) : new FileSystemDirectoryHandle ( entry ) ]
37+ yield [ entry . name , entry . kind === 'file'
38+ ? new FileSystemFileHandle ( entry )
39+ : new FileSystemDirectoryHandle ( entry ) ]
3340 }
3441
3542 /** @deprecated use .entries() instead */
3643 async * getEntries ( ) {
3744 const { FileSystemFileHandle} = await import ( './FileSystemFileHandle.js' )
3845 console . warn ( 'deprecated, use .entries() instead' )
3946 for await ( let entry of this [ kAdapter ] . entries ( ) )
40- yield entry . kind === 'file' ? new FileSystemFileHandle ( entry ) : new FileSystemDirectoryHandle ( entry )
47+ yield entry . kind === 'file'
48+ ? new FileSystemFileHandle ( entry )
49+ : new FileSystemDirectoryHandle ( entry )
4150 }
4251
4352 /**
@@ -48,9 +57,12 @@ class FileSystemDirectoryHandle extends FileSystemHandle {
4857 async getFileHandle ( name , options = { } ) {
4958 const { FileSystemFileHandle} = await import ( './FileSystemFileHandle.js' )
5059 if ( name === '' ) throw new TypeError ( `Name can't be an empty string.` )
51- if ( name === '.' || name === '..' || name . includes ( '/' ) ) throw new TypeError ( `Name contains invalid characters.` )
60+ if ( name === '.' || name === '..' || name . includes ( '/' ) ) {
61+ throw new TypeError ( `Name contains invalid characters.` )
62+ }
5263 options . create = ! ! options . create
53- return new FileSystemFileHandle ( await this [ kAdapter ] . getFileHandle ( name , options ) )
64+ const handle = await this [ kAdapter ] . getFileHandle ( name , options )
65+ return new FileSystemFileHandle ( handle )
5466 }
5567
5668 /**
@@ -59,13 +71,16 @@ class FileSystemDirectoryHandle extends FileSystemHandle {
5971 * @param {boolean } [options.recursive]
6072 */
6173 async removeEntry ( name , options = { } ) {
62- if ( name === '' ) throw new TypeError ( `Name can't be an empty string.` )
63- if ( name === '.' || name === '..' || name . includes ( '/' ) ) throw new TypeError ( `Name contains invalid characters.` )
74+ if ( name === '' ) {
75+ throw new TypeError ( `Name can't be an empty string.` )
76+ }
77+ if ( name === '.' || name === '..' || name . includes ( '/' ) ) {
78+ throw new TypeError ( `Name contains invalid characters.` )
79+ }
6480 options . recursive = ! ! options . recursive // cuz node's fs.rm require boolean
6581 return this [ kAdapter ] . removeEntry ( name , options )
6682 }
6783
68- // TODO: jsdoc
6984 async resolve ( possibleDescendant ) {
7085 if ( await possibleDescendant . isSameEntry ( this ) ) {
7186 return [ ]
0 commit comments