(string)
| 192 | * @return {ReadableStream} |
| 193 | */ |
| 194 | export function stringToStream (string) { |
| 195 | return from(function (size, next) { |
| 196 | // if there's no more content |
| 197 | // left in the string, close the stream. |
| 198 | if (!string || string.length <= 0) { |
| 199 | return next(null, null) |
| 200 | } |
| 201 | |
| 202 | // Pull in a new chunk of text, |
| 203 | // removing it from the string. |
| 204 | const chunk = string.slice(0, size) |
| 205 | string = string.slice(size) |
| 206 | |
| 207 | // Emit "chunk" from the stream. |
| 208 | next(null, chunk) |
| 209 | }) |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * Removes line ending characters (\n and \r) from a string. |
no outgoing calls
no test coverage detected