{"id":18062814,"url":"https://github.com/ded/klass","last_synced_at":"2025-05-16T13:05:29.308Z","repository":{"id":58222795,"uuid":"1457065","full_name":"ded/klass","owner":"ded","description":"a utility for creating expressive classes in JavaScript","archived":false,"fork":false,"pushed_at":"2015-07-16T03:28:45.000Z","size":304,"stargazers_count":750,"open_issues_count":9,"forks_count":78,"subscribers_count":32,"default_branch":"master","last_synced_at":"2025-04-12T09:19:52.593Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ded.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-03-08T23:59:49.000Z","updated_at":"2025-02-10T06:53:45.000Z","dependencies_parsed_at":"2022-09-01T12:23:00.430Z","dependency_job_id":null,"html_url":"https://github.com/ded/klass","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ded%2Fklass","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ded%2Fklass/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ded%2Fklass/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ded%2Fklass/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ded","download_url":"https://codeload.github.com/ded/klass/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248543844,"owners_count":21121838,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-31T05:08:31.334Z","updated_at":"2025-04-12T09:19:58.683Z","avatar_url":"https://github.com/ded.png","language":"JavaScript","funding_links":[],"categories":["Class"],"sub_categories":["Runner"],"readme":"## Klass\nAn expressive, cross platform JavaScript Class provider with a classical interface to prototypal inheritance.\n\n## API\n### creating a Class\n\n``` js\nvar Person = klass(function (name) {\n  this.name = name\n})\n  .statics({\n    head: ':)',\n    feet: '_|_'\n  })\n  .methods({\n    walk: function () {}\n  })\n```\n\n### Subclassing\n\n``` js\nvar SuperHuman = Person.extend(function (name) {\n  // super class is automagically called\n})\n  .methods({\n    walk: function() {\n      this.supr()\n      this.fly()\n    },\n\n    fly: function() {}\n\n  })\n\nnew SuperHuman('Zelda').walk()\n```\n\n### Object Literal Interface\n\n``` js\nvar Foo = klass({\n  foo: 0,\n  initialize: function() {\n    this.foo = 1\n  },\n  getFoo: function () {\n    return this.foo\n  },\n  setFoo: function (x) {\n    this.foo = x\n    return this.getFoo()\n  }\n})\n```\n\n*note: initialize will be called on class invocation*\n\n### Implement\n\nbecause sometimes you want to overwrite OR mixin an instance method\n\n``` js\n// note you can optionally pass an object literal to extend too ;)\nvar Alien = SuperHuman.extend({\n  beam: function() {\n    this.supr()\n    // beam into space\n  }\n})\n\nvar Spazoid = new Alien('Zoopo')\n\nif (beamIsDown) {\n  Spazoid.implement({\n    beam: function() {\n      this.supr()\n      // fallback to jets\n      this.jets()\n    }\n  })\n}\n```\n\n## Environments\nKlass is [Common JS](http://commonjs.org) compliant and provides the [Modules 1.1](http://wiki.commonjs.org/wiki/Modules/1.1) interface to allow two flavors of development. See the implementations below:\n\n### Browser\n\n``` html\n\u003cscript src=\"path/to/klass.js\"\u003e\u003c/script\u003e\n\u003c!-- klass() is exposed to context --\u003e\n```\n\n### As a node module\n\n``` sh\nnpm install klass\n```\n\n``` js\nvar klass = require('klass')\n```\n\n### Ender compatibility\nadd `klass` to your [ender](http://enderjs.com) compilation\n\n``` sh\nender add klass\n```\n\n### Developers\n\n``` sh\nnpm install\nmake\nmake test\n```\n\nKeep your edits localized to `src/klass.js`\n\n## LICENSE\n    MIT\n\n### Happy Klassing!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fded%2Fklass","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fded%2Fklass","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fded%2Fklass/lists"}