Reactive-Extensions / rx-node

RxJS Bindings for Node.js and io.js
Other
219 stars 27 forks source link

add dataEventName parameter #13

Closed mcharytoniuk closed 8 years ago

mcharytoniuk commented 8 years ago

Since Node.js 0.12 we are able to use 'readline' package bundled with Node.js. It provides wrapper for readableStream which adds new 'line' event. It works in a similar way to the 'data' event but instead of returning buffer with bytes chunk, String of characters is returned. This pull request adds optional 'dataEventName' parameter which allows to use RxNode with 'readline' package.

See also: https://nodejs.org/api/readline.html#readline_example_read_file_stream_line_by_line

mcharytoniuk commented 8 years ago

Maybe it would be also reasonable to add a new API method like this one?

  /**
   * Converts a flowing readline stream to an Observable sequence.
   * @param {Stream} stream A stream to convert to a observable sequence.
   * @returns {Observable} An observable sequence which fires on each 'data' event as well as handling 'error' and 'end' events.
   */
  fromReadLineStream: function (stream) {
    return this.fromStream(stream, 'close', 'line');
  },
mattpodwysocki commented 8 years ago

@mcharytoniuk yes, that would be fine