tcomb-promise
v0.0.2
Published
tcomb combinator for promises / thenables
Downloads
11
Readme
tcomb-promise
tcomb combinator for promises / thenables.
Installation
npm install tcomb-promise
Usage
T = require 'tcomb-promise'
User = T.struct
name: T.String
email: T.String
, 'User'
fetchUser = T.func T.String, T.promise(User)
.of (id) ->
fetch "https://example.com/users/#{id}"
.then ({data}) -> data
fetchUser('someId').then (u) ->
# result is automatically hydrated
User.is(u) == true
API
The promise(type)
combinator is added to the tcomb
namespace.