Node.FS wrappers for purescript-aff.
The Aff monad lets you write async code with ease, and node-fs-aff lets you easily access the filesystem within Aff.
spago install node-fs-aff
Consider asynchronously listing only non-hidden directories:
main = launchAff do
files <- FS.readdir "."
files' <- flip filterM files \file -> do
stat <- FS.stat file
pure $
FS.isDirectory stat
&& (maybe false (fromChar >>> (/= ".")) $ charAt 0 file)
liftEff $ print files'That was easy. Run npm run example to see it work.
Module documentation is published on Pursuit.