npm

Need private packages and team management tools?Check out npm Orgs. »

p-stream

1.0.3 • Public • Published

p-stream

Readable stream to Promise

Create Promises that resolve when a readable stream is finished streaming data. Or rejected when the stream reports an error.

Promise must be polyfilled.

Examples

var fs = require("fs");
var pstream = require("p-stream");
 
function readFile(filePath) {
  return fs
    .createReadStream(filePath)
    .setEncoding("utf8");
}
 
pstream(readFile("somefile.log")).then(function(text) {
  console.log("File read", text);
});

p-stream can handle strings and buffers.

TIP: Make sure to set the encoding on the stream to properly handle utf8 strings. Please refer to setEncoding for more details.

install

npm i p-stream

Downloadsweekly downloads

144

version

1.0.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability