Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

callback2stream

hybridables16MIT1.0.1

Transform sync, async or generator function to Stream. Correctly handle errors and optional arguments.

args, arguments, async, asynchronous, callback, callback-stream, cb, correct, create, fn, function, generator, generators, letta, make, optional, promisify, relike, stream, streamify, sync, synchronous, to, to-stream, tranform, value

readme

callback2stream npmjs.com The MIT License npm downloads

Transform sync, async or generator function to Stream. Correctly handle errors and optional arguments.

code climate standard code style travis build status coverage status dependency status

Install

npm i callback2stream --save

Usage

For more use-cases see the tests

const callback2stream = require('callback2stream')

callback2stream

Create a stream from sync, async or generator function.

Params

Example

var fs = require('fs')
var cb2stream = require('callback2stream')

var readFileStream = cb2stream(fs.readFile)
var stream = readFileStream('package.json', 'utf8')
stream
  .on('data', function (val) {
    var json = JSON.parse(val)
    console.log(json.name) // => 'callback2stream'
  })
  .once('error', console.error)
  .once('end', function () {
    console.log('reading finished')
  })

// you also have access to the
// contents with promise
stream.promise
  .then(JSON.parse, console.error)
  .then(function (val) {
    console.log(val.name) // => 'callback2stream'
  }, console.error)
  .catch(console.error)

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckoCore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github

changelog

1.0.1 - 2016-05-06

  • Release v1.0.1 / npm@v1.0.1
  • update related libs, add value2stream
  • fix docs
  • ensurance test

1.0.0 - 2016-05-06

  • Release v1.0.0 / npm@v1.0.0
  • use lazy-cache
  • fix codeclimate issue ("duplication", damn)
  • generate docs, related list, add keywords
  • fix banner links
  • implement

0.0.0 - 2016-05-06

  • Initial commit