JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q42274F
  • License MIT

High quality runtime assertions for Typescript

Package Exports

  • tassert

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tassert) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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