{"id":22660653,"url":"https://github.com/openovate/jsm","last_synced_at":"2025-03-29T08:24:16.004Z","repository":{"id":35110908,"uuid":"207714598","full_name":"Openovate/jsm","owner":"Openovate","description":"JavaScript Modules that Work in Node, and Browser","archived":false,"fork":false,"pushed_at":"2023-03-01T22:32:09.000Z","size":464,"stargazers_count":1,"open_issues_count":16,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-03T22:54:33.682Z","etag":null,"topics":["javascript-modules"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/Openovate.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-11T03:25:41.000Z","updated_at":"2022-06-30T22:12:28.000Z","dependencies_parsed_at":"2024-12-09T11:11:28.935Z","dependency_job_id":"f7dc4dd6-b4a4-40b7-b784-fa3342029f63","html_url":"https://github.com/Openovate/jsm","commit_stats":{"total_commits":23,"total_committers":2,"mean_commits":11.5,"dds":0.04347826086956519,"last_synced_commit":"4cd9e0e8edd08167e01867ba2430e5866ce2cba4"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Openovate%2Fjsm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Openovate%2Fjsm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Openovate%2Fjsm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Openovate%2Fjsm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Openovate","download_url":"https://codeload.github.com/Openovate/jsm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246158251,"owners_count":20732751,"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":["javascript-modules"],"created_at":"2024-12-09T11:11:23.606Z","updated_at":"2025-03-29T08:24:15.974Z","avatar_url":"https://github.com/Openovate.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jsm\n\nJavaScript Modules that Work in Node, and Browser\n\n## Install\n\n```bash\n$ npm i @openovate/jsm\n```\n\n## EventEmitter Usage\n\n```js\nconst { EventEmitter } = require('@openovate/jsm')\n\nconst emitter = new EventEmitter;\n\nemitter.on('trigger something', async x =\u003e {\n  console.log('something triggered', x + 1)\n})\n\nemitter.on(/trigger (something)/, async x =\u003e {\n  await Helper.sleep(2000)\n  console.log('(something) triggered', x + 2)\n}, 2)\n\nawait emitter.emit('trigger something', 1)\n```\n\n## Exception Usage\n\n```js\nconst { Exception } = require('@openovate/jsm')\n\nthrow Exception.for('Something %s is %s', 'good', 'bad')\n```\n\n## Registry Usage\n\n```js\nconst { Registry } = require('@openovate/jsm')\n\nconst registry = Registry.load()\n\nregistry.set('foo', 'bar', 'zoo')\nregistry.set('foo', 'zoo', ['foo', 'bar', 'zoo'])\n\nconsole.log(registry.has('foo', 'bar'))\nconsole.log(registry.has('bar', 'foo'))\nconsole.log(registry.get('foo', 'zoo', 1))\n\nregistry.remove('foo', 'bar')\n\nconsole.log(registry.has('foo', 'bar'))\nconsole.log(registry.has('foo', 'zoo'))\n```\n\n## TaskQueue Usage\n\n```js\nconst { TaskQueue } = require('@openovate/jsm')\n\nconst queue = new TaskQueue;\n\nqueue.push(async x =\u003e {\n  console.log(x + 1)\n})\n\nqueue.shift(async x =\u003e {\n  await Helper.sleep(2000)\n  console.log(x + 2)\n})\n\nqueue.add(async x =\u003e {\n  console.log(x + 3)\n}, 10)\n\nawait queue.run(1)\n```\n\n## Reflection Usage\n\n```js\nclass Foo {\n  foo(x, y, z) {\n    return x + y + z;\n  }\n}\n\nconst foo = new Foo;\nconst names = reflect(foo.foo).getArgumentNames(); //--\u003e x, y, z\n\nconst descriptors1 = reflect(Foo1).getDescriptors(); //--\u003e {foo: {...}}\nconst descriptors2 = reflect(foo).getDescriptors(); //--\u003e {foo: {...}}\n\nconst methods1 = reflect(Foo1).getMethods(); //--\u003e {foo: function}\nconst methods2 = reflect(foo).getMethods(); //--\u003e {foo: function}\n```\n\n## traits Usage\n\n```js\nconst { traits } = require('@openovate/jsm')\n\nclass Bar {\n  bar() {}\n}\n\nclass Zoo {\n  zoo() {}\n}\n\nclass Foo2 extends traits(Bar, Zoo) {\n  foo() {}\n}\n\nconst foo = new Foo2\n\nfoo.foo()\nfoo.bar()\nfoo.zoo()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenovate%2Fjsm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenovate%2Fjsm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenovate%2Fjsm/lists"}