Boo provides easy-modo prototypical inheritance and object composition for JavaScript, through mixins and prototype cloning:
var animal = boo.Base.clone({
name: 'Unknow'
, say:
function say(thing) {
return this.name + ': ' + thing }
})
var cat = animal.clone({
init:
function init(name) {
if (name) this.name = name }
})
var Nyah = cat.make('Nyan Cat')
Nyah.say('Nyan nyan nyan~')
// => 'Nyan Cat: Nyan nyan nyan~'
With Node.js and NPM, you can do the easy-modo install:
$ npm install boo
# Then require it as usual
node> var boo = require('boo')
In the browser, you have to include the script tag pointing to the boo.js file:
<script src="/path/to/boo.js"></script>
<script type="text/javascript">
// `boo' is in the global scope now
</script>
Boo should support all ECMAScript 5-compliant platforms. For the legacy ones, you’ll have to provide support for the following methods:
- Object.keys
- Object.create
- Object.getPrototypeOf
- Array.prototype.forEach
- Array.prototype.filter
- Array.prototype.indexOf
The nice es5-shim library takes care of handling all of those for you.
Boo uses the Github tracker for tracking bugs and new features.