@the-/assert
Assert for the-framework
Installation
$ npm install @the-/assert --save
Usage
'use strict'
const { TheAssert } = require('@the-/assert')
async function tryExample() {
const assert = new TheAssert('MyApp') //
function sum(a, b) {
assert(arguments.length > 0, 'must take two arguments')
return a + b
}
sum() // -> new Error(`[MyApp] must take two arguments`)
}
tryExample().catch((err) => console.error(err))
API Guide
function
- #bind()
- #notNullish(value,message)
- #nullish(value,message)
- #ok(condition,message)
- .create(args)
- .default(args)
class
License
This software is released under the MIT License.