0.5.0 • Published 9 years ago

tassert v0.5.0

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

tassert Build Status npm mit

High quality runtime assertions for Typescript

Alpha - ready for feedback

Installation

npm install -S tassert

Usage

import t, {boolean, literal, number, or, string} from 'tassert'

t(number, 42)
t(string, 'foo')
t(or(boolean, number, string), 999)
t(literal([1,2,3]), [1,2]) // Error!

Features

  • Native types
    • Array
      • Array<any>
      • Array<A>
    • ArrayBuffer
    • Boolean
    • Buffer
    • Date
    • Error
    • Function
    • Map
      • Map<any, any>
      • Map<A, B>
    • NaN
    • Null
    • Number
    • Object
      • Object<any, any>
      • Object<A, B>
    • RegExp
    • Set
      • Set<any>
      • Set<A>
    • String
    • Symbol
    • TypedArray
    • Undefined
    • WeakMap
      • WeakMap<any, any>
      • WeakMap<A, B>
    • WeakSet
      • WeakSet<any>
      • WeakSet<A>
  • Constructors (tassert.instanceOf(Foo))
  • Literals
    • Shallow (tassert.literal(42, false))
    • Deep (tassert.literal(42))
  • Logic
    • and (tassert.and(tassert.literal(42), tassert.number))
    • or (tassert.or(tassert.string, tassert.number, tassert.array))
    • not (tassert.or(tassert.string, not(tassert.string('foo'))))
    • xor (tassert.xor(tassert.literal(42), tassert.number))
  • Comparators
    • ==
    • <
    • =

    • <=
    • :> (Superset of)
    • <: (Subset of)
    • ~= (Structurally equal)

Tests

npm test

Building

npm run build

Hacking

npm run watch & npm run tdd

0.5.0

9 years ago

0.4.1

10 years ago

0.4.0

10 years ago

0.3.0

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.0.1

10 years ago