@@ -20,8 +20,12 @@ module Node.FS.Async
20
20
, unlink
21
21
, rmdir
22
22
, rmdir'
23
+ , rmdirOptionsDefault
24
+ , RmdirOptions
23
25
, rm
24
26
, rm'
27
+ , rmOptionsDefault
28
+ , RmOptions
25
29
, mkdir
26
30
, mkdir'
27
31
, readdir
@@ -65,8 +69,10 @@ module Node.FS.Async
65
69
, lchown
66
70
, lutimes
67
71
-- , openAsBlob
68
- , opendir'
69
72
, opendir
73
+ , opendir'
74
+ , OpendirOptions
75
+ , opendirOptionsDefault
70
76
, readv
71
77
, statfs
72
78
-- , unwatchFile
@@ -158,8 +164,8 @@ foreign import symlinkImpl :: EffectFn4 FilePath FilePath (Nullable String) (JSC
158
164
foreign import readlinkImpl :: EffectFn2 FilePath (JSCallback FilePath ) Unit
159
165
foreign import realpathImpl :: forall cache . EffectFn3 FilePath { | cache } (JSCallback FilePath ) Unit
160
166
foreign import unlinkImpl :: EffectFn2 FilePath (JSCallback Unit ) Unit
161
- foreign import rmdirImpl :: EffectFn3 FilePath { maxRetries :: Int , retryDelay :: Int } (JSCallback Unit ) Unit
162
- foreign import rmImpl :: EffectFn3 FilePath { force :: Boolean , maxRetries :: Int , recursive :: Boolean , retryDelay :: Int } (JSCallback Unit ) Unit
167
+ foreign import rmdirImpl :: EffectFn3 FilePath RmdirOptions (JSCallback Unit ) Unit
168
+ foreign import rmImpl :: EffectFn3 FilePath RmOptions (JSCallback Unit ) Unit
163
169
foreign import mkdirImpl :: EffectFn3 FilePath { recursive :: Boolean , mode :: String } (JSCallback Unit ) Unit
164
170
-- if { withFileTypes: false, recursive: false } => ['Tidy']
165
171
-- if { withFileTypes: false, recursive: true } => [ 'Tidy', 'Tidy/Codegen', 'Tidy/Codegen.purs', 'Tidy/Codegen/Class.purs', .. ]
@@ -290,32 +296,42 @@ unlink
290
296
-> Effect Unit
291
297
unlink file cb = runEffectFn2 unlinkImpl file (handleCallback cb)
292
298
299
+ type RmdirOptions = { maxRetries :: Int , retryDelay :: Int }
300
+
301
+ rmdirOptionsDefault :: RmdirOptions
302
+ rmdirOptionsDefault = { maxRetries: 0 , retryDelay: 100 }
303
+
293
304
-- | Deletes a directory.
294
305
rmdir
295
306
:: FilePath
296
307
-> Callback Unit
297
308
-> Effect Unit
298
- rmdir path cb = rmdir' path { maxRetries: 0 , retryDelay: 100 } cb
309
+ rmdir path cb = rmdir' path rmdirOptionsDefault cb
299
310
300
311
-- | Deletes a directory with options.
301
312
rmdir'
302
313
:: FilePath
303
- -> { maxRetries :: Int , retryDelay :: Int }
314
+ -> RmdirOptions
304
315
-> Callback Unit
305
316
-> Effect Unit
306
317
rmdir' path opts cb = runEffectFn3 rmdirImpl path opts (handleCallback cb)
307
318
319
+ type RmOptions = { force :: Boolean , maxRetries :: Int , recursive :: Boolean , retryDelay :: Int }
320
+
321
+ rmOptionsDefault :: RmOptions
322
+ rmOptionsDefault = { force: false , maxRetries: 100 , recursive: false , retryDelay: 1000 }
323
+
308
324
-- | Deletes a file or directory.
309
325
rm
310
326
:: FilePath
311
327
-> Callback Unit
312
328
-> Effect Unit
313
- rm path = rm' path { force: false , maxRetries: 100 , recursive: false , retryDelay: 1000 }
329
+ rm path = rm' path rmOptionsDefault
314
330
315
331
-- | Deletes a file or directory with options.
316
332
rm'
317
333
:: FilePath
318
- -> { force :: Boolean , maxRetries :: Int , recursive :: Boolean , retryDelay :: Int }
334
+ -> RmOptions
319
335
-> Callback Unit
320
336
-> Effect Unit
321
337
rm' path opts cb = runEffectFn3 rmImpl path opts (handleCallback cb)
@@ -655,16 +671,21 @@ lutimes file atime mtime cb = runEffectFn4 lutimesImpl file (datetimeToUnixEpoch
655
671
-- openAsBlob :: FilePath -> Promise Blob -> Effect Unit
656
672
-- openAsBlob path cb = runEffectFn2 openAsBlobImpl path (handleCallback cb)
657
673
674
+ type OpendirOptions = { encoding :: Encoding , bufferSize :: Int , recursive :: Boolean }
675
+
676
+ opendirOptionsDefault :: OpendirOptions
677
+ opendirOptionsDefault = { bufferSize: 32 , recursive: false , encoding: UTF8 }
678
+
658
679
-- | Open a directory. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_opendir_path_options_callback)
659
680
-- | for details.
660
- opendir' :: FilePath -> { encoding :: Encoding , bufferSize :: Int , recursive :: Boolean } -> Callback Dir -> Effect Unit
681
+ opendir' :: FilePath -> OpendirOptions -> Callback Dir -> Effect Unit
661
682
opendir' path { encoding, bufferSize, recursive } cb = runEffectFn3 opendirImpl path { encoding: encodingToNode encoding, bufferSize, recursive } (handleCallback cb)
662
683
663
684
-- | Open a directory. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_opendir_path_options_callback)
664
685
-- | for details.
665
686
-- | NOTE: encoding: 'buffer' is not supported, will throw error "TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Buffer"
666
687
opendir :: FilePath -> Callback Dir -> Effect Unit
667
- opendir path = opendir' path { bufferSize: 32 , recursive: false , encoding: UTF8 }
688
+ opendir path = opendir' path opendirOptionsDefault
668
689
669
690
-- | Read from a file descriptor into a buffer array. See the [Node Documentation](https://nodejs.org/api/fs.html#fs_fs_readv_fd_buffers_position_callback)
670
691
-- | for details.
0 commit comments