{"id":17503177,"url":"https://github.com/dab0mb/cla6","last_synced_at":"2025-07-11T08:04:34.534Z","repository":{"id":29901691,"uuid":"33447367","full_name":"DAB0mB/cla6","owner":"DAB0mB","description":"ES6 style class system","archived":false,"fork":false,"pushed_at":"2015-07-21T22:26:42.000Z","size":360,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-03T15:24:30.837Z","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/DAB0mB.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":"2015-04-05T16:36:13.000Z","updated_at":"2018-05-16T13:34:02.000Z","dependencies_parsed_at":"2022-09-21T18:12:57.612Z","dependency_job_id":null,"html_url":"https://github.com/DAB0mB/cla6","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAB0mB%2Fcla6","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAB0mB%2Fcla6/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAB0mB%2Fcla6/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DAB0mB%2Fcla6/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DAB0mB","download_url":"https://codeload.github.com/DAB0mB/cla6/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232786401,"owners_count":18576418,"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-19T22:05:35.132Z","updated_at":"2025-01-06T21:09:53.842Z","avatar_url":"https://github.com/DAB0mB.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cla6.js\n\nProvides a class factory with additional functionality, like [`mixins`](#mixins) and [`plugins`](#plugins). Although originally designed for use with [Node.js](http://nodejs.org) and installable via `npm install cla6`,\nit can also be used directly in the browser.\n\nCla6 is also installable via:\n\n- [bower](http://bower.io/): `bower install cla6`\n\n## Basic Example\n\n```js\nvar Cla6 = require('cla6');\n\nvar Parent = Cla6('Parent', {\n  constructor: function() {\n    console.log('parent constructor');\n  },\n\n  parentMethod: function() {\n    console.log('parent method');\n  }\n});\n\nvar Child = Cla6('Child').extend(Parent, {\n  childMethod: function() {\n    this.parentMethod();\n    console.log('child method');\n  },\n\n  get accessor() {\n    console.log('child getter');\n  },\n\n  set accessor(value) {\n    console.log('child setter');\n  }\n});\n\nchild = new Child(); // parent constructor\nchild.childMethod(); // parent method, child method\nchild.accessor = child.accessor; // child getter, child setter\n```\n\n## Why Use It\n\n- Easy to use\n- Easy to read\n- Highliy compatible\n- Defines classes *THE RIGHT WAY*\n\nUnlike classic class definition, Cla6 defines unenumerable prototype properties:\n\n```js\n// Classic class definition\n\nfunction Klass() {\n  this.foo = 'foo';\n  this.bar = 'bar';\n}\n\nKlass.prototype.constructor = Klass;\n\nKlass.prototype.baz = function() {\n  return 'baz';\n};\n\nvar instance = new Klass();\n\n// prints foo, bar, baz\nfor (var k in instance)\n  console.log(k);\n\n// Cla6 class definition\n\nvar Klass = Cla6('Klass', {\n  constructor: function() {\n    this.foo = 'foo';\n    this.bar = 'bar';\n  },\n\n  baz: function() {\n    return 'baz';\n  }\n});\n\nvar instance = new Klass();\n\n// prints foo, bar\nfor (var k in instance)\n  console.log(k);\n```\n\n## Mixins\n\nEach class created by Cla6 can be extended using a mixin. Mixins can be applied at class creation or during run time.\n\n```js\nvar mixin1 = {\n  method1: function() {\n    console.log('mixin1');\n  }\n};\n\nvar mixin2 = {\n  method2: function() {\n    console.log('mixin2');\n  }\n};\n\nvar mixin3 = {\n  method3: function() {\n    console.log('mixin3');\n  }\n};\n\nvar Klass = Cla6('Klass', {\n  constructor: function() {\n    console.log(\"klass\");\n  },\n}).mixin(mixin1, mixin2);\n\nKlass.mixin(mixin3);\n\nvar obj = new Klass(); // klass\nobj.method1(); // mixin1\nobj.method2(); // mixin2\nobj.method3(); // mixin3\n```\n\n## Plugins\n\nA plugin is a module which adds functionality to Cla6 and can be loaded dynamcally. Multipile plugins can be applied and will be called by their order of use.\n\nNote, each plugin will affect the arguments for the next plugin in the plugins chain.\n\n```js\nCla6.use(plugin);\n```\n\nThe official plugins currently available are:\n\n- [cla6-base](https://github.com/DAB0mB/cla6-base)\n- [cla6-hidden](https://github.com/DAB0mB/cla6-hidden)\n\n### Building a plugin\n\nA basic plugin stracture should look like so:\n\n```js\nvar initialize = function(Cla6) {\n  // initializer logic\n};\n\nvar manipulate = function(descriptors, Parent) {\n  // manipulator logic\n};\n\nmodule.exports = {\n  initialize: initialize,\n  manipulate: manipulate\n};\n```\n\n- `initialize` - An optional initializer function which will be called with Cla6 instance once the plugin is used.\n- `manipulate` - A required manipulator function which will be called every time before a class gets created with its descriptors and Parent class.\n\n## Download\n\nThe source is available for download from\n[GitHub](http://github.com/DAB0mB/cla6).\nAlternatively, you can install using Node Package Manager (`npm`):\n\n    npm install cla6","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdab0mb%2Fcla6","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdab0mb%2Fcla6","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdab0mb%2Fcla6/lists"}