A compact design-by-contract helper for nodejs and the browser.
Installation
$ npm install dbc.js
To use in a browser:
!! Be sure to fix the path relative to your static media assets and the referring page.
Example
var dbc = expect = ; // from http://stackoverflow.com/questions/46155/validate-email-address-in-javascriptvar emailRe = /^@$/; { return emailRe;} { ; ; thisemail = email; thishandle = handle; thislast = last; thisfirst = first;} tobe; to; to;
Tests
Tests use mocha and expect.js, so if you clone the github repository you'll need to run:
npm install
... followed by ...
npm test
... or ...
mocha -R spec
To run the same tests from a browser, open the test/test.html
file directly from your file system.