Uptown
Simplify prototypical inheritance. This tries to provide some simple constructs for providing functionality you get with ES6 classes, such as:
- Constructor functions
- Static class methods
- Getter and setter methods
Install
Using npm:
npm install uptown --save
Using cdn:
dist/uptown.js
contains uptown and requires lodash to be loaded separately. Can be used with requirejs.dist/uptown.min.js
contains minified uptown and dependencies (lodash).
Usage
Use extendify
to add the extend method to a class (note: it mutates the original class).
The extend
class method takes three options arguments:
- Object of instance properties
- Object of static methods and properties
- Object of getter and setter mutators
var extendify = extendify; var {}; Originalprototype { return 'Hello, ' + value;} ; var SubClass = Original;
New classes may also be created using the createClass
function. The createClass
function works just like .extend
.
var createClass = createClass; var Foo = ;