0.2.0 • Published 8 years ago

rxjs-node-stream-subject v0.2.0

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

rxjs-node-stream-subject Build Status Test Coverage Code Climate

Installation

$ npm install rxjs-node-stream-subject

Usage

StreamSubject

var readline = require('readline')
var StreamSubject = require('rxjs-node-stream-subject')

var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
})

var s = new StreamSubject({
  dataEvent: 'line',
  endEvent: 'end',
  createStream: function() {
    return readline.createInterface({
      input: process.stdin,
      output: process.stdout
    })
  }
})

s.next('Write to stdout!\n')

// Map stin input
s.map(function(input) {
  return parseInt(input)
})
.forEach(function(integers) {
  // Do something with the entered integers!
})

SocketSubject

var SocketSubject = require('rxjs-node-stream-subject/dist/socket-subject').default

var s = new SocketSubject({
  host: 'topaxi.ch',
  port: 443,
  tls: true
})

s.next('GET / HTTP/1.1\r\n')
s.next('Host: topaxi.ch\r\n')
s.next('Connection: close\r\n')
s.next('\r\n')

s.subscribe(function(httpResponse) {
  console.log(httpResponse)
})

License