Skip to content

Commit d73fa50

Browse files
committed
Improve docs
1 parent 0bb57f0 commit d73fa50

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/Node/Stream.purs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ type Duplex = Stream (read :: Read, write :: Write)
5858

5959
foreign import setEncodingImpl :: forall w eff. Readable w eff -> String -> Eff eff Unit
6060

61-
-- | Set the encoding used to read chunks as strings from the stream.
61+
-- | Set the encoding used to read chunks as strings from the stream. This
62+
-- | function is useful when you are passing a readable stream to some other
63+
-- | JavaScript library, which already expects an encoding to be set. It
64+
-- | has no effect on the behaviour of the `onDataString` function (because
65+
-- | that function ensures that the encoding is always supplied explicitly).
6266
setEncoding :: forall w eff. Readable w eff -> Encoding -> Eff eff Unit
6367
setEncoding r enc = setEncodingImpl r (show enc)
6468

@@ -68,8 +72,8 @@ foreign import onDataImpl :: forall w eff a. Readable w eff -> (a -> Eff eff Uni
6872
onData :: forall w eff. Readable w eff -> (Buffer -> Eff eff Unit) -> Eff eff Unit
6973
onData = onDataImpl
7074

71-
-- | Listen for `data` events, returning data in a String, decoded with the
72-
-- | given encoding.
75+
-- | Listen for `data` events, returning data in a String, which will be
76+
-- | decoded using the given encoding.
7377
onDataString :: forall w eff. Readable w eff -> Encoding -> (String -> Eff eff Unit) -> Eff eff Unit
7478
onDataString r enc cb = onData r $ \buf -> do
7579
str <- unsafeInterleaveEff (Buffer.toString enc buf)
@@ -113,7 +117,11 @@ foreign import uncork :: forall r eff. Writable r eff -> Eff eff Unit
113117

114118
foreign import setDefaultEncodingImpl :: forall r eff. Writable r eff -> String -> Eff eff Unit
115119

116-
-- | Set the default encoding used to write chunks to the stream. This
120+
-- | Set the default encoding used to write chunks to the stream. This function
121+
-- | is useful when you are passing a writable stream to some other JavaScript
122+
-- | library, which already expects a default encoding to be set. It has no
123+
-- | effect on the behaviour of the `writeString` function (because that
124+
-- | function ensures that the encoding is always supplied explicitly).
117125
setDefaultEncoding :: forall r eff. Writable r eff -> Encoding -> Eff eff Unit
118126
setDefaultEncoding r enc = setDefaultEncodingImpl r (show enc)
119127

0 commit comments

Comments
 (0)