socket-observer
v0.1.4
Published
Make an Observable from net.Socket easily
Downloads
1
Readme
socket-observer
Simple RXJS wrapper around node's net.Socket.
Installation
npm install --save socket-observer
Example usage
With user-provided socket:
import { createConnection } from 'net';
import { socketObserver } from 'socket-observer';
const socket = createConnection({
host: 'example.com',
port: 80
});
const oSocket = socketObserver(socket);
oSocket.down.subscribe(console.log);
oSocket.up('GET / HTTP/1.1\nHost: example.com\n\n');
Or using createConnection
helper:
import { createConnection } from 'socket-observer';
const oSocket = createConnection({
host: 'example.com',
port: 80
});
oSocket.down.subscribe(console.log);
oSocket.up('GET / HTTP/1.1\nHost: example.com\n\n');