StrStr
strstr
is a small Node.js library that provides a way of both reading a string as a Node
stream and to gather all data from a Node stream and return a string from it.
Usage
var ss = ; // Read a string as if it were a Node streamss; // Write some stream to a stringvar stream = ;ss
ss.readString(string[, options])
Returns a readable stream that will emit the given string
as regular data
events.
The number of data
events fired depends on both the string
and the options
given to the
function, and should generally not be relied upon. In particular, no data
events are ever fired
if the passed string is empty.
The options
object can contain the following keys:
chunkSize
: Determines the size of the chunks emitted by the stream. If unspecified or set to 0, selects a default size that's small but not too small.
ss.writeString(stream)
Returns a Promise that will eventually be fulfilled with the accumulated value read from the
passed [readable stream
][]. If the passed stream emits an error
event, the returned promise
will be rejected instead, with the emitted error as it rejection reason.