tcomb-kefir

0.0.1 • Public • Published

tcomb-kefir

tcomb-kefir provides Tcomb type combinators for Kefir streams and properties.

This allows you to create streams and properties that have typesafe values.

Example

Here we create a typesafe function greet. It takes a string Tcomb.Str and returns a stream of strings TcombKefir.stream(Tcomb.Str).

var Tcomb = require('tcomb'),
    Kefir = require('kefir'),
    TcombKefir = require('./src/tcomb-kefir'),
    readline = require('readline'),
    greet = Tcomb.func(Tcomb.Str, TcombKefir.stream(Tcomb.Str))
        .of(function(greeting) {
            var rlInterface = readline.createInterface({ input: process.stdin, output: process.stdout }),
                question = "What would you like to be called? ",
                ask = function(callback) { rlInterface.question(question, callback) },
                answer = Kefir.fromCallback(ask),
                append = function(name) { return greeting + " " + name + "!"; };
 
            return answer.map(append).onValue(rlInterface.close.bind(rlInterface));
        });
 
greet("Hi there").onValue(console.log.bind(console));

Package Sidebar

Install

npm i tcomb-kefir

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • becky-conning