0 | module Node.FS.Static
3 | import Node.FS.ReadStream
5 | import Node.FS.Module
6 | import Node.Internal.Support
8 | %foreign "node:lambda: (fs,path)=>fs.createReadStream(path)"
9 | ffi_createReadStream : FSModule -> String -> PrimIO ReadStream
12 | (.createReadStream) : HasIO io => (fs : FSModule) -> String -> io ReadStream
13 | (.createReadStream) fs path = primIO $
ffi_createReadStream fs path
17 | (fs,rty,bigint,path) => {
19 | const result = fs.statSync(path, {
21 | throwIfNoEntry: true
24 | return _right(result);
30 | ffi_statSync : FSModule -> {r: StatsReturnType} -> (bigint : Bool) -> String -> PrimIO (Either Error $
Stats r)
33 | (.statSync) : HasIO io => (fs : FSModule) -> (r : StatsReturnType) -> String -> io (Either Error $
Stats r)
34 | (.statSync) fs r path = primIO $
ffi_statSync fs (isBigInt r) path
38 | (fs,rty,bigint,path,cb) => {
42 | (err, value) => cb()(err ? _left(err) : _right(value))
46 | ffi_stat : FSModule -> {r: StatsReturnType} -> (bigint : Bool) -> String -> (Either Error (Stats r) -> PrimIO()) -> PrimIO ()
49 | (.stat) : HasIO io => (fs : FSModule) -> (r: StatsReturnType) -> String -> (Either Error (Stats r) -> IO ()) -> io ()
50 | (.stat) fs r path cb = primIO $
ffi_stat fs (isBigInt r) path $
\either => toPrim $
cb either