{"id":21405374,"url":"https://github.com/karimsa/gordon","last_synced_at":"2026-01-03T06:16:43.413Z","repository":{"id":36371542,"uuid":"40676387","full_name":"karimsa/gordon","owner":"karimsa","description":"a natural language event-emitter interface","archived":false,"fork":false,"pushed_at":"2016-07-27T04:18:57.000Z","size":98,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-11T21:03:58.043Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/karimsa.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-08-13T18:56:31.000Z","updated_at":"2016-07-27T04:18:32.000Z","dependencies_parsed_at":"2022-08-31T22:11:12.051Z","dependency_job_id":null,"html_url":"https://github.com/karimsa/gordon","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karimsa%2Fgordon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karimsa%2Fgordon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karimsa%2Fgordon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karimsa%2Fgordon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karimsa","download_url":"https://codeload.github.com/karimsa/gordon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243902293,"owners_count":20366259,"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-22T16:24:49.052Z","updated_at":"2026-01-03T06:16:43.384Z","avatar_url":"https://github.com/karimsa.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gordon\n\na natural language event-emitter interface.\n\n[![NPM](https://nodei.co/npm/gordon.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/gordon/)\n\n## usage\n\nGordon's interface is based on the traditional event emitter, but with a few twists to support the ideas\nof natural language. Event names work like normal, but [pennyworth](https://github.com/karimsa/pennyworth)\ntemplates can be associated with event names for a more natural experience.\n\nWhen `.emit()` is called with a natural language string, gordon will find the most appropriate registered\nevent and use its most appropriate template to parse the emitted text. The event will then be fired with\nthe event data being the compiled template.\n\n### initializing a new emitter\n\n```javascript\nvar Gordon = require('gordon');\nvar emitter = new Gordon();\n```\n\n### adding an event listener\n\nFor unregistered events, you can use `.when()` to attach an event\nhandler to a trigger template.\n\n```javascript\nemitter.when('my name is $subject.', function (data) {\n  console.log('hello there, %s', data.subject);\n});\n```\n\n### registering an event\n\nTo register an event is to associate a certain trigger template or list\nof templates with an event. This allows you to hook onto a group of templates\nthat will provide you with the same data.\n\nOn every call, you can register a single template or a list of templates. Follow\nup calls will not re-allocate the template list but rather append to it.\n\n```javascript\nemitter.register('introduction', [\n  '[... hi, hey, hello], $subject.',\n  'how are you, $subject?'\n]);\n```\n\n### attaching to an event\n\nThis works exactly the same as with a regular event emitter.\n\n```javascript\nemitter.on('introduction', function (data) {\n  console.log('hello there, %s.', data.subject);\n});\n```\n\n### emitting an event (using a trigger)\n\nCall emit with a trigger, which is the input data to a pennyworth\ntemplate.\n\n```javascript\nemitter.emit('hey, Gordon.');\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarimsa%2Fgordon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarimsa%2Fgordon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarimsa%2Fgordon/lists"}