{"id":19877121,"url":"https://github.com/yehorbk/annotations-js","last_synced_at":"2025-05-02T12:30:41.573Z","repository":{"id":41402247,"uuid":"313904217","full_name":"yehorbk/annotations-js","owner":"yehorbk","description":"Library that provides annotations functionality in vanilla JavaScript ","archived":false,"fork":false,"pushed_at":"2020-12-06T12:31:27.000Z","size":56,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T01:23:05.888Z","etag":null,"topics":["annotation","annotations","javascript","javascript-library","javascript-vanilla"],"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/yehorbk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-18T10:48:13.000Z","updated_at":"2025-01-23T14:44:44.000Z","dependencies_parsed_at":"2022-07-25T22:33:00.963Z","dependency_job_id":null,"html_url":"https://github.com/yehorbk/annotations-js","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/yehorbk%2Fannotations-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yehorbk%2Fannotations-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yehorbk%2Fannotations-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yehorbk%2Fannotations-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yehorbk","download_url":"https://codeload.github.com/yehorbk/annotations-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252038094,"owners_count":21684624,"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":["annotation","annotations","javascript","javascript-library","javascript-vanilla"],"created_at":"2024-11-12T16:36:39.550Z","updated_at":"2025-05-02T12:30:41.284Z","avatar_url":"https://github.com/yehorbk.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Annotations-JS\n\nLibrary that provides annotations functionality in vanilla JavaScript.\n\n# Installation\n\nInstall library via npm:\n\n```\n$ npm install annotations-js\n```\n\n# How to Use\n\n## Creating custom annotation\n\nFirst of all, you need to get the main `Annotation` function by connecting the library.\nTo create your own custom annotation, you need to call the `bind` function from `Annotation`, passing your function (annotation) to it.\nThis function will set generic annotation prototype to your annotation and then you will be able to use your\nannotation or extend it's functionality.\n\n```javascript\nconst Annotation = require('annotations.js');\n\nAnnotation.bind(CustomAnnotation);\nfunction CustomAnnotation() {}\n```\n\nTo get all binded annotations in your application you can use method `getAnnotations` from `Annotation`.\n\n## Working with annotation\n\nWith your custom annotation you can annotate functions, objects and variables. All annotated items will\nbe stored in annotation's storage that can be returned from `getAnnotated` method. Also you able to\npass params with annotated item. To annotate a function declaration - use next syntax:\n\n```javascript\nCustomAnnotation.annotate(FooFunction, { fooParam: 'fooParam' });\nfunction FooFunction() {}\n```\n\nIf you want to annotate functional expressions, objects, variables, etc. - there is\nspecial syntax for it. The `annotate` method returns interface for your annotated value:\n\n```javascript\nconst fooInterface = CustomAnnotation.annotate('fooObject');\nconst fooObject = (fooInterface.value = { objectParam: 'objectParam' });\n```\n\nThe string literal `'fooObject'` in this example - it's a key for annotated item.\nIt is advisable to name it the same as the annotated one.\n\n# Linting\n\nUnfortunately, not all basic linter configurations allow you to work with multi-assignment\nand use of a function before it's declared, so if you are using ESLint you should\ndisable these rules: `no-multi-assign`, `no-use-before-define`.\n\n# Author\n\n**Yehor Bublyk**: [GitHub](https://github.com/yehorbk) • [Twitter](https://twitter.com/yehorbk)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyehorbk%2Fannotations-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyehorbk%2Fannotations-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyehorbk%2Fannotations-js/lists"}