extendonclass

Add a backbone-like extend method onto your CoffeeScript classes, making it easy for JavaScript users to extend your CoffeeScript classes

npm install extendonclass
55 downloads in the last day
560 downloads in the last week
2 831 downloads in the last month

Extend on Class

Build Status NPM version Gittip donate button Flattr donate button PayPayl donate button

Add a backbone-like extend method onto your CoffeeScript classes, making it easy for JavaScript users to extend your CoffeeScript classes

Install

Node

  • Use: require('extendonclass')
  • Install: npm install --save extendonclass

Browserify

  • Use: require('extendonclass')
  • Install: npm install --save extendonclass
  • CDN URL: //wzrd.in/bundle/extendonclass@1.0.0

Ender

  • Use: require('extendonclass')
  • Install: ender add extendonclass

Usage

# Import
{extendOnClass} = require('extendonclass')

# Fixtures
class A
    name: 'default'

    constructor: (name) ->
        @name = name  if name

    @extend: extendOnClass

`
var B = A.extend({
    name: 'unknown'
});

var C = B.extend({
    constructor: function (name) {
        if ( name )  this.name = name.toUpperCase();
    }
});

# Tests
console.log('---');

var a = new A();
console.log(a.name)  // 'default'

var aa = new A('bob');
console.log(aa.name)  // 'bob'

var b = new B();
console.log(b.name)  // 'unknown'

var bb = new B('bob');
console.log(bb.name)  // 'bob'

var c = new C();
console.log(c.name)  // 'unknown'

var cc = new C('bob');
console.log(cc.name)  // 'BOB'

History

Discover the change history by heading on over to the HISTORY.md file.

Contribute

Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

Backers

Maintainers

These amazing people are maintaining this project:

Sponsors

No sponsors yet! Will you be the first?

Gittip donate button Flattr donate button PayPayl donate button

Contributors

No contributors yet! Will you be the first? Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

License

Licensed under the incredibly permissive MIT license

Copyright © 2013+ Bevry Pty Ltd us@bevry.me (http://bevry.me)

npm loves you