Current Stable Version: 1.1.0
Automated Build Status:
Node Support: 0.6, 0.8, 0.10
Browser Support: Android Browser 2.2–4.2, Firefox 3.6, Firefox 4–19, Google Chrome 14–25, Internet Explorer 6–10, Mobile Safari iOS 3–6, Opera 12.10, Safari 5–6
You can use Chic on the server side with Node.js and npm:
$ npm install chic
On the client side, you can either install Chic through Component:
$ component install rowanmanning/chic
or by simply including
chic.js in your page:
In Node.js or using Component, you can include Chic in your script by using require:
var Class = require'chic'Class;
Chic also works with AMD-style module loaders, just specify it as a dependency.
If you're just including with a
Class is available in the
var Class = chicClass;
The rest of the examples assume you've got the
Class variable already.
Creating classes is very simple. You extend the base class like this:
var Animal = Classextend;
Obviously you want to add methods to your class, to give it some functionality:
var Animal = Classextend;
init method is a special one. This is your class constructor, and is called when a new instance of your class is created. You can set things up in here.
var Animal = Classextendthisalive = true;;
var fluffy = ;fluffypoop; // Bad Fluffy!
Any class you create is also extendable. You extend custom classes in exactly the same way as the base class:
var Cat = Animalextend;
If you define methods in this extend, then they will override methods of the same name which have been inherited from the parent class. For example:
var Animal = Classextendreturn 'Roar!';;var Cat = Animalextendreturn 'Miaow?';;var mrTibbles = ;mrTibblesspeak; // Miaow?
If you wish to call the parent method, then that's possible using
this.sup, which is a reference to the parent method with the same name as the one being called:
var Animal = Classextendthisname = name;return thisname + ' is eating';;var Cat = Animalextendreturn thissup + ' like a good kitty';;var pet = 'Mr Tibbles';peteat; // Mr Tibbles is eating like a good kitty
To develop Chic, you'll need to clone the repo and install dependencies with
make deps. If you're on Windows, you'll also need to install Make for Windows.
Once you're set up, you can run the following commands:
$ make deps # Install dependencies$ make lint # Run JSHint with the correct config$ make test # Run unit tests in Node$ make test-server # Run a server for browser unit testing (visit localhost:3000)
When no build target is specified, make will run
deps lint test. This means you can use the following command for brevity:
Code with lint errors or no/failing tests will not be accepted, please use the build tools outlined above.
Chic is licensed under the MIT license.