1.0.1 • Published 6 years ago

pull-promise-end v1.0.1

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
6 years ago

pull-promise-end

A small wrapper function around pull.onEnd, which drains the stream passed to it and returns a promise.

Usage

var end = require('pull-promise-end')
var pull = require('pull-stream')

var stream = pull(
  pull.values([5, 4, 3, 2, 1, ]),
  pull.asyncMap(someMagic)
)

end(stream).then(function () {
  // Move on
}).catch(function (err) {
  // Handle error
})

Like all promises, you can also use this with async/await:

async function drainStream () {
  try {
    await end(stream)
    // Move on
  } catch (err) {
    // Handle error
  }
}

License

Apache-2.0