seal-stream-as-string

seal-stream-as-string transforms streams to strings.

Usage no npm install needed!

<script type="module">
  import sealStreamAsString from 'https://cdn.skypack.dev/seal-stream-as-string';
</script>

README

seal-stream-as-string

CircleCI AppVeyor

seal-stream-as-string transforms streams to strings.

Installation

$ npm install seal-stream-as-string

Quick start

First you need to add a reference to seal-stream-as-string within your application.

const StreamAsString = require('seal-stream-as-string');

Then use the write function to add data to the stream. Once you are done, call end. Afterwards, you may use the asString function to get the stringified stream.

const streamAsString = new StreamAsString();

streamAsString.write('foo');
streamAsString.write('bar');
streamAsString.end();

console.log(streamAsString.asString()); // => 'foobar'

Alternatively, you may listen to the as-string event. It is raised after the stream has been ended.

const streamAsString = new StreamAsString();

streamAsString.once('as-string', (asString) => {
  console.log(asString); // => 'foobar'
});

streamAsString.write('foo');
streamAsString.write('bar');
streamAsString.end();

Running the build

To build this module use roboter.

$ bot