Skip to content
A super lightweight (½kb) JavaScript library with automatic method chaining, automatic context binding, event support and simple inheritance. c-{{{-<
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
bower.json rebuild Apr 12, 2016
example.js Update example to reflect inheritance. Nov 30, 2012
tests.js Add test output for browsers. Jan 7, 2013

Fishbone.js c-{{{-<

A super lightweight (½kb) JavaScript library with automatic method chaining, automatic context binding, event support and simple inheritance.

NPM version


  • 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 !)


  • Klass = Model({ init: function(options){} }) - create a model
  • Klass2 = Klass.extend({ … }) - inherit from other class
  • instance = new Klass(options) - create an instance
  • instance.on(event, listener) - observe a given event
  •, [listener]) - remove listener
  • instance.trigger(event, data) - triggers an event


var Model = require("./fishbone");              // require module (Node only)

var Pirate = Model({                            // simple class creator
  likes: "GROG",                                // instance properties
  init: function(name){                         // init is the main entrance = name;                           // options can be passed
    this.grogs = 0;
  drink: function(){                            // instance method
    if (++this.grogs >= 100){
      this.trigger("drunk");                    // trigger an event
  yell: function(){
    console.log("WANT MORE: " + this.likes);    // this is always in context

var Captain = Pirate.extend({                   // simple inheritance
  likes: "STRONG GROG",                         // override property
  yell: function(){                             // override method
    console.log("Avast, me hearties!");
    this.__yell();                              // call super method

var captain = new Captain("Jack"),              // create an instance
  rounds = 20;

captain.on("drunk", captain.yell);              // add event listener

function neverbeingcalled(){                    // pseudo listener

captain.on("drunk", neverbeingcalled);          // add event listener"drunk", neverbeingcalled);         // remove event listener

while (rounds--){
    .drink()                                    // chaining FTW!
    .drink()                                    // chaining FTW!
    .drink()                                    // chaining FTW!
    .drink()                                    // chaining FTW!
    .drink();                                   // chaining FTW!


Include fishbone.min.js or copy and paste this:

Model=function a(b,c,d,e){function f(){var a=this,f={};a.on=function(b,c){return(f[b]||
(f[b]=[])).push(c),a},a.trigger=function(a,b){for(var c=f[a],d=0;c&&d<c.length;)c[d++](
b)},,e){for(d=f[b]||[];e&&(c=d.indexOf(e))>-1;)d.splice(c,1);return f[b]
=e?d:[],a};for(c in b)d=b[c],a[c]="function"==typeof d?function(){return(d=this.apply(a,
arguments))===e?a:d}.bind(d):d;a.init&&a.init.apply(a,arguments)}return f.extend=function
(f){d={};for(c in b)d[c]=b[c];for(c in f)d[c]=f[c],b[c]!==e&&(d["__"+c]=b[c]);return a(d)
},f},"object"==typeof module&&(module.exports=Model);                         // c-{{{-<

Install via npm:

npm install fishbone

Install via bower:

bower install --save 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:


Developed by Martin Kleppe at Ubilabs.

Released under the WTFPL license.


You can’t perform that action at this time.