Naughty Programmer's Madness

    This package has been deprecated

    Author message:

    use

    es6like-class

    0.2.4 • Public • Published

    es6like-class NPM version Build Status Coverage

    Write es6 like classes in es5 with a few more features

    Cover some limitations to the current implementation of classes in es6:

    • define properties
    • use traits

    Use

    var newClass = require('es6like-class').newClass;
     
    var A = newClass({
        constructor: function A(value) {
            this.initialized = value;
        }
    });
     
    var B = newClass({
        extends: A,
     
        constructor: function B(value) {
            assert.strictEqual(this.constructor, B);
            this.bValue = value;
        }
    });
     

    Class special properties

    • abstract: set the class as abstract
    • constructor: this is the constructor of the class, like the constructor function in es6 classes
    • extends: extends a class from another or from an object
    • implements: light checks over expected implementations and warn eventually when something is missing
    • prototype
    • static: define static properties in the class
    • with: an array of traits, objects with properties

    Keywords

    Install

    npm i es6like-class

    DownloadsWeekly Downloads

    8

    Version

    0.2.4

    License

    MIT

    Last publish

    Collaborators

    • avatar