From d14acee42e3aa1868a20a34d43625e19a0725dd8 Mon Sep 17 00:00:00 2001 From: JordanMartinez Date: Wed, 27 Apr 2022 07:53:41 -0500 Subject: [PATCH] Fix stream write to include error callback (#41) * Update write callback to include error arg * Add changelog entry --- CHANGELOG.md | 1 + src/Node/Stream.purs | 6 +++--- test/Main.purs | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9b6757..af9c475 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Notable changes to this project are documented in this file. The format is based Breaking changes: - Update project and deps to PureScript v0.15.0 (#39 by @nwolverson, @JordanMartinez, @sigma-andex) +- Update `write` callback to include `Error` arg (#40 by @JordanMartinez) New features: diff --git a/src/Node/Stream.purs b/src/Node/Stream.purs index 6bfb776..ea3d7f4 100644 --- a/src/Node/Stream.purs +++ b/src/Node/Stream.purs @@ -254,7 +254,7 @@ foreign import write :: forall r . Writable r -> Buffer - -> Effect Unit + -> (Error -> Effect Unit) -> Effect Boolean foreign import writeStringImpl @@ -262,7 +262,7 @@ foreign import writeStringImpl . Writable r -> String -> String - -> Effect Unit + -> (Error -> Effect Unit) -> Effect Boolean -- | Write a string in the specified encoding to a writable stream. @@ -271,7 +271,7 @@ writeString . Writable r -> Encoding -> String - -> Effect Unit + -> (Error -> Effect Unit) -> Effect Boolean writeString w enc = writeStringImpl w (show enc) diff --git a/test/Main.purs b/test/Main.purs index 75d219e..c57c525 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -62,7 +62,7 @@ testReads = do assertEqual (unsafePartial (fromJust str)) testString pure unit - writeString sIn UTF8 testString do + writeString sIn UTF8 testString \_ -> do pure unit testReadBuf = do @@ -77,7 +77,7 @@ testReads = do <*> pure testString pure unit - writeString sIn UTF8 testString do + writeString sIn UTF8 testString \_ -> do pure unit testSetDefaultEncoding :: Effect Boolean @@ -91,7 +91,7 @@ testSetDefaultEncoding = do where check w = do - writeString w UTF8 testString do + writeString w UTF8 testString \_ -> do c <- getContentsAsString w assertEqual testString c @@ -128,7 +128,7 @@ testPipe = do log "pipe 3" _ <- unzip `pipe` sOut - writeString sIn UTF8 testString do + writeString sIn UTF8 testString \_ -> do end sIn do onDataString sOut UTF8 \str -> do assertEqual str testString