Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cevek/assertio

Tiny assertion lib with typescript plugin to remove all assertations on production
https://github.com/cevek/assertio

Last synced: 5 days ago
JSON representation

Tiny assertion lib with typescript plugin to remove all assertations on production

Awesome Lists containing this project

README

        

# Assertio
Assertio is a tiny assertion library, similar to Node's built-in assert.
It makes testing much easier by giving you lots of assertions you can run against your code.

## Assertations
* `assert(value: boolean, msg?)`
* `assertValue(value, predicate, msg?)`
* `assertFn(value: () => boolean, msg?)`
* `ensureArray(value, msg?)`
* `ensureObject(value, msg?)`
* `ensureString(value, msg?)`
* `ensureNumber(value, msg?)`
* `ensureBoolean(value, msg?)`
* `ensureNonVoid(value, msg?)`
* `ensureNonNull(value, msg?)`
* `ensureNonNullable(value, msg?)`
* `nonVoid(value, msg?)`
* `nonNull(value, msg?)`
* `nonNullable(value, msg?)`
* `never(msg?)`
* `neverValue(value, msg?)`
* `castValue(value)`
* `cast(value)`
* `as(value)`
* `maybe(value)`

## TypeScript transformer plugin
Assertio has a typescript transformer plugin to remove all assertations on production.
See how to use typescript plugins https://github.com/cevek/ttypescript

`tsconfig.json`
```
{
"compilerOptions": {
// ...
"plugins": [
{ "transform": "assertio/transform" },
]
}
}
```