Skip to content

Commit 64f777f

Browse files
committed
Add async exists
1 parent 576fc66 commit 64f777f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

examples/Test.purs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import Node.Encoding
1111

1212
main = do
1313

14+
A.exists "examples\\Test.purs" $ \e ->
15+
trace $ "Test.purs exists? " ++ show e
16+
1417
file <- S.readTextFile UTF8 "examples\\Test.purs"
1518
trace "\n\nreadTextFile sync result:"
1619
trace $ file

src/Node/FS/Async.purs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,3 +326,12 @@ appendTextFile :: forall eff. Encoding
326326

327327
appendTextFile encoding file buff cb = mkEff $ \_ -> runFn4
328328
fs.appendFile file buff { encoding: show encoding } (handleCallback cb)
329+
330+
-- |
331+
-- Check if the path exists.
332+
--
333+
exists :: forall eff. FilePath
334+
-> (Boolean -> Eff eff Unit)
335+
-> Eff (fs :: FS | eff) Unit
336+
exists file cb = mkEff $ \_ -> runFn2
337+
fs.exists file $ \b -> runPure (unsafeInterleaveEff (cb b))

0 commit comments

Comments
 (0)