Livescript has a pretty sweet class system. Shame we can't use it in JS-land.
OR CAN WE.
const Base = require'estira';var Foo = Baseextendthisbar = bar;return thisbar + baz;;var foo = "hello ";foofrob"world"; //⇒ "hello world"
Base class with the bare minimal needed for inheritance. Extend it, it doesn't do much on its own.
Returns a prototypal subclass of
Superclass's instance and class properties, extended with the object passed in. If
methods contains a method called
initialize, it is used as
Subclass's constructor. If
initialize is omitted, it delegates to the parent class' constructor.
Extends the "metaclass" of
Class. Lets you add static methods, which may be inherited.
Refers to the parent class implementation of the function. Lets you call super methods like
var Superclass = Baseextendreturn "hello";;var Subclass = Superclassextendquux:return quuxsuper$ + " world";;
If you want to extend a class that doesn't derive from
EventEmitter), you can shoehorn estira onto it using
Sub = Base.extend.call(EventEmitter, methods). Classes created this way can be further extended, and
super$ calls still work.
MIT. © 2014 Matt Brennan.