{"id":13394345,"url":"https://github.com/mafintosh/localcast","last_synced_at":"2025-08-30T22:31:02.198Z","repository":{"id":65994774,"uuid":"84457582","full_name":"mafintosh/localcast","owner":"mafintosh","description":"A shared event emitter that works across multiple processes on the same machine, including the browser!","archived":false,"fork":false,"pushed_at":"2017-04-21T00:28:57.000Z","size":9,"stargazers_count":166,"open_issues_count":1,"forks_count":16,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-12-17T15:47:49.978Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mafintosh.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}},"created_at":"2017-03-09T15:29:33.000Z","updated_at":"2024-10-27T20:29:25.000Z","dependencies_parsed_at":"2023-03-28T20:48:47.054Z","dependency_job_id":null,"html_url":"https://github.com/mafintosh/localcast","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"6e9f8207f39b13846ae1246394d1b600a7540727"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Flocalcast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Flocalcast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Flocalcast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mafintosh%2Flocalcast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mafintosh","download_url":"https://codeload.github.com/mafintosh/localcast/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231534901,"owners_count":18391543,"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-07-30T17:01:16.610Z","updated_at":"2024-12-27T20:09:39.192Z","avatar_url":"https://github.com/mafintosh.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","others","Web Socket"],"sub_categories":["Docker Custom Builds"],"readme":"# localcast\n\nA shared event emitter that works across multiple processes on the same machine, including the browser!\n\n```\nnpm install localcast\n```\n\n## Usage\n\nFirst save the example below in file called `example.js`.\n\n``` js\nvar localcast = require('localcast')\nvar cast = localcast()\n\ncast.on('hello', function (data) {\n  console.log('hello', data)\n})\n\ncast.emit('hello', 'world')\n```\n\nThen try running the example in a terminal.\n\n``` sh\n# in one terminal\n$ node example.js\n```\n\nRunning the above should print out `hello world` and keep the process running.\n\nThen try running opening a new terminal and run the example again.\n\n``` sh\n# in a new terminal\n$ node example.js\n```\n\nBoth the new and old terminal should print out `hello world`.\n\nNow try browserifying the example\n\n``` sh\nbrowserify example.js \u003e bundle.js\necho '\u003chtml\u003e\u003cbody\u003e\u003cscript src=\"bundle.js\"\u003e\u003c/script\u003e\u003c/body\u003e\u003c/html\u003e' \u003e example.html\n```\n\nOpen `example.html` in a browser. Now both the browser and the two previous terminals should print out `hello world`!\n\n## API\n\n#### `var cast = localcast([name])`\n\nCreate a new localcast event emitter.\n\nOptionally you can give it a name if you are running multiple and want them to avoid clashing.\n\n#### `cast.on('localcast', peer)`\n\nWhenever you are connected to another localcast instance a special `localcast` event is emitted with an object describing the other instance.\n\n``` js\ncast.on('localcast', function (peer) {\n  console.log('we are connected to another instance', peer)\n})\n```\n\nIf the other peer is a browser the peer looks like this\n\n``` js\n{\n  type: 'browser',\n  localhost: urlOfWebsite\n}\n```\n\nIf the other peer is a node process it looks like this\n\n``` js\n{\n  type: 'node',\n  pid: pid\n}\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmafintosh%2Flocalcast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmafintosh%2Flocalcast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmafintosh%2Flocalcast/lists"}