@@ -58,7 +58,11 @@ type Duplex = Stream (read :: Read, write :: Write)
5858
5959foreign 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).
6266setEncoding :: forall w eff . Readable w eff -> Encoding -> Eff eff Unit
6367setEncoding 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
6872onData :: forall w eff . Readable w eff -> (Buffer -> Eff eff Unit ) -> Eff eff Unit
6973onData = 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.
7377onDataString :: forall w eff . Readable w eff -> Encoding -> (String -> Eff eff Unit ) -> Eff eff Unit
7478onDataString 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
114118foreign 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).
117125setDefaultEncoding :: forall r eff . Writable r eff -> Encoding -> Eff eff Unit
118126setDefaultEncoding r enc = setDefaultEncodingImpl r (show enc)
119127
0 commit comments