

Show HN: cofoja-like's contracts for Javascript - my Saturday afternoon project. - pretzel
https://github.com/wbecker/jsContract

======
pretzel
I saw cofoja (<http://code.google.com/p/cofoja/>) this afternoon, and realised
it would be good to be able to code like that, but since I spend my days doing
mostly Javascript I wouldn't get to use it. So I've basically just ported it
across. It's just an afternoon's work so it's probably incredibly bug ridden -
don't even consider thinking about using it for real production code!

There are some other libraries that do the same thing for Javascript,
(<http://www.cerny-online.com/cerny.js/>
<http://weblogs.mozillazine.org/weirdal/archives/016921.html> and one also
called jsContract (oops - - looks like I might have to change my name...)
<http://kinsey.no/projects/jsContract/>)

The difference with these is they all expect you to call a special library
within your functions. My library takes the cofoja approach, where you keep
your function the same, but wrap it up with annotations that specify the
contracts. You can even turn contracts off completely, by setting a variable.

It has some tests there, but they aren't in jsUnit - I'll do that tomorrow. My
next step is to put contracts on each of its own functions, just to prove it
works.

