{"author":{"name":"Ben Newman","email":"bn@cs.stanford.edu"},"name":"cls","description":"Class factory featuring inheritance of static properties, static constructors, lazy population of prototypes, and this._super.","keywords":["class","inheritance","static","lazy","super","prototype","extend"],"version":"0.1.2","homepage":"http://github.com/benjamn/cls","repository":{"type":"git","url":"git://github.com/benjamn/cls.git"},"main":"main.js","scripts":{"test":"whiskey test/run.js"},"dependencies":{"whiskey":"0.6.x"},"devDependencies":{},"optionalDependencies":{"whiskey":"0.6.x"},"engines":{"node":">= 0.6"},"bugs":{"url":"https://github.com/benjamn/cls/issues"},"_id":"cls@0.1.2","dist":{"shasum":"9460c9b2b77b1ae787ddafc9ed84808badf09555","tarball":"http://registry-npm.ywwl.com/cls/download/cls-0.1.2.tgz","integrity":"sha512-W5mO8aE8GmPM5+d+XWOZJhpcoAj7fs3AVJOoCYp5h77R4vtsy6unO38PJZ1fvRh8kk/QDtdpoC7fnGbHC/hPRA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCbgg6sbbVpXtsjuqPGbai28LlBxIwklHdBmYWHWpsCdAIhAPjQ/mIrxjWyu6KQD71H9eHdak9vIxzCRySanHD2AF+z"}],"size":3902,"noattachment":false,"key":"/cls/-/cls-0.1.2.tgz"},"_from":".","_npmVersion":"1.2.30","_npmUser":{"name":"benjamn","email":"bn@cs.stanford.edu"},"maintainers":[{"name":"benjamn","email":"bn@cs.stanford.edu"}],"directories":{},"readme":"Introduction\n---\n\nStandardized `class` syntax\n[is coming](http://wiki.ecmascript.org/doku.php?id=strawman:maximally_minimal_classes)\nin ECMAScript 6, supposedly, but until then I need a class factory that fills the gap.\n\nFor me that means (in no particular order):\n\n* prototypal inheritance under the hood\n* access to overridden properties (`super`)\n* inheritance of `static` properties\n* `static` constructors\n* close correspondence to ES6 syntax\n* ES5/browser compatibility\n* only-pay-for-what-you-use performance\n* excellent test coverage: [![Build Status](https://travis-ci.org/benjamn/cls.png?branch=master)](https://travis-ci.org/benjamn/cls)\n\nI have no delusions of persuading the world to use this tool. Just try\n`npm search inheritance` some time to see how many other people have come\nup with solutions that work for them.\n\nIf you have a special interest in the tired me-too sport of\npure-JavaScript class factory implementations, you might find this one\ninteresting for its solutions to each of the requirements listed above,\nparticularly the lazy (just-in-time) population of prototype properties.\n\nNote that I did not mention privacy enforcement as a requirement. If you\nneed a mechanism like the `private` keyword in other languages, I have a\nseparate [project](https://npmjs.org/package/private) that works\nseamlessly alongside this one.\n\nInstallation\n---\nFrom NPM:\n\n    npm install cls\n\nFrom GitHub:\n\n    cd path/to/node_modules\n    git clone git://github.com/benjamn/cls.git\n    cd cls\n    npm install .\n\nUsage\n---\n\nOne example will have to suffice for now:\n```js\nvar cls = require(\"cls\");\n\nvar BaseClass = cls.extend({\n    init: function(a, b) {\n        this.sum = a + b;\n    },\n\n    getSum: function() {\n        return this.sum;\n    },\n\n    statics: {\n        name: \"BaseClass\",\n\n        init: function(cls) {\n            cls.zero = new cls(0, 0);\n        }\n    }\n});\n\nvar SubClass = BaseClass.extend({\n    init: function(arg) {\n        this._super(arg, arg);\n        this.sum += 1;\n    },\n\n    statics: {\n        name: \"SubClass\"\n    }\n});\n\nassert(BaseClass.name === \"BaseClass\");\nassert(SubClass.name === \"SubClass\");\n\nassert(new BaseClass(2).getSum() === 4);\nassert(new SubClass(2).getSum() === 5);\n\nassert(SubClass.zero !== BaseClass.zero);\nassert(SubClass.zero instanceof SubClass);\nassert(SubClass.zero.getSum() === 1);\n```\nFor more complex examples, see `test/run.js`.\n","publish_time":1371327361416,"_cnpm_publish_time":1371327361416,"dist-tags":{"latest":"0.1.5"}}