All Projects → oyvindkinsey → jsContract

oyvindkinsey / jsContract

Licence: other
jsContract is a framework for using code contracts in Javascript. The library is very easy to use and supports both pre- and postconditions.

Programming Languages

javascript
184084 projects - #8 most used programming language
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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].