Skip to content

Simpler stream creation #102

@sonewman

Description

@sonewman

I have mentioned this in a couple of other threads before, I just wanted to get some thoughts and opinions really.

My suggestion is that we allow the _ methods, which need to be set on a stream, be passed in as part of the options on instantiation. e.g.

var stream = require('readable-stream')

var readable = new stream.Readable({
  read(n) { }
})

var writable = new stream.Writable({
  write(data, enc, next) { },
  // edit - courtesy @calvinmetcalf
  writev(chunks, next) { }
})

var duplex = new stream.Duplex({
  read(n) { },
  write(data, enc, next) { },
  // edit - courtesy @calvinmetcalf
  writev(chunks, next) { }
})

var transform = new stream.Transform({
  transform(data, enc, next) { },
  // edit - courtesy @calvinmetcalf
  flush(done) { }
})

edit - functions in ES6 for readability

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions