fix: Pipes.Node.FS.read'
This commit is contained in:
parent
54d9d57927
commit
1a5ca66e83
@ -8,7 +8,7 @@ import Effect.Aff.Class (class MonadAff)
|
|||||||
import Effect.Class (liftEffect)
|
import Effect.Class (liftEffect)
|
||||||
import Effect.Exception (Error)
|
import Effect.Exception (Error)
|
||||||
import Node.Buffer (Buffer)
|
import Node.Buffer (Buffer)
|
||||||
import Node.FS.Stream (WriteStreamOptions)
|
import Node.FS.Stream (WriteStreamOptions, ReadStreamOptions)
|
||||||
import Node.FS.Stream as FS.Stream
|
import Node.FS.Stream as FS.Stream
|
||||||
import Node.Path (FilePath)
|
import Node.Path (FilePath)
|
||||||
import Node.Stream.Object as O
|
import Node.Stream.Object as O
|
||||||
@ -61,3 +61,19 @@ read :: forall m. MonadAff m => MonadThrow Error m => FilePath -> Producer (Mayb
|
|||||||
read p = do
|
read p = do
|
||||||
r <- liftEffect $ FS.Stream.createReadStream p
|
r <- liftEffect $ FS.Stream.createReadStream p
|
||||||
fromReadable $ O.fromBufferReadable r
|
fromReadable $ O.fromBufferReadable r
|
||||||
|
|
||||||
|
-- | Creates a `fs.Readable` stream for the file at the given path.
|
||||||
|
-- |
|
||||||
|
-- | Emits `Nothing` before closing. To opt out of this behavior,
|
||||||
|
-- | use `Pipes.Node.Stream.withoutEOS` or `Pipes.Node.Stream.unEOS`.
|
||||||
|
read'
|
||||||
|
:: forall r trash m
|
||||||
|
. Union r trash ReadStreamOptions
|
||||||
|
=> MonadAff m
|
||||||
|
=> MonadThrow Error m
|
||||||
|
=> Record r
|
||||||
|
-> FilePath
|
||||||
|
-> Producer (Maybe Buffer) m Unit
|
||||||
|
read' opts p = do
|
||||||
|
r <- liftEffect $ FS.Stream.createReadStream' p opts
|
||||||
|
fromReadable $ O.fromBufferReadable r
|
||||||
|
Loading…
Reference in New Issue
Block a user