diff --git a/src/Pipes.Node.Stream.purs b/src/Pipes.Node.Stream.purs index 2de43db..f67626a 100644 --- a/src/Pipes.Node.Stream.purs +++ b/src/Pipes.Node.Stream.purs @@ -96,6 +96,7 @@ fromTransform t = pure $ Done unit yieldFromReadableHalf = flip tailRecM unit $ const do + liftAff $ delay $ wrap 0.0 res <- liftEffect (O.read t) case res of O.ReadJust a -> do diff --git a/src/Pipes.Util.purs b/src/Pipes.Util.purs index 635196d..563bca4 100644 --- a/src/Pipes.Util.purs +++ b/src/Pipes.Util.purs @@ -85,9 +85,10 @@ chunked size = do Rec.whileJust $ runMaybeT do a <- MaybeT await chunkPut a - len <- chunkLength + len <- lift chunkLength when (len >= size) $ lift $ yield =<< Just <$> chunkTake - yield =<< Just <$> chunkTake + len <- chunkLength + when (len > 0) $ yield =<< Just <$> chunkTake yield Nothing -- | Equivalent of unix `uniq`, filtering out duplicate values passed to it.