jsContract is a framework for using code contracts in Javascript. The library is very easy to use and supports both pre- and postconditions.
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.gitignore
MyClass.js
README.txt
index.html
jsContract.js
test.html
test.js
test2.html

README.txt

jsContract is a tool for implementing code contracts in Javascript.
Code contracts are implemented as a series of statements in the head of each function supporting both pre- and postconditions.

	myFunction(a,b,c) {
		Contract.expectNumber(a,"a is not a number");
		Contract.guaranteesString("The result was not a string");

To support postconditions one has to instrument the script (rewrite it) using a call to Contract.instrument , such as

	var script = ".......";
	var instrumented = Contract.instrument(script);

One can also use the Contract framework to asynchronously load and instrument files using Contract.load

	Contract.load("myscript.js",true,function(){
		useCode();
	});


The  library is shared under the MIT-license.
http://www.opensource.org/licenses/mit-license.php