A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/disnet/contracts.coffee below:

GitHub - disnet/contracts.coffee: Contracts for CoffeeScript

contracts.coffee is a dialect of CoffeeScript with contract support.

Contracts allow you to write powerful runtime assertions about your code. Like types but less painful, like assert but more useful.

square :: (Num) -> Num
square = (x) -> x * x

# throws a run-time error
square "a string"   

Documentation, usage, and more examples: http://disnetdev.com/contracts.coffee/

Note: I am no longer actively maintaining contracts.coffee. Check out contracts.js instead which has great contracts.coffee inspired syntax thanks to sweet.js macros.

Install via npm:

npm install -g contracts.coffee

Use the compiler:

coffee -c --contracts /path/to/script.coffee

An alternative to using the --contracts flag is setting this env variable:

export CONTRACTS_COFFEE_ENABLED=1

If you are running in the browser then you'll need to load the contracts library (found in lib/contracts/contracts.js)

<script type="text/javascript" src="contracts.js"></script>

There is also experimental support for require.js. See here for an example.

If you are running in node.js then you'll need to install the contracts.js package

Note that contracts.coffee requires some pretty new features of JavaScript (Proxies in particular) so it currently only works on Firefox 4+, node.js 0.8.0+, and recent versions of Chrome (though you'll need to enable the experimental JavaScript flag in about:flags).


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.3