codemix / obligations

Tiny JavaScript library for preconditions and postconditions, intended for use with Contractual.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Obligations

Build Status

Tiny JavaScript library for preconditions, postconditions and invariants, intended for use with Contractual.

Installation

npm install obligations

Usage

var obligations = require('obligations');

obligations.precondition(1 > 0); // always ok
obligations.precondition(false); // throws a PreconditionError
obligations.precondition(0 > 1, "The world has ended!"); // throws a PreconditionError with a custom message


obligations.postcondition(1 > 0); // always ok
obligations.postcondition(false); // throws a PostconditionError
obligations.postcondition(0 > 1, "The world has ended!"); // throws a PostconditionError with a custom message

obligations.invariant(1 > 0); // always ok
obligations.invariant(false); // throws an InvariantError
obligations.invariant(0 > 1, "The world has ended!"); // throws a InvariantError with a custom message

License

MIT, see LICENSE.md.

About

Tiny JavaScript library for preconditions and postconditions, intended for use with Contractual.

License:MIT License


Languages

Language:JavaScript 100.0%