Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/disnet/contracts.coffee
Contracts for CoffeeScript
https://github.com/disnet/contracts.coffee
Last synced: 3 months ago
JSON representation
Contracts for CoffeeScript
- Host: GitHub
- URL: https://github.com/disnet/contracts.coffee
- Owner: disnet
- License: mit
- Fork: true (jashkenas/coffeescript)
- Created: 2011-07-20T17:22:16.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2014-08-08T19:58:47.000Z (over 10 years ago)
- Last Synced: 2024-07-11T21:23:24.709Z (4 months ago)
- Language: JavaScript
- Homepage: http://disnet.github.io/contracts.coffee/
- Size: 18.5 MB
- Stars: 216
- Watchers: 6
- Forks: 6
- Open Issues: 28
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
contracts.coffee
================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](https://github.com/disnet/contracts.js) instead which has great contracts.coffee inspired syntax thanks to [sweet.js](http://sweetjs.org) macros.
Quick start
===========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](https://github.com/disnet/contracts.coffee/tree/master/lib/contracts))
There is also experimental support for require.js.
See [here](https://github.com/disnet/contracts.coffee/tree/master/test/webtest) for an example.If you are running in node.js then you'll need to install the contracts.js package
npm install contracts.js
Note that contracts.coffee requires some pretty new features of JavaScript
([Proxies](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Proxy)
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).Change Log
----------
* [0.3.2](https://github.com/disnet/contracts.coffee/tree/c0.3.1) (September 5, 2012)
* disabling contracts for arrays (see issue [54](https://github.com/disnet/contracts.coffee/issues/54))
* various bug fixes
* [0.3.1](https://github.com/disnet/contracts.coffee/tree/c0.3.1) (July 15th, 2012)
* support for stable node.js (v0.8.0+)
* some bug fixes
* [0.3.0](https://github.com/disnet/contracts.coffee/tree/c0.3.0) (March 15th, 2012)
* [change](https://github.com/disnet/contracts.coffee/issues/8) to dependent function contracts
* various contracts.coffee bug fixes: [#27](https://github.com/disnet/contracts.coffee/issues/27), [#41](https://github.com/disnet/contracts.coffee/issues/41), [#33](https://github.com/disnet/contracts.coffee/issues/33), [#31](https://github.com/disnet/contracts.coffee/issues/31),
* various contracts.js bug fixes: [#9](https://github.com/disnet/contracts.js/pull/9), [#8](https://github.com/disnet/contracts.js/pull/8), [#7](https://github.com/disnet/contracts.js/pull/7), [#6](https://github.com/disnet/contracts.js/pull/6), [#5](https://github.com/disnet/contracts.js/pull/5), [#4](https://github.com/disnet/contracts.js/pull/4)
* experimental support for require.js (see [here](https://github.com/disnet/contracts.coffee/tree/master/test/webtest) for example use)
* based off CoffeeScript 1.3.1
* [0.2.0](https://github.com/disnet/contracts.coffee/tree/c0.2.0) (January 4th, 2012)
* removed `.use()`, now using `Contracts.exports` and `Contracts.use`
* various bug fixes
* based off CoffeeScript 1.2.0
* [0.1.0](https://github.com/disnet/contracts.coffee/tree/c0.1.0) (August 29th, 2011)
* initial release
* based off CoffeeScript 1.1.2