1. stream-to-string
Pipe a stream into a string, collect value with callback or promise
stream-to-string
Package: stream-to-string
Created by: jasonpincin
Last modified: Wed, 08 Feb 2023 01:06:04 GMT
Version: 1.2.1
License: MIT
Downloads: 452,998
Repository: https://github.com/jasonpincin/stream-to-string

Install

npm install stream-to-string
yarn add stream-to-string

stream-to-string

NPM version
Build Status
Coverage Status

Pipe a stream into a string, collect value with callback or promise

example

 var toString = require('..'),
    through2 = require('through2'),
    stream   = through2()

toString(stream, function (err, msg) {
    console.log(msg)
})

# or with promises
toString(stream).then(function (msg) {
    console.log(msg)
})

stream.write('this is a')
stream.write(' test')
stream.end()

api

 var toString = require('stream-to-string')

toString(stream[, enc][, cb])

Collects stream data into a string. Accepts an optional encoding argument used when converting the stream. Executes optional callback with err, string. Returns a promise.

testing

npm test [--dot | --spec] [--coverage | --grep=pattern]

Specifying --dot or --spec will change the output from the default TAP style.
Specifying --coverage will print a text coverage summary to the terminal after
tests have ran, while --pattern will only run the test files that match the given
pattern.

Open an html coverage report with npm run view-cover.

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code