stream-read-all
Returns a promise which fulfils with the supplied stream's content
Last updated 2 years ago by 75lb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install stream-read-all 
SYNC missed versions from official npm registry.

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.

Current Tags

  • 5.0.2                                ...           latest (2 years ago)

12 Versions

  • 5.0.2                                ...           2 years ago
  • 5.0.1                                ...           2 years ago
  • 5.0.0                                ...           2 years ago
  • 4.0.0                                ...           4 years ago
  • 3.0.1                                ...           6 years ago
  • 3.0.0                                ...           7 years ago
  • 2.0.0                                ...           8 years ago
  • 1.0.1                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
  • 0.1.2                                ...           9 years ago
  • 0.1.1                                ...           9 years ago
  • 0.1.0                                ...           9 years ago
Maintainers (1)
Downloads
Total 68
Today 0
This Week 1
This Month 20
Last Day 0
Last Week 12
Last Month 25
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE