c-{{{-<
Fishbone.js A super lightweight (½kb) JavaScript library with automatic method chaining, automatic context binding, event support and simple inheritance.
Version: 1.0.1
Features
- clean and simple syntax
- steep learning curve
this
is the context in all methods- automatic method chaining
- simple inheritance
on
,off
event observer pattern- no dependencies
- production ready
- well tested
- cross browser & Node.js support
- ~ 512 bytes minified (300 gzipped !)
Usage
Klass = Model({ init: function(options){} })
- create a modelKlass2 = Klass.extend({ … })
- inherit from other classinstance = new Klass(options)
- create an instanceinstance.on(event, listener)
- observe a given eventinstance.off(event, [listener])
- remove listenerinstance.trigger(event, data)
- triggers an event
Example
var Model = ; // require module (Node only) var Pirate = ; var Captain = Pirate; var captain = "Jack" // create an instance rounds = 20; captain; // add event listener { // pseudo listener console;} captain; // add event listenercaptain; // remove event listener while rounds-- captain // chaining FTW! // chaining FTW! // chaining FTW! // chaining FTW! ; // chaining FTW!
Install
Include fishbone.js
or copy and paste this:
{{var a=thisf={};a{fa||fa=}a{forvar c=fad=0;c&&d<clength;cd++b}a{ford=fa||;b&&c=d>-1;d;fa=b?d:};forc in bd=bcac=typeof d=="function"?{returnd=this===e?a:d}:d;ainit&&ainit}return f{d={};forc in bdc=bc;forc in fdc=fcbc!==e&&d"__"+c=bc;return }f}typeof module=="object"&&moduleexports=Model; // c-{{{-<
Install via npm:
npm install fishbone
Browser Support
Fishbone runs in all modern browsers and Node.js.
If you want support for Internet Explorer 8 and below, you have to include the
.bind
and .indexOf
polyfills: https://github.com/aemkei/fishbone.js/blob/master/polyfills.js
About
Developed by Martin Kleppe at Ubilabs.
Released under the WTFPL license.