2 Commits

Author SHA1 Message Date
e1c2481e70 chore: prepare v1.3.3 2024-05-13 14:42:48 -05:00
820351f800 fix: more yields 2024-05-13 14:42:23 -05:00
3 changed files with 12 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "purescript-node-stream-pipes",
"version": "v1.3.2",
"version": "v1.3.3",
"type": "module",
"dependencies": {
"csv-parse": "^5.5.5",

View File

@@ -1,7 +1,7 @@
package:
name: node-stream-pipes
publish:
version: '1.3.2'
version: '1.3.3'
license: 'GPL-3.0-or-later'
location:
githubOwner: 'cakekindel'

View File

@@ -94,17 +94,21 @@ fromTransform t =
liftEffect $ removeErrorListener
fromReadable t
pure $ Done unit
yieldFromReadableHalf = do
res <- liftEffect (O.read t)
case res of
O.ReadJust a -> yield (Just a) *> yieldFromReadableHalf
O.ReadWouldBlock -> pure unit
O.ReadClosed -> yield Nothing *> pure unit
yieldFromReadableHalf =
flip tailRecM unit $ const do
res <- liftEffect (O.read t)
case res of
O.ReadJust a -> do
yield $ Just a
pure $ Loop unit
O.ReadWouldBlock -> pure $ Done unit
O.ReadClosed -> yield Nothing $> Done unit
go { error, cancel } = do
liftAff $ delay $ wrap 0.0
err <- liftEffect $ liftST $ STRef.read error
for_ err throwError
yieldFromReadableHalf
ma <- await
case ma of
Nothing -> cleanup cancel