🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

stream-read-all

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-read-all

Returns a promise which fulfils with the supplied stream's content

latest
Source
npmnpm
Version
5.0.2
Version published
Weekly downloads
453K
-14.29%
Maintainers
1
Weekly downloads
 
Created
Source

view on npm npm module downloads Gihub repo dependents Gihub package dependents Node.js CI js-standard-style

stream-read-all

Returns a promise which fulfils with the supplied stream's content. Supports any Readable stream as input in either regular or object mode.

For example, this script...

import { streamReadAll } from 'stream-read-all'
const readable = await streamReadAll(process.stdin)
console.log(readable.toString())

...prints this output.

$ echo Hello | node example.js
Hello

The above streamReadAll function returns either a Buffer in regular mode or an array of objects in object mode. Alternatively, you can use streamReadText which is identical to the above except it returns text. The second argument is optional, specifying the character encoding to use (as in the buffer.toString() first argument). The default value is 'utf8'.

import { streamReadText } from 'stream-read-all'
const readable = fs.createReadStream('./package.json')
const text = await streamReadText(readable, 'hex')
console.log(text)
// prints the package.json file content in hex format

© 2017-25 Lloyd Brookes opensource@75lb.com.

Keywords

concat

FAQs

Package last updated on 18 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts