{
    "name": "superb-class",
    "description": "A superb way of creating classes. Focues on OOP stability.",
    "author": [{
        "name" : "Bogdan Mustiata",
        "email" : "bogdan.mustiata@gmail.com"
    }],
    "version": "0.3.2",
    "dependencies": {
    },
    "devDependencies" : {
        "grunt" : "0.4.5",
        "grunt-mocha-test" : "0.12.7",
        "grunt-contrib-clean" : "0.6.0",
        "grunt-contrib-concat" : "0.5.1",
        "assert" : "1.3.0",
        "better-assert" : "1.0.2",
        "chai" : "2.1.1"
    },
    "keywords": [],
    "main": "./lib/superb-class.js",
    "bugs": {
        "url": "https://github.com/bmustiata/superb-class/issues"
    },
    "licenses": [
        {
            "type": "BSD",
            "url": "https://github.com/bmustiata/superb-class/blob/master/LICENSE"
        }
    ],
    "repository": {
        "type": "git",
        "url": "https://github.com/bmustiata/superb-class.git"
    },
    "readme": "# superb-class\nA superb way of doing JS classes.\n## About\nSuperb Class is a simple API that allows creating JS classes with ease,\ndesigned for ES3/5 usage.\nIt's heavily tested, simple to use, and validates your\nclasses against simple programming errors.\n## Install\nIn order to install it you can just do:\n```sh\nnpm install superb-class\n```\n## Usage\nIn its simplest form you can just:\n```javascript\nvar createClass = require('superb-class').createClass;\nvar Dialog = createClass(\"Dialog\", {\n    _title : null,\n    constructor : function(title) {\n        this._title = title;\n    },\n    show : function() {\n        console.log('Dialog.show(): ', this._title);\n    }\n});\nvar dialog = new Dialog('Dialog Title');\ndialog.show();\n```\nThe created class propagates the arguments to the constructor function\nas you might expect. The `this` variable is the variable that will be\nreturned and has already the instance updated to have the base class,\nmixins, and current prototypical items already written.\nA more advanced usage is:\n```javascript\nvar createClass = require('superb-class').createClass;\n// ==========================================================================\n// Dialog Class\n// ==========================================================================\nvar Dialog = createClass({\n    _title : null, // declaring members adds them to checking\n    constructor : function(title) {\n        this._title = title;\n    },\n    show : function() {\n        console.log('Dialog.show(): ', this._title);\n    }\n});\n// ==========================================================================\n// ModalDialog Class\n// ==========================================================================\nvar ModalDialog = createClass(Dialog, {\n    _modal : false,\n    constructor : function(modal, title) {\n        this._super.constructor.call(this, title);\n        this._modal = false;\n    },\n    show : function() {\n        console.log('ModalDialog.show(): ', this._modal, this._title);\n        this._super.show.apply(this, arguments);\n    }\n}, { // static functions\n    create : function(title) {\n        console.log('Static factory create()');\n        return new ModalDialog(true, title);\n    }\n});\n// ==========================================================================\n// Usage\n// ==========================================================================\nvar dialog = ModalDialog.create('dialog_title');\n// equivalent to: new ModalDialog(true, 'dialog_title');\nconsole.log('Is dialog instanceof ModalDialog: ', dialog instanceof ModalDialog);\nconsole.log('Is dialog instanceof Dialog: ', dialog instanceof Dialog);\ndialog.show();\n```\nThis will output:\n```text\nStatic factory create()\nIs dialog instanceof ModalDialog:  true\nIs dialog instanceof Dialog:  true\nModalDialog.show():  false dialog_title\nDialog.show():  dialog_title\n```\n## Full API\nStraight from the sources:\n```javascript\n/**\n * Create a class.\n * @param {string} name The string name of the class.\n * @param {function} superClass The superclass to inherit from. It will be\n *                          available as $super in the this instance, for\n *                          calls on the super class.\n * @param {Array<function>} mixins mixins definitions.\n * @param {Object} instanceProperties Instance properties that should be\n *          created. Properties that are prefixed with _ denode private\n *          properties, and creation of the class will fail if another\n *          property with the same name exists in the parent prototype.\n *          Properties prefixed with $ are protected properties.\n *          Shadowing is allowed only for public and protected members.\n *          The constructor() will be called if present with the arguments\n *          from the function itself.\n * @param {Object} staticProperties Static properties that will be defined\n *          on the returned class itself.\n * @type {function}\n */\nfunction createClass() { /* ... */ }\n```\n## Superb\n### Class name\nIf the class name is given as the first argument, the class name is used in\nthe function creation, so the stack trace will look like you would expect.\nFor example:\n```javascript\nvar Dialog = createClass(\"Dialog\", {\n    show : function() {\n        // in the stack trace here is Dialog.show()\n    }\n});\n```\nIf no class name is provided, the `__anonymous__` name will be used.\n### \\_super Access\nThe \\_super private member is available on the this instance that points to\nthe prototype of the parent class. Thus calls to the base implementation\nof a specific method becomes easier, without holding manual references to\nthe base implementation, or navigating the prototype chain.\n```javascript\nthis._super.show.apply(this, arguments);\n```\n### Private Members\nPrivate members are prefied with \\_.\nPrivate members can not be overwritten by mixins, nor by extending classes.\nIn case this is attempted createClass will throw an error. This is especially\ngood in large APIs where it becomes impossible to check if a private member\nwith a given name is already defined.\nDue to the prototypical nature of JavaScript\nprivate members are available in extending classes. Even if they are available,\nit's strongly discouraged to access them from derived classes.\n```javascript\nvar createClass = require('superb-class').createClass;\nvar Base = createClass({\n    _show : function() {\n        console.log('Base.show()');\n    }\n});\nvar Extend = createClass(Base, {\n    // Fails with:\n    // Error: Private member _show is already defined.\n    _show : function() {\n        console.log('Extend.show()');\n    }\n});\n```\n### Protected Members\nProtected members are prefixed with $.\nProtected members can be overwritten by extending classes, but not by mixins.\nThe reason is this: most likely having abstract classes does make sense to be implemented\nin the extending class, but the implementation being present in a mixin is most likely\na bug.\nNote that mixins can still add both private _and_ protected members to the instance,\nthey just can't override anything from the base class, or clash with\ncurrent prototype items.\n## Change Log\n* 2015-05-11 0.3.1 Export the class names.\n* 2015-05-06 0.3.0 Mocha client tests. IE8 support.\n* 2015-05-04 0.2.4 Client support via bower.\n* 2015-03-09 0.2.3 Stable implementation of createClass.\n",
    "readmeFilename": "README.md",
    "homepage": "http://blog.ciplogic.com"
}
