{"_id":"class","_rev":"15-d20377698cb1aebbdb5cd402b96b6df4","name":"class","description":"A simple yet powerful Ruby-like Class inheritance system","dist-tags":{"latest":"0.1.4"},"versions":{"0.1.0":{"name":"class","preferGlobal":true,"version":"0.1.0","author":{"name":"Jared Grippe","email":"jared@deadlyicon.com"},"description":"A simple yet powerful Ruby-like Class inheritance system","main":"class.js","repository":{"type":"git","url":"https://github.com/deadlyicon/class.js.git"},"scripts":{"test":"mocha -R spec"},"keywords":["class","Class","Constructor","prototype","inheritance","class inheritance"],"analyze":false,"devDependencies":{"mocha":"*","expect.js":"*"},"license":"MIT","engines":{"node":">=0.6"},"readme":"class.js\n========\n\nA super simple ruby like class system with class property and instance property inheritance.\n\n## Class.js does not use constructors\n\n```javascript\nvar Animal = Class.new()\nnew Animal //=> TypeError: object is not a function\n```\n\nThe reason `Animal` is not a Function is because functions cannot delegate their properties to another Function.\n\n\n## Examples\n\n```javascript\nvar Animal = Class.new({\n  initialize: function(){\n    this.birthdate = new Date;\n  }\n});\n\nvar Mammal = Animal.subclass(function(){\n\n  this.initialize = function(name){\n    this.name = name\n    this.super('initialize').apply(this);\n  };\n\n});\n\nvar Dog    = Mammal.subclass();\n\nvar Cat    = Mammal.subclass();\n\nvar sparky = Dog.new('sparky');\n\nvar mitten = Cat.new('mitten');\n```\n\n## Tests\n\n```bash\nnpm install mocha\nnpm install expect.js\nmocha -R list\n```\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/deadlyicon/class.js/issues"},"_id":"class@0.1.0","dist":{"shasum":"7033cacbd03a57649881f2eed06e5a673b5b1304","tarball":"https://registry.npmjs.org/class/-/class-0.1.0.tgz","integrity":"sha512-+VaFsNg7+zihhG0PmJ0GA1tN0BvXGqcFkZ5BfGCboIOoyOIkECHnbeqkJzsoMZTFliP+284PX1t2kK18owwRBg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD6vayb/or70RYUacWkOc54E59GVbMTMnLaxbS5X55r/gIgNslFIckH9F0sRrJaI6UwqNiCwTsOt/95EnvxYCXgHWs="}]},"_from":".","_npmVersion":"1.3.5","_npmUser":{"name":"deadlyicon","email":"npmjs.org@deadlyicon.com"},"maintainers":[{"name":"deadlyicon","email":"npmjs.org@deadlyicon.com"}]},"0.1.1":{"name":"class","preferGlobal":true,"version":"0.1.1","author":{"name":"Jared Grippe","email":"jared@deadlyicon.com"},"description":"A simple yet powerful Ruby-like Class inheritance system","main":"class.js","repository":{"type":"git","url":"https://github.com/deadlyicon/class.js.git"},"scripts":{"test":"mocha -R spec"},"keywords":["class","Class","Constructor","prototype","inheritance","class inheritance"],"analyze":false,"devDependencies":{"mocha":"*","expect.js":"*"},"license":"MIT","engines":{"node":">=0.6"},"readme":"class.js\n========\n\nA super small ruby-ish class system with both class and class instance  inheritance.\n\n## Example usage:\n\n```javascript\n\nvar Animal = Class.new(function(){\n\n  this.class.find = function(id, callback){\n    // $.getJSON('/animals/'+id, this.new.bind(this));\n  };\n\n  this.initialize = function(attributes){\n    this.birthday = new Date;\n    this.extend(attributes);\n  };\n\n});\n\nvar Mammal = Animal.subclass({\n  warmBlooded: true\n});\n\nvar HasLegs = {\n  walk: function(feet, direction){\n    console.log(this.name, 'is walking', feet, 'feet toward', direction);\n  }\n};\n\nvar Biped = Mammal.subclass(function(){\n  this.numberOfLegs = 2;\n  this.extend(HasLegs);\n});\n\nvar Quadruped = Mammal.subclass({\n  numberOfLegs: 4,\n});\n\nQuadruped.include(HasLegs);\n\nvar Dingo = Biped.subclass();\n\nvar Dog = Quadruped.subclass();\n\nvar jumpy = Dingo.new({name:'Jumpy'});\njumpy.walk(10,'north');\n\nvar sparky = Dog.find(12);\n\n```\n\n## Class.js does not use constructors\n\n```javascript\nnew Animal //=> TypeError: object is not a function\n```\n\nThe reason `Animal` is not a `Function` is because functions cannot be created with a prototype other than `Function.prototype`.\n\n\n## Extend\n\nBoth the `Class` and `Class#prototype` objects have an extend function that supports plain objects as well as functions\n\n```javascript\nvar Kitten = Class.new();\n\nKitten.extend({\n  defaultFurColor: 'orange'\n});\n\nKitten.defaultFurColor; //= 'orange'\n\nKitten.extend(function(){\n  this.brown = true;\n});\n\nKitten.defaultFurColor; //= 'brown'\n\nKitten.prototype.extend({\n  age: 1\n});\n\nKitten.new().age; //= 1\n\nKitten.prototype.extend(function(){\n  this.age = 12;\n});\n\nKitten.new().age; //= 12\n```\n## subclass\n\nWhen you call `Animal.subclass()` it returns a new object that points to `Animal`. The new object's prototype property is also a new object that points to `Animal.prototype`.\n\n## Tests\n\n```bash\nnpm install mocha\nnpm install expect.js\nmocha -R spec\n```\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/deadlyicon/class.js/issues"},"_id":"class@0.1.1","dist":{"shasum":"8f3bd682efb5cf21a473a5d7be8d5f2436561e98","tarball":"https://registry.npmjs.org/class/-/class-0.1.1.tgz","integrity":"sha512-yUBdSIIv/ziJ7dPDhf1f63fhuPmfrPN6PBgQCU1lcWpR/EjOS+v8xZ5tJRnHP1pe36dcwq00x72KGnwanrVWaQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDD6cclmuu0mF0J9EfZCEdHO49iYyHmavef4wvCTnrGIAiEAnltevAfxQcUmCzzzizbEXB/fS5lge9naJnxljygroms="}]},"_from":".","_npmVersion":"1.3.5","_npmUser":{"name":"deadlyicon","email":"npmjs.org@deadlyicon.com"},"maintainers":[{"name":"deadlyicon","email":"npmjs.org@deadlyicon.com"}]},"0.1.2":{"name":"class","preferGlobal":true,"version":"0.1.2","author":{"name":"Jared Grippe","email":"jared@deadlyicon.com"},"description":"A simple yet powerful Ruby-like Class inheritance system","main":"class.js","repository":{"type":"git","url":"https://github.com/deadlyicon/class.js.git"},"scripts":{"test":"mocha -R spec"},"keywords":["class","Class","Constructor","prototype","inheritance","class inheritance"],"analyze":false,"devDependencies":{"mocha":"*","expect.js":"*"},"license":"MIT","engines":{"node":">=0.6"},"readme":"class.js\n========\n\nA super small ruby-ish class system with both class and class instance  inheritance.\n\n## Example usage:\n\n```javascript\n\nvar Animal = Class.new(function(){\n\n  this.class.find = function(id, callback){\n    // $.getJSON('/animals/'+id, this.new.bind(this));\n  };\n\n  this.initialize = function(attributes){\n    this.birthday = new Date;\n    this.extend(attributes);\n  };\n\n});\n\nvar Mammal = Animal.subclass({\n  warmBlooded: true\n});\n\nvar HasLegs = {\n  walk: function(feet, direction){\n    console.log(this.name, 'is walking', feet, 'feet toward', direction);\n  }\n};\n\nvar Biped = Mammal.subclass(function(){\n  this.numberOfLegs = 2;\n  this.extend(HasLegs);\n});\n\nvar Quadruped = Mammal.subclass({\n  numberOfLegs: 4,\n});\n\nQuadruped.include(HasLegs);\n\nvar Kangaroo = Biped.subclass();\n\nvar Dog = Quadruped.subclass();\n\nvar jumpy = Kangaroo.new({name:'Jumpy'});\njumpy.walk(10,'north');\n\nvar sparky = Dog.find(12);\n\n```\n\n## Class.js does not use constructors\n\n```javascript\nnew Animal //=> TypeError: object is not a function\n```\n\nThe reason `Animal` is not a `Function` is because functions cannot be created with a prototype other than `Function.prototype`.\n\n\n## Extend\n\nBoth the `Class` and `Class#prototype` objects have an extend function that supports plain objects as well as functions\n\n```javascript\nvar Kitten = Class.new();\n\nKitten.extend({\n  defaultFurColor: 'orange'\n});\n\nKitten.defaultFurColor; //= 'orange'\n\nKitten.extend(function(){\n  this.brown = true;\n});\n\nKitten.defaultFurColor; //= 'brown'\n\nKitten.prototype.extend({\n  age: 1\n});\n\nKitten.new().age; //= 1\n\nKitten.prototype.extend(function(){\n  this.age = 12;\n});\n\nKitten.new().age; //= 12\n```\n## subclass\n\nWhen you call `Animal.subclass()` it returns a new object that points to `Animal`. The new object's prototype property is also a new object that points to `Animal.prototype`.\n\n## Tests\n\n```bash\nnpm install mocha\nnpm install expect.js\nmocha -R spec\n```\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/deadlyicon/class.js/issues"},"_id":"class@0.1.2","dist":{"shasum":"f1658415b8fde6752cb51030995660892bf8e705","tarball":"https://registry.npmjs.org/class/-/class-0.1.2.tgz","integrity":"sha512-ONgp4OS54coD8XjKAX/BbbQamFNHZH45uJWs2Wp8KPjgYEtpYVHJHLI6gIef7wbNNQERDZ8R05UyoHAIu9czJg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDgFD2aUr52NO/nCR2kZ+jIvyCWJBSbY7A9bHKx4CLpSwIgBz3UlleTP67+S834gnt2QjRYGVjWJEm6jbetZWPywwE="}]},"_from":".","_npmVersion":"1.3.5","_npmUser":{"name":"deadlyicon","email":"npmjs.org@deadlyicon.com"},"maintainers":[{"name":"deadlyicon","email":"npmjs.org@deadlyicon.com"}]},"0.1.3":{"name":"class","preferGlobal":true,"version":"0.1.3","author":{"name":"Jared Grippe","email":"jared@deadlyicon.com"},"description":"A simple yet powerful Ruby-like Class inheritance system","main":"class.js","repository":{"type":"git","url":"https://github.com/deadlyicon/class.js.git"},"scripts":{"test":"mocha -R spec"},"keywords":["class","Class","Constructor","prototype","inheritance","class inheritance"],"analyze":false,"devDependencies":{"mocha":"*","expect.js":"*","object-inspect":"*"},"license":"MIT","engines":{"node":">=0.6"},"readme":"class.js\n========\n\nA super small ruby-ish class system with both class and class instance  inheritance.\n\n## Example usage:\n\n```javascript\n\nvar Animal = Class.new(function(){\n\n  this.class.find = function(id, callback){\n    // $.getJSON('/animals/'+id, this.new.bind(this));\n  };\n\n  this.initialize = function(attributes){\n    this.birthday = new Date;\n    this.extend(attributes);\n  };\n\n});\n\nvar Mammal = Animal.subclass({\n  warmBlooded: true\n});\n\nvar HasLegs = {\n  walk: function(feet, direction){\n    console.log(this.name, 'is walking', feet, 'feet toward', direction);\n  }\n};\n\nvar Biped = Mammal.subclass(function(){\n  this.numberOfLegs = 2;\n  this.extend(HasLegs);\n});\n\nvar Quadruped = Mammal.subclass({\n  numberOfLegs: 4,\n});\n\nQuadruped.include(HasLegs);\n\nvar Kangaroo = Biped.subclass();\n\nvar Dog = Quadruped.subclass();\n\nvar jumpy = Kangaroo.new({name:'Jumpy'});\njumpy.walk(10,'north');\n\nvar sparky = Dog.find(12);\n\n```\n\n## Class.js does not use constructors\n\n```javascript\nnew Animal //=> TypeError: object is not a function\n```\n\nThe reason `Animal` is not a `Function` is because functions cannot be created with a prototype other than `Function.prototype`.\n\n\n## Extend\n\nBoth the `Class` and `Class#prototype` objects have an extend function that supports plain objects as well as functions\n\n```javascript\nvar Kitten = Class.new();\n\nKitten.extend({\n  defaultFurColor: 'orange'\n});\n\nKitten.defaultFurColor; //= 'orange'\n\nKitten.extend(function(){\n  this.brown = true;\n});\n\nKitten.defaultFurColor; //= 'brown'\n\nKitten.prototype.extend({\n  age: 1\n});\n\nKitten.new().age; //= 1\n\nKitten.prototype.extend(function(){\n  this.age = 12;\n});\n\nKitten.new().age; //= 12\n```\n## subclass\n\nWhen you call `Animal.subclass()` it returns a new object that points to `Animal`. The new object's prototype property is also a new object that points to `Animal.prototype`.\n\n## modules\n\nA Module can either be a plain object or a function.\n\n``\nvar Car = Class.new(function(){\n  this.initialize = this.extend;\n});\n\nvar HasEngine = {\n  engine: function(){\n    if (!this._engine) this._engine = Engine.new(this);\n    return this._engine;\n  }\n};\n\nvar PersistedWithLocalStorage = function(){\n\n  function save(){\n    // localStorage[…] = …;\n    return this;\n  }\n\n  function find(id){\n    // return this.new(localStorage[…]);\n  }\n\n  return function(){\n    this.class.find = find;\n    this.save = save;\n  };\n\n}();\n\nCar.include(HasEngine, PersistedWithLocalStorage);\n\ntypeof Car.find //= 'function'\ntypeof Car.new().save //= 'function'\ntypeof Car.new().engine //= 'function'\n\n## Tests\n\n```bash\nnpm install mocha\nnpm install expect.js\nmocha -R spec\n```\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/deadlyicon/class.js/issues"},"_id":"class@0.1.3","dist":{"shasum":"ecff20c57847bbf76ed6e14caf778979faf5aa5b","tarball":"https://registry.npmjs.org/class/-/class-0.1.3.tgz","integrity":"sha512-VvNW/mV1lD79eQyB5xEg8w0CtDvPzpliHCkWlrMEJboAmxnmhEZ+TSGEAry1iclr1pGYkR725KsbD8a5cTWUcA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDY1yC03kn0zF4hNLHmeM2N2NlAIlo75Qa8eOkF0O8VRgIhAMdw8JWv2VA9XzzwFNCLJh339kIDpLHSB/D6m//z8T1j"}]},"_from":".","_npmVersion":"1.3.5","_npmUser":{"name":"deadlyicon","email":"npmjs.org@deadlyicon.com"},"maintainers":[{"name":"deadlyicon","email":"npmjs.org@deadlyicon.com"}]},"0.1.4":{"name":"class","preferGlobal":true,"version":"0.1.4","author":{"name":"Jared Grippe","email":"jared@deadlyicon.com"},"description":"A simple yet powerful Ruby-like Class inheritance system","main":"class.js","repository":{"type":"git","url":"https://github.com/deadlyicon/class.js.git"},"scripts":{"test":"mocha -R spec"},"keywords":["class","Class","Constructor","prototype","inheritance","class inheritance"],"analyze":false,"devDependencies":{"mocha":"*","expect.js":"*","object-inspect":"*"},"license":"MIT","engines":{"node":">=0.6"},"readme":"class.js\n========\n\nA super small ruby-ish class system with both class and class instance  inheritance.\n\n[![Build Status](https://travis-ci.org/deadlyicon/class.js.png)](https://travis-ci.org/deadlyicon/class.js)\n\n## Example usage:\n\n```javascript\n\nvar Animal = Class.new(function(){\n\n  this.class.find = function(id, callback){\n    // $.getJSON('/animals/'+id, this.new.bind(this));\n  };\n\n  this.initialize = function(attributes){\n    this.birthday = new Date;\n    this.extend(attributes);\n  };\n\n});\n\nvar Mammal = Animal.subclass({\n  warmBlooded: true\n});\n\nvar HasLegs = {\n  walk: function(feet, direction){\n    console.log(this.name, 'is walking', feet, 'feet toward', direction);\n  }\n};\n\nvar Biped = Mammal.subclass(function(){\n  this.numberOfLegs = 2;\n  this.extend(HasLegs);\n});\n\nvar Quadruped = Mammal.subclass({\n  numberOfLegs: 4,\n});\n\nQuadruped.include(HasLegs);\n\nvar Kangaroo = Biped.subclass();\n\nvar Dog = Quadruped.subclass();\n\nvar jumpy = Kangaroo.new({name:'Jumpy'});\njumpy.walk(10,'north');\n\nvar sparky = Dog.find(12);\n\n```\n\n## Class.js does not use constructors\n\n```javascript\nnew Animal //=> TypeError: object is not a function\n```\n\nThe reason `Animal` is not a `Function` is because functions cannot be created with a prototype other than `Function.prototype`.\n\n\n## Extend\n\nBoth the `Class` and `Class#prototype` objects have an extend function that supports plain objects as well as functions\n\n```javascript\nvar Kitten = Class.new();\n\nKitten.extend({\n  defaultFurColor: 'orange'\n});\n\nKitten.defaultFurColor; //= 'orange'\n\nKitten.extend(function(){\n  this.brown = true;\n});\n\nKitten.defaultFurColor; //= 'brown'\n\nKitten.prototype.extend({\n  age: 1\n});\n\nKitten.new().age; //= 1\n\nKitten.prototype.extend(function(){\n  this.age = 12;\n});\n\nKitten.new().age; //= 12\n```\n## subclass\n\nWhen you call `Animal.subclass()` it returns a new object that points to `Animal`. The new object's prototype property is also a new object that points to `Animal.prototype`.\n\n## modules\n\nA Module can either be a plain object or a function.\n\n```javascript\nvar Car = Class.new(function(){\n  this.initialize = this.extend;\n});\n\nvar HasEngine = {\n  engine: function(){\n    if (!this._engine) this._engine = Engine.new(this);\n    return this._engine;\n  }\n};\n\nvar PersistedWithLocalStorage = function(){\n\n  function save(){\n    // localStorage[…] = …;\n    return this;\n  }\n\n  function find(id){\n    // return this.new(localStorage[…]);\n  }\n\n  return function(){\n    this.class.find = find;\n    this.save = save;\n  };\n\n}();\n\nCar.include(HasEngine, PersistedWithLocalStorage);\n\ntypeof Car.find //= 'function'\ntypeof Car.new().save //= 'function'\ntypeof Car.new().engine //= 'function'\n```\n\n## Tests\n\n```bash\nnpm install mocha\nnpm install expect.js\nmocha -R spec\n```\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/deadlyicon/class.js/issues"},"_id":"class@0.1.4","dist":{"shasum":"92620d448694603457a39da296554d36ceea2b1f","tarball":"https://registry.npmjs.org/class/-/class-0.1.4.tgz","integrity":"sha512-bLVg+g7slPspef6I/W/TkJG3A4XhUPZyjMaeHc23lVm7hr7jaTgpftQAGtKY2UCa67Zfg17sNGsrC74MWsMDaQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEmCHI/9ODEfe7HYAtSoEfCCVcvI9qJisLTUPnVi0FCnAiBxv9XHaE+CWH/qSJqEQ+ijezFlLQFapBeVCGkMLJ+FZA=="}]},"_from":".","_npmVersion":"1.3.5","_npmUser":{"name":"deadlyicon","email":"npmjs.org@deadlyicon.com"},"maintainers":[{"name":"deadlyicon","email":"npmjs.org@deadlyicon.com"}]}},"readme":"class.js\n========\n\nA super simple ruby like class system with class property and instance property inheritance.\n\n## Class.js does not use constructors\n\n```javascript\nvar Animal = Class.new()\nnew Animal //=> TypeError: object is not a function\n```\n\nThe reason `Animal` is not a Function is because functions cannot delegate their properties to another Function.\n\n\n## Examples\n\n```javascript\nvar Animal = Class.new({\n  initialize: function(){\n    this.birthdate = new Date;\n  }\n});\n\nvar Mammal = Animal.subclass(function(){\n\n  this.initialize = function(name){\n    this.name = name\n    this.super('initialize').apply(this);\n  };\n\n});\n\nvar Dog    = Mammal.subclass();\n\nvar Cat    = Mammal.subclass();\n\nvar sparky = Dog.new('sparky');\n\nvar mitten = Cat.new('mitten');\n```\n\n## Tests\n\n```bash\nnpm install mocha\nnpm install expect.js\nmocha -R list\n```\n","maintainers":[{"name":"deadlyicon","email":"npmjs.org@deadlyicon.com"}],"time":{"modified":"2022-06-13T06:05:33.272Z","created":"2013-08-15T21:33:18.614Z","0.1.0":"2013-08-15T21:33:19.674Z","0.1.1":"2013-08-15T23:00:32.391Z","0.1.2":"2013-08-15T23:06:49.436Z","0.1.3":"2013-08-15T23:36:19.968Z","0.1.4":"2013-08-15T23:48:39.756Z"},"author":{"name":"Jared Grippe","email":"jared@deadlyicon.com"},"repository":{"type":"git","url":"https://github.com/deadlyicon/class.js.git"},"users":{"nickeljew":true,"dodoss":true}}