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.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.2
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.2
    1
  • 0.0.1
    0
  • 0.0.0
    1

Package Sidebar

Install

npm i tcomb-promise

Weekly Downloads

2

Version

0.0.2

License

ISC

Last publish

Collaborators

  • nl