# tiny-assert

> TinyAssert is very simple and lightweight assertion library

Latest version **0.1.0** (published 2019-09-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install tiny-assert
pnpm add tiny-assert
yarn add tiny-assert
bun add tiny-assert
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2019-09-05 |
| First published | 2019-09-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Rumkin |
| Maintainers | rumkin |
| Keywords | assert, assertion, simple, light |

## Links

- npm: https://www.npmjs.com/package/tiny-assert
- Repository: https://github.com/rumkin/tiny-assert
- Homepage: https://github.com/rumkin/tiny-assert#readme
- Issues: https://github.com/rumkin/tiny-assert/issues
- npm.io page: https://npm.io/package/tiny-assert

## Alternatives

- [@oh-my-pi/pi-natives](https://npm.io/package/@oh-my-pi/pi-natives.md) — 51.8K weekly downloads
- [@capgo/capacitor-light-sensor](https://npm.io/package/@capgo/capacitor-light-sensor.md) — 3.0K weekly downloads
- [@heyhuynhgiabuu/pi-diff](https://npm.io/package/@heyhuynhgiabuu/pi-diff.md) — 492 weekly downloads
- [@lotsa/verdant-lang-asm](https://npm.io/package/@lotsa/verdant-lang-asm.md) — 38 weekly downloads
- [new-era-syntax](https://npm.io/package/new-era-syntax.md) — 20 weekly downloads

## Recent versions

- 0.1.0 (latest) — 2019-09-05

## README

# Tiny Assert

TinyAssert is simple and lightweight assertion library.

## API

## assert.ok()
```
(value:Boolean, msg?:String) -> void
```

Throw if `value` is _not_ truly. Using `msg` as assertion error message.

```js
value == true
```

## assert.notOk()
```
(value:Boolean, msg?:String) -> void
```

Throw if `value` is truthy. Using `msg` as assertion error message text.

```js
value != true
```

Check if `a` _non_-strictly _doesn't_ equal `b`.

## assert.equal()
```
(a:*, b:*, msg?:String) -> void
```

Check if `a` strictly equals `b`.

```js
a === b
```

## assert.notEqual()
```
(a:*, b:*[, msg:String]) -> void
```

Check if `a` doesn't strictly equal `b`.

```js
a !== b
```

## assert.oneOf()
```
(a:*, b:Array<*>, msg?:String) -> void
```

Check if `a` is presented in a list `b`.

```js
b.indexOf(a) > -1
```

## assert.notOneOf()
```
(a:*, b:Array<*>, msg?:String) -> void
```

Check if `a` isn't presented in list `b`

```js
b.indexOf(a) < 0
```

## assert.match()
```
(a:*, b:Object, msg?:String) -> void
```

Check if properties of `b` be strictly equal to properties of `a`.

```js
a[k] === b[k]
```

## assert.notMatch()
```
(a:*, b:Object, msg?:String) -> void
```

Check if properties of `b` be strictly equal to properties of `a`.

```js
a[k] !== b[k]
```

## assert.fail()
```
(msg:String) -> void
```

Throws assert exception with `msg` as a text.

## assert.throws()
```
(fn:() -> *, error: String|Error|Object, msg?:String) -> void
```

Check if function throws an assertion of defined shape. If `error` is
a string, then error.toString() value will be compared against the string. If it's an Error constructor, then `instanceof` check will be performed. If it's an Object, then each property of `error` will be checked to equality to actual error properties.

## assert.doesNotThrow()
```
(fn:() -> *, error: String|Error|Object, msg?:String) -> void
```

Performs the same checks as `assert.throws` but expects all comparisons to return `false`.

## assert.rejects()
```
(fn:() -> Promise<*,Error>, error: String|Error|Object, msg?:String) -> void
```

Same as `assert.throws` but for promises.

## assert.doesNotReject()
```
(fn:() -> Promise<*,Error>, error: String|Error|Object, msg?:String) -> void
```

Same as `assert.doesNotThrow` but for promises.

## License

MIT © [Rumkin](https://rumk.in)

---
_Source: https://npm.io/package/tiny-assert · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
