Skip to content

Commit

Permalink
Fix stream write to include error callback (#41)
Browse files Browse the repository at this point in the history
* Update write callback to include error arg

* Add changelog entry
  • Loading branch information
JordanMartinez authored Apr 27, 2022
1 parent f100d2f commit d14acee
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
6 changes: 3 additions & 3 deletions src/Node/Stream.purs
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,15 @@ foreign import write
:: forall r
. Writable r
-> Buffer
-> Effect Unit
-> (Error -> Effect Unit)
-> Effect Boolean

foreign import writeStringImpl
:: forall r
. Writable r
-> String
-> String
-> Effect Unit
-> (Error -> Effect Unit)
-> Effect Boolean

-- | Write a string in the specified encoding to a writable stream.
Expand All @@ -271,7 +271,7 @@ writeString
. Writable r
-> Encoding
-> String
-> Effect Unit
-> (Error -> Effect Unit)
-> Effect Boolean
writeString w enc = writeStringImpl w (show enc)

Expand Down
8 changes: 4 additions & 4 deletions test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d14acee

Please sign in to comment.