Bodyguard
Because sometimes you want something like interfaces in JavaScript
Installation
If you are using Node.js: npm install bodyguard
If you are using Bower: bower install bodyguard
(If you also want to save the configuration in your package.json
or bower.json
add --save
to the command.)
Don't use npm or bower? Just grab bodyguard.js
from the dist
folder and embed it in your application.
Example
JavaScript:
var MyClass = { var {}; MyClassprototype { return 5; }; MyClassprototype { return 6; }; MyClassprototype { return 7; };}; var NewClass = ;// NewClass can now be instantiated and returns an object with a and b bound// to its prototype
CoffeeScript:
: -> : -> 5 : -> 6 : -> 7 NewClass = bodyguard 'NewClass''a''b'# NewClass can now be instantiated and returns an object with a and b bound # to its prototype
(Yes, we all know, technically we shouldn't be calling it classes in JavaScript. :) )