{"id":17344400,"url":"https://github.com/ivteplo/mixins","last_synced_at":"2026-05-18T07:34:03.986Z","repository":{"id":38256944,"uuid":"464123226","full_name":"ivteplo/mixins","owner":"ivteplo","description":"JavaScript library for mixins","archived":false,"fork":false,"pushed_at":"2022-06-08T07:39:18.000Z","size":255,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T14:45:28.387Z","etag":null,"topics":["class-composition","javascript","mixins","object-oriented-programming","oop","typescript"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/@teplovs/mixins","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ivteplo.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":"2022-02-27T11:57:22.000Z","updated_at":"2022-10-26T18:13:00.000Z","dependencies_parsed_at":"2022-08-31T16:12:12.896Z","dependency_job_id":null,"html_url":"https://github.com/ivteplo/mixins","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/ivteplo%2Fmixins","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivteplo%2Fmixins/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivteplo%2Fmixins/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivteplo%2Fmixins/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivteplo","download_url":"https://codeload.github.com/ivteplo/mixins/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245822389,"owners_count":20678165,"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":["class-composition","javascript","mixins","object-oriented-programming","oop","typescript"],"created_at":"2024-10-15T16:25:10.544Z","updated_at":"2025-10-28T03:36:33.796Z","avatar_url":"https://github.com/ivteplo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mixins\nJavaScript library for mixins\n\n## Installation\n\n```bash\nnpm install @teplovs/mixins\n# or, if you prefer yarn:\nyarn add @teplovs/mixins\n```\n\n## Usage Example\n\n```javascript\nimport { createMixin } from \"@teplovs/mixins\"\n\nclass Animal {}\n\nconst canFly = createMixin(ParentClass =\u003e\n  class CanFly extends ParentClass {\n    canFly = true\n  }\n)\n\nconst canRun = createMixin(ParentClass =\u003e\n  class CanRun extends ParentClass {\n    canRun = true\n  }\n)\n\nconst canGreet = createMixin((ParentClass, sound) =\u003e\n  class CanGreet extends ParentClass {\n    greet(name) {\n      return `${sound} ${name}!`\n    }\n  }\n)\n\nclass Dog extends canRun(canGreet(Animal, \"Woof woof\")) {\n  // ...\n}\n\nclass Cat extends canRun(canGreet(Animal, \"Meow\")) {\n  // ...\n}\n\nclass Parrot extends canFly(canGreet(Animal, \"Chirp chirp. Hi\")) {\n  // ...\n}\n\nnew Dog().greet(\"y'all\") // \"Woof woof y'all!\"\nnew Cat().greet(\"y'all\") // \"Meow y'all!\"\nnew Parrot().greet(\"y'all\") // \"Chirp chirp. Hi y'all!\"\n\nnew Dog().canRun // true\nnew Cat().canRun // true\nnew Parrot().canFly // true\n```\n\n## API\n\n### `createMixin(createClass: (ParentClass, ...props) =\u003e Class): (...props) =\u003e Class`\n\nFunction to create a new mixin.\n\n#### Mixin without properties\n\n```javascript\nclass Animal {}\n\nconst canRun = createMixin(ParentClass =\u003e\n  class CanRun extends ParentClass {\n    canRun = true\n  }\n)\n\nconst AnimalThatCanRun = canRun(Animal)\nnew AnimalThatCanRun().canRun // true\n```\n\n#### Mixin with properties\n\n```javascript\nclass Person {}\n\nconst hasHobby = createMixin((ParentClass, personsHobby) =\u003e\n  class HasHobby extends ParentClass {\n    hobby = personsHobby\n  }\n)\n\nconst Artist = hasHobby(Person, \"drawing\")\nnew Artist().hobby // \"drawing\"\n```\n\n## Development\n\n### Requirements\n\n- Node.js and npm\n\n### Setup\n\n1. Clone the repository\n\n```bash\ngit clone https://github.com/teplovs/mixins\n```\n\n2. Navigate to the project folder\n\n```bash\ncd mixins\n```\n\n3. Install dependencies\n\n```bash\nnpm install\n# or, if you prefer yarn:\nyarn install\n```\n\n4. To run tests:\n\n```bash\nnpm test\n# or:\nyarn test\n```\n\n5. To build:\n\n```bash\nnpm run build\n# or:\nyarn build\n```\n\n6. Happy hacking! 🎉\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivteplo%2Fmixins","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivteplo%2Fmixins","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivteplo%2Fmixins/lists"}