{"_id":"cls","_rev":"16-11d558fb8dba5ee7732e85d65ac6289f","name":"cls","description":"Class factory featuring inheritance of static properties, static constructors, lazy population of prototypes, and this._super.","dist-tags":{"latest":"0.1.5"},"versions":{"0.1.0":{"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.0","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.0","dist":{"shasum":"4722aa290bc5cad819e1ba47b90b0eec57579b32","tarball":"https://registry.npmjs.org/cls/-/cls-0.1.0.tgz","integrity":"sha512-Bcj5RNh/IJmxnXIF1uSpROuE9g9eTqaMp66vPKcyeyaVI5jw50dI/fZiL50hmK+bAcvgKV9W2+poWrros2lS1w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAsvrqAAalMoE+MECjjqN2sFm/+FyTcSbhl+EDR/VwubAiA1Ku7iads+BxPr3srL9dOSE3R6YQILB18hNSMdnmsKqg=="}]},"_from":".","_npmVersion":"1.2.30","_npmUser":{"name":"benjamn","email":"bn@cs.stanford.edu"},"maintainers":[{"name":"benjamn","email":"bn@cs.stanford.edu"}]},"0.1.1":{"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.1","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.1","dist":{"shasum":"8044508373acd6c4cd2e0c7c3e82fd522306069d","tarball":"https://registry.npmjs.org/cls/-/cls-0.1.1.tgz","integrity":"sha512-DpTG+8NdfJKbompg6Zh0koUttz9Fcw5kLXNMGDqTbVTT71nvqyTUn5SKQlT2+v7izVNxCWR49ywXHhOuDZdtlA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCwgMcWKHbynld5fXFOZTu/0BfxilUEDhS0l/cZQ5VeTwIhANtNXDOEDPc2N+4+qcl4C6p1hNjoAK+StpTRWRyEEIY1"}]},"_from":".","_npmVersion":"1.2.30","_npmUser":{"name":"benjamn","email":"bn@cs.stanford.edu"},"maintainers":[{"name":"benjamn","email":"bn@cs.stanford.edu"}]},"0.1.2":{"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":"https://registry.npmjs.org/cls/-/cls-0.1.2.tgz","integrity":"sha512-W5mO8aE8GmPM5+d+XWOZJhpcoAj7fs3AVJOoCYp5h77R4vtsy6unO38PJZ1fvRh8kk/QDtdpoC7fnGbHC/hPRA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCbgg6sbbVpXtsjuqPGbai28LlBxIwklHdBmYWHWpsCdAIhAPjQ/mIrxjWyu6KQD71H9eHdak9vIxzCRySanHD2AF+z"}]},"_from":".","_npmVersion":"1.2.30","_npmUser":{"name":"benjamn","email":"bn@cs.stanford.edu"},"maintainers":[{"name":"benjamn","email":"bn@cs.stanford.edu"}]},"0.1.3":{"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.3","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.3","dist":{"shasum":"4a896404e6e5a99bf6bb966000b4fd4c27e19b0b","tarball":"https://registry.npmjs.org/cls/-/cls-0.1.3.tgz","integrity":"sha512-QAUagB60JvlfwkoxtTz0FvbPwRdm04tiamEzluuB3sUayd0LH37ZH5iCchrURAPoXmSXjz7QVFz5uc7x+hRkhA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD7ju6vUXeKSZnpqay/EE2g91vPOlSmmoNyAMJV4aej8AIhAO51SskBUqkP5Z7QkVYd7TnRpIYTXFnfkiaaIlaxFl63"}]},"_from":".","_npmVersion":"1.2.30","_npmUser":{"name":"benjamn","email":"bn@cs.stanford.edu"},"maintainers":[{"name":"benjamn","email":"bn@cs.stanford.edu"}]},"0.1.4":{"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.4","homepage":"http://github.com/benjamn/cls","repository":{"type":"git","url":"git://github.com/benjamn/cls.git"},"main":"main.js","scripts":{"test":"node ./node_modules/mocha/bin/mocha --reporter spec"},"dependencies":{},"devDependencies":{"mocha":"~1.18.2"},"engines":{"node":">= 0.6"},"bugs":{"url":"https://github.com/benjamn/cls/issues"},"_id":"cls@0.1.4","dist":{"shasum":"209e3531edaed42c97107dc7d78c1f86a868a97b","tarball":"https://registry.npmjs.org/cls/-/cls-0.1.4.tgz","integrity":"sha512-9TAn80GjuBhS0fQbNkZ+iCl1HmCsKcunLH2yImTbIyl7QMjdEvGCUk/AIhujkSoNufxfW/4QvmLoMw5aCI6yoQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICTUTOKIzTpNhNTD1ksXTPrCFEOB1B2oihp/ObBNeS4VAiEAq862W1pfzfefy4fjiECFLgj0cZi8H+k3zfB155tmHXc="}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"benjamn","email":"bn@cs.stanford.edu"},"maintainers":[{"name":"benjamn","email":"bn@cs.stanford.edu"}]},"0.1.5":{"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.5","homepage":"http://github.com/benjamn/cls","repository":{"type":"git","url":"git://github.com/benjamn/cls.git"},"license":"MIT","main":"main.js","scripts":{"test":"node ./node_modules/mocha/bin/mocha --reporter spec"},"dependencies":{},"devDependencies":{"mocha":"~1.18.2"},"engines":{"node":">= 0.6"},"bugs":{"url":"https://github.com/benjamn/cls/issues"},"_id":"cls@0.1.5","dist":{"shasum":"df3218cf9d1480747f584d88b19b74c6b281317b","tarball":"https://registry.npmjs.org/cls/-/cls-0.1.5.tgz","integrity":"sha512-l5BPpQaNDud5DtmzvPrs6/XmsK0Rsp+xhhNTGLtUPb2x3zrEYOb2alBkVw3YyzKMf3v6py+i9LBE22b2vgGO7Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE8hG+yrd6UXqXGAUHU48SQdgumJ9SalIyP+czdW21eUAiB3b1n/emHK2iYm9YN9eEL0YX9UGO/G43Fh5lpe7vcFRw=="}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"benjamn","email":"bn@cs.stanford.edu"},"maintainers":[{"name":"benjamn","email":"bn@cs.stanford.edu"}]}},"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","maintainers":[{"name":"benjamn","email":"bn@cs.stanford.edu"}],"time":{"modified":"2022-06-13T06:16:42.954Z","created":"2013-06-15T18:56:32.251Z","0.1.0":"2013-06-15T18:56:33.900Z","0.1.1":"2013-06-15T20:06:58.772Z","0.1.2":"2013-06-15T20:16:01.416Z","0.1.3":"2013-06-15T20:35:55.540Z","0.1.4":"2014-04-02T22:01:15.163Z","0.1.5":"2014-05-26T18:09:57.451Z"},"author":{"name":"Ben Newman","email":"bn@cs.stanford.edu"},"repository":{"type":"git","url":"git://github.com/benjamn/cls.git"},"homepage":"http://github.com/benjamn/cls","keywords":["class","inheritance","static","lazy","super","prototype","extend"],"bugs":{"url":"https://github.com/benjamn/cls/issues"},"readmeFilename":"README.md","license":"MIT","users":{"zhangyaochun":true}}