A net wrapper for Prescription the FRP library

npm install prescription-net
2 downloads in the last week
8 downloads in the last month

Prescription Net

This exposes the core node.js net module as a set of functions that return Prescription FRP Observables instead of taking callbacks.


Echo server:

var net = require("prescription-net");

// Create a server instance
var server = new net.Server();

// Make the server listen on port 3000, we're only interested in the connection
// Observable, so we subscribe() that one through and we subscribe to each of
// the sockets it's emit back to themselves (echo server)
server.listen(3000).connection.subscribe(function(observables) {

TCP client:

var net         = require("prescription-net");
var client      = new net.Socket();
var observables = client.connect(3000);
var connect     = observables.connect;
var socket      = observables.socket; {
    return data.toString();
}).subscribe(function(data) {
connect.subscribe(function() {
    socket.onNext("beep bop boop");
npm loves you