sprom

Convert node.js Streams into Promises

sprom

Convert node.js Streams into Promises

$ npm install sprom
sprom.end(request(url).pipe(fs.createWriteStream('file.json')))
  .then(function () {
    console.log('Successfully wrote file');
  }, function (err) {
    console.error('Failed to write file');
    console.error(err.stack || err.message || err);
  });
sprom(request(url))
  .then(function (body) {
    console.dir(JSON.parse(body.toString()));
  })
  .then(null, function (err) {
    console.error('Failed to read JSON');
    console.error(err.stack || err.message || err);
  });

Get a promise that is resolved when the stream has ended. This won't make any attempt to look at the data of the stream.

Buffers the contents of the stream using concat-stream and returns a promise for the concatenated results.

Buffers the contents of the stream into an array and returns a promise for the array.

MIT