@@ -5,7 +5,7 @@ This module provides a low-level wrapper for the Node Stream API.
5
5
#### ` Stream `
6
6
7
7
``` purescript
8
- data Stream :: # * -> # ! -> * -> *
8
+ data Stream :: # * -> # ! -> *
9
9
```
10
10
11
11
A stream.
@@ -14,7 +14,6 @@ The type arguments track, in order:
14
14
15
15
- Whether reading and/or writing from/to the stream are allowed.
16
16
- Effects associated with reading/writing from/to this stream.
17
- - The type of chunks which will be read from/written to this stream (` String ` or ` Buffer ` ).
18
17
19
18
#### ` Read `
20
19
@@ -59,119 +58,136 @@ A duplex (readable _and_ writable stream)
59
58
#### ` setEncoding `
60
59
61
60
``` purescript
62
- setEncoding :: forall w eff. Readable w eff String -> Encoding -> Eff eff Unit
61
+ setEncoding :: forall w eff. Readable w eff -> Encoding -> Eff eff Unit
63
62
```
64
63
65
- Set the encoding used to read chunks from the stream.
64
+ Set the encoding used to read chunks as strings from the stream. This
65
+ function is useful when you are passing a readable stream to some other
66
+ JavaScript library, which already expects an encoding to be set. It
67
+ has no effect on the behaviour of the ` onDataString ` function (because
68
+ that function ensures that the encoding is always supplied explicitly).
66
69
67
70
#### ` onData `
68
71
69
72
``` purescript
70
- onData :: forall w eff a . Readable w eff a -> (a -> Eff eff Unit) -> Eff eff Unit
73
+ onData :: forall w eff. Readable w eff -> (Buffer -> Eff eff Unit) -> Eff eff Unit
71
74
```
72
75
73
- Listen for ` data ` events.
76
+ Listen for ` data ` events, returning data in a Buffer.
77
+
78
+ #### ` onDataString `
79
+
80
+ ``` purescript
81
+ onDataString :: forall w eff. Readable w eff -> Encoding -> (String -> Eff eff Unit) -> Eff eff Unit
82
+ ```
83
+
84
+ Listen for ` data ` events, returning data in a String, which will be
85
+ decoded using the given encoding.
74
86
75
87
#### ` onEnd `
76
88
77
89
``` purescript
78
- onEnd :: forall w eff a . Readable w eff a -> Eff eff Unit -> Eff eff Unit
90
+ onEnd :: forall w eff. Readable w eff -> Eff eff Unit -> Eff eff Unit
79
91
```
80
92
81
93
Listen for ` end ` events.
82
94
83
95
#### ` onClose `
84
96
85
97
``` purescript
86
- onClose :: forall w eff a . Readable w eff a -> Eff eff Unit -> Eff eff Unit
98
+ onClose :: forall w eff. Readable w eff -> Eff eff Unit -> Eff eff Unit
87
99
```
88
100
89
101
Listen for ` close ` events.
90
102
91
103
#### ` onError `
92
104
93
105
``` purescript
94
- onError :: forall w eff a . Readable w eff a -> Eff eff Unit -> Eff eff Unit
106
+ onError :: forall w eff. Readable w eff -> Eff eff Unit -> Eff eff Unit
95
107
```
96
108
97
109
Listen for ` error ` events.
98
110
99
111
#### ` resume `
100
112
101
113
``` purescript
102
- resume :: forall w eff a . Readable w eff a -> Eff eff Unit
114
+ resume :: forall w eff. Readable w eff -> Eff eff Unit
103
115
```
104
116
105
117
Resume reading from the stream.
106
118
107
119
#### ` pause `
108
120
109
121
``` purescript
110
- pause :: forall w eff a . Readable w eff a -> Eff eff Unit
122
+ pause :: forall w eff. Readable w eff -> Eff eff Unit
111
123
```
112
124
113
125
Pause reading from the stream.
114
126
115
127
#### ` isPaused `
116
128
117
129
``` purescript
118
- isPaused :: forall w eff a . Readable w eff a -> Eff eff Boolean
130
+ isPaused :: forall w eff. Readable w eff -> Eff eff Boolean
119
131
```
120
132
121
133
Check whether or not a stream is paused for reading.
122
134
123
135
#### ` pipe `
124
136
125
137
``` purescript
126
- pipe :: forall r w eff a . Readable w eff a -> Writable r eff a -> Eff eff (Writable r eff a )
138
+ pipe :: forall r w eff. Readable w eff -> Writable r eff -> Eff eff (Writable r eff)
127
139
```
128
140
129
141
Read chunks from a readable stream and write them to a writable stream.
130
142
131
143
#### ` write `
132
144
133
145
``` purescript
134
- write :: forall r eff a . Writable r eff String -> a -> Eff eff Unit -> Eff eff Boolean
146
+ write :: forall r eff. Writable r eff -> Buffer -> Eff eff Unit -> Eff eff Boolean
135
147
```
136
148
137
- Write a chunk to a writable stream.
149
+ Write a Buffer to a writable stream.
138
150
139
151
#### ` writeString `
140
152
141
153
``` purescript
142
- writeString :: forall r eff. Writable r eff String -> Encoding -> String -> Eff eff Unit -> Eff eff Boolean
154
+ writeString :: forall r eff. Writable r eff -> Encoding -> String -> Eff eff Unit -> Eff eff Boolean
143
155
```
144
156
145
157
Write a string in the specified encoding to a writable stream.
146
158
147
159
#### ` cork `
148
160
149
161
``` purescript
150
- cork :: forall r eff a . Writable r eff a -> Eff eff Unit
162
+ cork :: forall r eff. Writable r eff -> Eff eff Unit
151
163
```
152
164
153
165
Force buffering of writes.
154
166
155
167
#### ` uncork `
156
168
157
169
``` purescript
158
- uncork :: forall r eff a . Writable r eff a -> Eff eff Unit
170
+ uncork :: forall r eff. Writable r eff -> Eff eff Unit
159
171
```
160
172
161
173
Flush buffered data.
162
174
163
175
#### ` setDefaultEncoding `
164
176
165
177
``` purescript
166
- setDefaultEncoding :: forall r eff. Writable r eff String -> Encoding -> Eff eff Unit
178
+ setDefaultEncoding :: forall r eff. Writable r eff -> Encoding -> Eff eff Unit
167
179
```
168
180
169
- Set the default encoding used to write chunks to the stream.
181
+ Set the default encoding used to write strings to the stream. This function
182
+ is useful when you are passing a writable stream to some other JavaScript
183
+ library, which already expects a default encoding to be set. It has no
184
+ effect on the behaviour of the ` writeString ` function (because that
185
+ function ensures that the encoding is always supplied explicitly).
170
186
171
187
#### ` end `
172
188
173
189
``` purescript
174
- end :: forall r eff a . Writable r eff a -> Eff eff Unit -> Eff eff Unit
190
+ end :: forall r eff. Writable r eff -> Eff eff Unit -> Eff eff Unit
175
191
```
176
192
177
193
End writing data to the stream.
0 commit comments