JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 111769439
  • Score
    100M100P100Q236318F
  • License MIT

Get a stream as a string or buffer

Package Exports

  • get-stream

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (get-stream) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

get-stream Build Status

Get a stream as a string or buffer

Install

$ npm install --save get-stream

Usage

const fs = require('fs');
const getStream = require('get-stream');
const stream = fs.createReadStream('unicorn.txt');

getStream(stream).then(str => {
    console.log(str);
    /*
                  ,,))))))));,
               __)))))))))))))),
    \|/       -\(((((''''((((((((.
    -*-==//////((''  .     `)))))),
    /|\      ))| o    ;-.    '(((((                                  ,(,
             ( `|    /  )    ;))))'                               ,_))^;(~
                |   |   |   ,))((((_     _____------~~~-.        %,;(;(>';'~
                o_);   ;    )))(((` ~---~  `::           \      %%~~)(v;(`('~
                      ;    ''''````         `:       `:::|\,__,%%    );`'; ~
                     |   _                )     /      `:|`----'     `-'
               ______/\/~    |                 /        /
             /~;;.____/;;'  /          ___--,-(   `;;;/
            / //  _;______;'------~~~~~    /;;/\    /
           //  | |                        / ;   \;;,\
          (<_  | ;                      /',/-----'  _>
           \_| ||_                     //~;~~~~~~~~~
               `\_|                   (,~~
                                       \~\
                                        ~~
    */
});

API

Both methods returns a promise that is resolved when the end event fires on the stream, indicating that there is no more data to be read. The stream is switched to flowing mode.

getStream(stream, [options])

Get the stream as a string.

options

encoding

Type: string
Default: utf8

Encoding of the incoming stream.

getStream.buffer(stream)

Get the stream as a buffer.

FAQ

How is this different from concat-stream?

This one accepts a stream instead of being one and returns a promise instead of using a callback. The API is simpler and it only supports returning a string or buffer. It doesn't have a fragile type inference. You explicitly choose what you want. And it doesn't depend on the huge readable-stream package.

  • get-stdin - Get stdin as a string or buffer

License

MIT © Sindre Sorhus