{"id":16681436,"url":"https://github.com/printercu/coffee_classkit","last_synced_at":"2025-04-09T23:04:58.933Z","repository":{"id":57202691,"uuid":"9728683","full_name":"printercu/coffee_classkit","owner":"printercu","description":"Enhance coffeescript inheritance model! With an eye on ruby classes \u0026 modules.","archived":false,"fork":false,"pushed_at":"2014-01-08T14:19:28.000Z","size":351,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T23:04:53.337Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/printercu.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":"2013-04-28T10:28:40.000Z","updated_at":"2017-11-02T08:28:52.000Z","dependencies_parsed_at":"2022-09-15T13:21:03.938Z","dependency_job_id":null,"html_url":"https://github.com/printercu/coffee_classkit","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/printercu%2Fcoffee_classkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/printercu%2Fcoffee_classkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/printercu%2Fcoffee_classkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/printercu%2Fcoffee_classkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/printercu","download_url":"https://codeload.github.com/printercu/coffee_classkit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248125628,"owners_count":21051770,"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-12T14:04:12.836Z","updated_at":"2025-04-09T23:04:58.912Z","avatar_url":"https://github.com/printercu.png","language":"CoffeeScript","readme":"# CoffeeClasskit\n\nYou can make much more with CoffeeScript classes.\n\n```\nnpm install coffee_classkit\n```\n\n```coffee\nclasskit = require 'coffee_classkit'\n\nclass Child extends Parent\n  classkit.extendsWithProto @\n\n# ###\nclass Mixin extends classkit.Module\n  @extendsWithProto().concern()\n\n  @includedBlock: -\u003e\n    # will run in context of base class\n    @instanceVariable 'test'\n\n  class @ClassMethods\n    someClassMethod: -\u003e\n\n  someInstanceMethod: -\u003e\n\nclass Base extends classkit.Module\n  @extendsWithProto().include Mixin\n\n  @someClassMethod()\n\n(new Base).someInstanceMethod()\n```\n\n## Why\n\n`class ... extends ...` is implemented in coffee with\n\n```coffee\nfor key of parent\n  child[key] = parent[key]  if __hasProp_.call(parent, key)\n```\n\nIt makes inheritance sticky.\n* If you modify parent's property it would not be modified in child.\n* Properties defined with `Object.defineProperty` would not be inherited.\n* ...\n\n## Solution\n\nUse prototype chain for inheritance of class methods.\n\nWith `classkit.extendsWithProp @` default inheritance is redefined using\n`child.__proto__ = parent`.\n\nEnsure that you call this method before any class properties declarations,\n'cause it'll drop'em all.\n\nOnce you use `extendsWithProto` you should use it on all descendents.\n\n## Features\n\n* It doesn't break into global namespace.\n* Works on a top of usual coffee-script class declaration.\n* Classes use prototypes chain.\n* Full callbacks stack of Ruby-like inheritance model (`included`,\n  `append_features`, `extend_object`, etc).\n* Helpers to define ruby-like instance \u0026 class variables.\n* `ActiveSupport::Concern`-like behaviour is optional.\n* It works only 'cause of `__proto__`. Some say it's deprecated :)\n\n## For pure JS\n`Classkit.inherit` method provides inheritance that can be used in pure JS:\n\n```js\nfunction Parent() { /* ... */ }\nvar Child;\nClasskit.inherit(Parent, Child = function Child(){ /* ... */ });\n```\n\nIt uses CoffeeScript's inheritance. Take a look on compiled coffee source\nto know how to use `super` properly.\n\n## More examples\n\nSee source, tests \u0026 [costa](https://github.com/printercu/costa).\n\n## License\n\nBSD\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprintercu%2Fcoffee_classkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprintercu%2Fcoffee_classkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprintercu%2Fcoffee_classkit/lists"}