|
| 1 | +## Module Node.Stream |
| 2 | + |
| 3 | +This module provides a low-level wrapper for the Node Stream API. |
| 4 | + |
| 5 | +#### `Stream` |
| 6 | + |
| 7 | +``` purescript |
| 8 | +data Stream :: # * -> # ! -> * -> * |
| 9 | +``` |
| 10 | + |
| 11 | +A stream. |
| 12 | + |
| 13 | +The type arguments track, in order: |
| 14 | + |
| 15 | +- Whether reading and/or writing from/to the stream are allowed. |
| 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 | + |
| 19 | +#### `Read` |
| 20 | + |
| 21 | +``` purescript |
| 22 | +data Read |
| 23 | +``` |
| 24 | + |
| 25 | +A phantom type associated with _readable streams_. |
| 26 | + |
| 27 | +#### `Readable` |
| 28 | + |
| 29 | +``` purescript |
| 30 | +type Readable r = Stream (read :: Read | r) |
| 31 | +``` |
| 32 | + |
| 33 | +A readable stream. |
| 34 | + |
| 35 | +#### `Write` |
| 36 | + |
| 37 | +``` purescript |
| 38 | +data Write |
| 39 | +``` |
| 40 | + |
| 41 | +A phantom type associated with _writable streams_. |
| 42 | + |
| 43 | +#### `Writable` |
| 44 | + |
| 45 | +``` purescript |
| 46 | +type Writable r = Stream (write :: Write | r) |
| 47 | +``` |
| 48 | + |
| 49 | +A writable stream. |
| 50 | + |
| 51 | +#### `Duplex` |
| 52 | + |
| 53 | +``` purescript |
| 54 | +type Duplex = Stream (read :: Read, write :: Write) |
| 55 | +``` |
| 56 | + |
| 57 | +A duplex (readable _and_ writable stream) |
| 58 | + |
| 59 | +#### `setEncoding` |
| 60 | + |
| 61 | +``` purescript |
| 62 | +setEncoding :: forall w eff. Readable w eff String -> Encoding -> Eff eff Unit |
| 63 | +``` |
| 64 | + |
| 65 | +Set the encoding used to read chunks from the stream. |
| 66 | + |
| 67 | +#### `onData` |
| 68 | + |
| 69 | +``` purescript |
| 70 | +onData :: forall w eff a. Readable w eff a -> (a -> Eff eff Unit) -> Eff eff Unit |
| 71 | +``` |
| 72 | + |
| 73 | +Listen for `data` events. |
| 74 | + |
| 75 | +#### `onEnd` |
| 76 | + |
| 77 | +``` purescript |
| 78 | +onEnd :: forall w eff a. Readable w eff a -> Eff eff Unit -> Eff eff Unit |
| 79 | +``` |
| 80 | + |
| 81 | +Listen for `end` events. |
| 82 | + |
| 83 | +#### `onClose` |
| 84 | + |
| 85 | +``` purescript |
| 86 | +onClose :: forall w eff a. Readable w eff a -> Eff eff Unit -> Eff eff Unit |
| 87 | +``` |
| 88 | + |
| 89 | +Listen for `close` events. |
| 90 | + |
| 91 | +#### `onError` |
| 92 | + |
| 93 | +``` purescript |
| 94 | +onError :: forall w eff a. Readable w eff a -> Eff eff Unit -> Eff eff Unit |
| 95 | +``` |
| 96 | + |
| 97 | +Listen for `error` events. |
| 98 | + |
| 99 | +#### `resume` |
| 100 | + |
| 101 | +``` purescript |
| 102 | +resume :: forall w eff a. Readable w eff a -> Eff eff Unit |
| 103 | +``` |
| 104 | + |
| 105 | +Resume reading from the stream. |
| 106 | + |
| 107 | +#### `pause` |
| 108 | + |
| 109 | +``` purescript |
| 110 | +pause :: forall w eff a. Readable w eff a -> Eff eff Unit |
| 111 | +``` |
| 112 | + |
| 113 | +Pause reading from the stream. |
| 114 | + |
| 115 | +#### `isPaused` |
| 116 | + |
| 117 | +``` purescript |
| 118 | +isPaused :: forall w eff a. Readable w eff a -> Eff eff Boolean |
| 119 | +``` |
| 120 | + |
| 121 | +Check whether or not a stream is paused for reading. |
| 122 | + |
| 123 | +#### `pipe` |
| 124 | + |
| 125 | +``` purescript |
| 126 | +pipe :: forall r w eff a. Readable w eff a -> Writable r eff a -> Eff eff (Writable r eff a) |
| 127 | +``` |
| 128 | + |
| 129 | +Read chunks from a readable stream and write them to a writable stream. |
| 130 | + |
| 131 | +#### `write` |
| 132 | + |
| 133 | +``` purescript |
| 134 | +write :: forall r eff a. Writable r eff String -> a -> Eff eff Unit -> Eff eff Boolean |
| 135 | +``` |
| 136 | + |
| 137 | +Write a chunk to a writable stream. |
| 138 | + |
| 139 | +#### `writeString` |
| 140 | + |
| 141 | +``` purescript |
| 142 | +writeString :: forall r eff a. Writable r eff String -> Encoding -> String -> Eff eff Unit -> Eff eff Boolean |
| 143 | +``` |
| 144 | + |
| 145 | +Write a string in the specified encoding to a writable stream. |
| 146 | + |
| 147 | +#### `cork` |
| 148 | + |
| 149 | +``` purescript |
| 150 | +cork :: forall r eff a. Writable r eff a -> Eff eff Unit |
| 151 | +``` |
| 152 | + |
| 153 | +Force buffering of writes. |
| 154 | + |
| 155 | +#### `uncork` |
| 156 | + |
| 157 | +``` purescript |
| 158 | +uncork :: forall r eff a. Writable r eff a -> Eff eff Unit |
| 159 | +``` |
| 160 | + |
| 161 | +Flush buffered data. |
| 162 | + |
| 163 | +#### `setDefaultEncoding` |
| 164 | + |
| 165 | +``` purescript |
| 166 | +setDefaultEncoding :: forall r eff. Writable r eff String -> Encoding -> Eff eff Unit |
| 167 | +``` |
| 168 | + |
| 169 | +Set the default encoding used to write chunks to the stream. |
| 170 | + |
| 171 | +#### `end` |
| 172 | + |
| 173 | +``` purescript |
| 174 | +end :: forall r eff a. Writable r eff a -> Eff eff Unit -> Eff eff Unit |
| 175 | +``` |
| 176 | + |
| 177 | +End writing data to the stream. |
| 178 | + |
| 179 | + |
0 commit comments