tcomb-promise

0.0.2 • Public • Published

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.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i tcomb-promise

      Weekly Downloads

      2

      Version

      0.0.2

      License

      ISC

      Last publish

      Collaborators

      • nl