https://github.com/bcherny/tassert
High quality runtime assertions for Typescript
https://github.com/bcherny/tassert
typescript
Last synced: 7 months ago
JSON representation
High quality runtime assertions for Typescript
- Host: GitHub
- URL: https://github.com/bcherny/tassert
- Owner: bcherny
- License: mit
- Created: 2016-04-07T20:54:41.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-09-22T20:25:29.000Z (about 9 years ago)
- Last Synced: 2024-12-17T03:03:28.512Z (10 months ago)
- Topics: typescript
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# tassert [![Build Status][build]](https://circleci.com/gh/bcherny/tassert) [![npm]](https://www.npmjs.com/package/tassert) [![mit]](https://opensource.org/licenses/MIT)
[build]: https://img.shields.io/circleci/project/bcherny/tassert.svg?branch=master&style=flat-square
[npm]: https://img.shields.io/npm/v/tassert.svg?style=flat-square
[mit]: https://img.shields.io/npm/l/tassert.svg?style=flat-square> High quality runtime assertions for Typescript
**Alpha - ready for feedback**
## Installation
`npm install -S tassert`
## Usage
```ts
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`
- [x] `Array`
- [ ] `Array`
- [x] `ArrayBuffer`
- [x] `Boolean`
- [x] `Buffer`
- [x] `Date`
- [x] `Error`
- [x] `Function`
- [ ] `Map`
- [ ] `Map`
- [ ] `Map`
- [x] `NaN`
- [x] `Null`
- [x] `Number`
- [ ] `Object`
- [x] `Object`
- [ ] `Object`
- [x] `RegExp`
- [ ] `Set`
- [ ] `Set`
- [ ] `Set`
- [x] `String`
- [x] `Symbol`
- [x] `TypedArray`
- [x] `Undefined`
- [ ] `WeakMap`
- [ ] `WeakMap`
- [ ] `WeakMap`
- [ ] `WeakSet`
- [ ] `WeakSet`
- [ ] `WeakSet`
- [x] Constructors (`tassert.instanceOf(Foo)`)
- [x] Literals
- [x] Shallow (`tassert.literal(42, false)`)
- [x] Deep (`tassert.literal(42)`)
- [x] Logic
- [x] `and` (`tassert.and(tassert.literal(42), tassert.number)`)
- [x] `or` (`tassert.or(tassert.string, tassert.number, tassert.array)`)
- [x] `not` (`tassert.or(tassert.string, not(tassert.string('foo')))`)
- [x] `xor` (`tassert.xor(tassert.literal(42), tassert.number)`)
- [ ] Comparators
- [x] ==
- [ ] >
- [ ] <
- [ ] >=
- [ ] <=
- [ ] :> (Superset of)
- [ ] <: (Subset of)
- [ ] ~= (Structurally equal)## Tests
`npm test`
## Building
`npm run build`
## Hacking
`npm run watch & npm run tdd`