text-stream-accumulator
v2.0.0
Published
Accumulates all values of a text stream into a string
Downloads
14
Readme
Node.js Text Stream Accumulator
This micro-library (with zero dependencies) gathers all the text that flows through through a Node.JS readable stream.
const { TextStreamAccumulator } = require("text-stream-accumulator")
const acc = new Accumulator(myStream)
// wait for events from myStream
acc.toString() // prints accumulated content from myStream
As an example, When your myStream
object emits
data
events containing "hello" and "world" (in the form of a
Buffer or string),
calling acc.toString()
will return "helloworld".
TextStreamAccumulator
keeps all captured content in an internal buffer. To
reduce the size of this buffer, call one of these methods after you have found
what you have been looking for:
acc.reset()
removes all captured contentacc.truncate("foo")
removes all earlier captured content until (and including) the word "foo", but keeps content captured later around
Feedback
All feedback, no matter how big or small, is welcome. Please submit bugs, ideas, or improvements via an issue or pull request.
Development
- run all tests: make test
- run all linters: make lint
- run all formatters: make fix
- see all available Make commands: make help
- deploy a new version:
- update the version in
package.json
and commit tomaster
- run
npm publish
- update the version in