{"id":15693803,"url":"https://github.com/kbravh/multi-class","last_synced_at":"2025-05-08T05:54:22.297Z","repository":{"id":56373067,"uuid":"284549896","full_name":"kbravh/multi-class","owner":"kbravh","description":"Easy multiple inheritance and composition in JavaScript.","archived":false,"fork":false,"pushed_at":"2020-11-11T16:17:33.000Z","size":60,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-08T05:54:17.108Z","etag":null,"topics":["classes","composition","inheritance","object-oriented-programming","oop"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kbravh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-02T22:08:08.000Z","updated_at":"2023-12-29T20:49:01.000Z","dependencies_parsed_at":"2022-08-15T17:31:18.834Z","dependency_job_id":null,"html_url":"https://github.com/kbravh/multi-class","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbravh%2Fmulti-class","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbravh%2Fmulti-class/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbravh%2Fmulti-class/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbravh%2Fmulti-class/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kbravh","download_url":"https://codeload.github.com/kbravh/multi-class/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253009850,"owners_count":21839713,"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":["classes","composition","inheritance","object-oriented-programming","oop"],"created_at":"2024-10-03T18:49:10.926Z","updated_at":"2025-05-08T05:54:22.273Z","avatar_url":"https://github.com/kbravh.png","language":"JavaScript","readme":"\u003c!-- PROJECT SHIELDS --\u003e\n\u003c!-- [![Contributors][contributors-shield]][contributors-url] --\u003e\n\u003c!-- [![Forks][forks-shield]][forks-url] --\u003e\n\u003c!-- [![Stargazers][stars-shield]][stars-url] --\u003e\n[![Issues][issues-shield]][issues-url]\n[![MIT License][license-shield]][license-url]\n[![LinkedIn][linkedin-shield]][linkedin-url]\n![CircleCI][circle-ci]\n\n\n\n\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/kbravh/multi-class\"\u003e\n    \u003cimg src=\"images/logo.png\" alt=\"Logo\" width=\"80\" height=\"80\"\u003e\n  \u003c/a\u003e\n\n  \u003ch3 align=\"center\"\u003eMULTI-CLASS\u003c/h3\u003e\n\n  \u003cp align=\"center\"\u003e\n    Easy multiple inheritance and composition in JavaScript.\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/kbravh/multi-class/issues\"\u003eReport a Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/kbravh/multi-class/issues\"\u003eRequest a Feature\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\n\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n## Table of Contents\n\n* [About the Project](#about-the-project)\n* [Getting Started](#getting-started)\n  * [Installation](#installation)\n* [Usage](#usage)\n* [Roadmap](#roadmap)\n* [Contributing](#contributing)\n* [License](#license)\n* [Contact](#contact)\n\n\u003c!-- ABOUT THE PROJECT --\u003e\n## About The Project\n\nMulti-inheritance/composition is a very useful feature of Object Oriented Programming, but JavaScript's `Class` syntactic sugar does not allow for extending multiple parent classes. This library provides an easy way to solve that, without the need for mixin chains or functions.\n\n\n\u003c!-- GETTING STARTED --\u003e\n## Getting Started\n\nThis library has zero dependencies. To get up and running in your project, just go ahead and install.\n\n### Installation\n\nInstall the library with\n\n``` bash\nnpm install @kbravh/multi-class\n```\nor\n``` bash\nyarn add @kbravh/multi-class\n```\n\n\n\u003c!-- USAGE EXAMPLES --\u003e\n## Usage\nImport the library, then create a couple of parent classes. A common pattern uses \"Has\" or \"With\".\n\n``` JS\nconst multiclass = require('@kbravh/multi-class')\n\nclass HasName {\n  constructor({name}){\n    this.name = name\n  }\n}\n\nclass HasAge {\n  constructor({age}){\n    this.age = age\n  }\n}\n```\n\nThen, create your subclass and extend the parent classes using the `multi-class` function.\n\n``` JS\nclass Person extends multiclass(HasName, HasAge){\n  // The constructor is called implicitly\n\n  getNameAndAge(){\n    return `${this.name} is ${this.age} years old.`\n  }\n}\n```\n\nFinally, create an instance of your new class and see the magic!\n\n``` JS\nlet person = new Person({\n  age: 22,\n  name: \"Leeloo\"\n})\n\nperson.getNameAndAge() // Leeloo is 22 years old.\n```\n\n**Nota bene:** If your parent classes have different parameters for their respective constructors, an easy way to handle this is by passing in all arguments in a JSON object and destructuring them in the constructors, as is done above.\n\n### Options\n\nDon't like the name `multiclass`? Just change the name on import and inherit to your heart's content.\n\n``` JS\nconst 🤖 = require('@kbravh/multi-class')\n\nclass Person extends 🤖(HasName, HasAge){...}\n```\n\n\u003c!-- ROADMAP --\u003e\n## Roadmap\n\nSee the [open issues](https://github.com/kbravh/multi-class/issues) for a list of proposed features (and known issues).\n\n\n\n\u003c!-- CONTRIBUTING --\u003e\n## Contributing\n\nContributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b new-feature`)\n3. Be sure to run linting! (`yarn lint`)\n4. Commit your Changes (`git commit -m 'Add something cool!'`)\n5. Push to the Branch (`git push origin new-feature`)\n6. Open a Pull Request\n\n\n\n\u003c!-- LICENSE --\u003e\n## License\n\nDistributed under the MIT License. See [`LICENSE`](LICENSE) for more information.\n\n\u003c!-- CONTACT --\u003e\n## Contact\n\nKarey Higuera - [@kbravh](https://twitter.com/kbravh) - karey.higuera@gmail.com\n\nProject Link: [https://github.com/kbravh/multi-class](https://github.com/kbravh/multi-class)\n\n\n\u003c!-- MARKDOWN LINKS --\u003e\n[issues-shield]: https://img.shields.io/github/issues/kbravh/multi-class.svg?style=flat-square\n[issues-url]: https://github.com/kbravh/multi-class/issues\n[license-shield]: https://img.shields.io/github/license/kbravh/multi-class.svg?style=flat-square\n[license-url]: https://github.com/kbravh/multi-class/blob/master/LICENSE\n[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=flat-square\u0026logo=linkedin\u0026colorB=555\n[linkedin-url]: https://linkedin.com/in/kbravh\n[circle-ci]: https://img.shields.io/circleci/build/github/kbravh/multi-class/master?style=flat-square\u0026token=7a06dc52baa780c631a04b7dd09e358fa3f6b44d","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkbravh%2Fmulti-class","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkbravh%2Fmulti-class","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkbravh%2Fmulti-class/lists"}