type-check demo

type-check is a library which allows you to check the types of JavaScript values at runtime with a Haskell like type syntax. It is great for checking external input, for testing, or even for adding a bit of safety to your internal code.

For more information, including documentation and more examples, please check out the README on GitHub. MIT License. Version 0.3.1

For updates on type-check, follow me on twitter.

npm install type-check

quick examples

Types on the left for values on the right. For more examples check out the readme.

Number                        1
Maybe String                  'str'
Maybe String                  null
Number | String               2
Number | String               'str'
[Number]                      [1, 2, 3]
(String, Number)              ['str', 2]
{x: Number, y: Boolean}       {x: 2, y: false}
{x: Number, y: Maybe Boolean} {x: 2}
{x: Number, y: Boolean, ...}  {x: 2, y: false, z: 'str'}