Skip to content

Commit d14acee

Browse files
Fix stream write to include error callback (#41)
* Update write callback to include error arg * Add changelog entry
1 parent f100d2f commit d14acee

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Notable changes to this project are documented in this file. The format is based
66

77
Breaking changes:
88
- Update project and deps to PureScript v0.15.0 (#39 by @nwolverson, @JordanMartinez, @sigma-andex)
9+
- Update `write` callback to include `Error` arg (#40 by @JordanMartinez)
910

1011
New features:
1112

src/Node/Stream.purs

+3-3
Original file line numberDiff line numberDiff line change
@@ -254,15 +254,15 @@ foreign import write
254254
:: forall r
255255
. Writable r
256256
-> Buffer
257-
-> Effect Unit
257+
-> (Error -> Effect Unit)
258258
-> Effect Boolean
259259

260260
foreign import writeStringImpl
261261
:: forall r
262262
. Writable r
263263
-> String
264264
-> String
265-
-> Effect Unit
265+
-> (Error -> Effect Unit)
266266
-> Effect Boolean
267267

268268
-- | Write a string in the specified encoding to a writable stream.
@@ -271,7 +271,7 @@ writeString
271271
. Writable r
272272
-> Encoding
273273
-> String
274-
-> Effect Unit
274+
-> (Error -> Effect Unit)
275275
-> Effect Boolean
276276
writeString w enc = writeStringImpl w (show enc)
277277

test/Main.purs

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ testReads = do
6262
assertEqual (unsafePartial (fromJust str)) testString
6363
pure unit
6464

65-
writeString sIn UTF8 testString do
65+
writeString sIn UTF8 testString \_ -> do
6666
pure unit
6767

6868
testReadBuf = do
@@ -77,7 +77,7 @@ testReads = do
7777
<*> pure testString
7878
pure unit
7979

80-
writeString sIn UTF8 testString do
80+
writeString sIn UTF8 testString \_ -> do
8181
pure unit
8282

8383
testSetDefaultEncoding :: Effect Boolean
@@ -91,7 +91,7 @@ testSetDefaultEncoding = do
9191

9292
where
9393
check w = do
94-
writeString w UTF8 testString do
94+
writeString w UTF8 testString \_ -> do
9595
c <- getContentsAsString w
9696
assertEqual testString c
9797

@@ -128,7 +128,7 @@ testPipe = do
128128
log "pipe 3"
129129
_ <- unzip `pipe` sOut
130130

131-
writeString sIn UTF8 testString do
131+
writeString sIn UTF8 testString \_ -> do
132132
end sIn do
133133
onDataString sOut UTF8 \str -> do
134134
assertEqual str testString

0 commit comments

Comments
 (0)