{"id":19910035,"url":"https://github.com/aitoroses/js-decorators","last_synced_at":"2025-03-01T08:23:24.460Z","repository":{"id":28765875,"uuid":"32288212","full_name":"aitoroses/js-decorators","owner":"aitoroses","description":"A simple transpiler that brings python style decorators to javascript","archived":false,"fork":false,"pushed_at":"2015-03-15T23:40:13.000Z","size":168,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-11T22:30:56.325Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/aitoroses.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-03-15T22:42:45.000Z","updated_at":"2020-08-29T05:14:54.000Z","dependencies_parsed_at":"2022-09-05T00:21:36.073Z","dependency_job_id":null,"html_url":"https://github.com/aitoroses/js-decorators","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/aitoroses%2Fjs-decorators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aitoroses%2Fjs-decorators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aitoroses%2Fjs-decorators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aitoroses%2Fjs-decorators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aitoroses","download_url":"https://codeload.github.com/aitoroses/js-decorators/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241337485,"owners_count":19946423,"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-11-12T21:17:20.790Z","updated_at":"2025-03-01T08:23:24.435Z","avatar_url":"https://github.com/aitoroses.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JS Decorators\n\nA tiny compiler that brings python style decorators to javascript.\n\n## Use\n\n```js\nimport Compiler from '../lib/compiler';\n\nvar compiler = new Compiler();\n\nvar result = compiler.compile(source);\n```\n\n## Example\n\n```js\n// decorators.js\n\nfunction addAnnotation(decorable, annotation) {\n  decorable.annotations = decorable.annotations || [];\n  decorable.annotations.push(annotation);\n  return decorable;\n}\n\nclass Annotation1 {}\n\nclass Annotation2 {\n  constructor(config) {\n    this.config = config;\n  }\n}\n\nexport function Decorator1(config, decorable) {\n  console.log([\"Decorator1\", config, decorable])\n  decorable = addAnnotation(decorable, new Annotation1(config))\n  return decorable;\n}\nexport function Decorator2(config, decorable) {\n  console.log([\"Decorator2\", config, decorable])\n  decorable = addAnnotation(decorable, new Annotation2(config))\n  return decorable;\n}\n```\n\n```js\n// index.js\n\nimport {Decorator1, Decorator2} from './decorators';\n\n@Decorator1\n@Decorator2({module: \"MY_MODULE\"})\nclass MyClass {\n  constructor() {\n    console.log(\"Instantiate my class\");\n  }\n}\n\nMyClass.annotations[0].name == Annotation2 // =\u003e true\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faitoroses%2Fjs-decorators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faitoroses%2Fjs-decorators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faitoroses%2Fjs-decorators/lists"}