{"id":16451837,"url":"https://github.com/thebearingedge/location-emitter","last_synced_at":"2026-06-08T22:32:25.676Z","repository":{"id":33473970,"uuid":"37119646","full_name":"thebearingedge/location-emitter","owner":"thebearingedge","description":"A simple observable facade to window.location","archived":false,"fork":false,"pushed_at":"2015-06-14T08:30:29.000Z","size":184,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-04-20T00:24:47.984Z","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/thebearingedge.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-06-09T08:20:12.000Z","updated_at":"2015-06-14T05:30:59.000Z","dependencies_parsed_at":"2022-09-12T15:21:11.312Z","dependency_job_id":null,"html_url":"https://github.com/thebearingedge/location-emitter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thebearingedge/location-emitter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebearingedge%2Flocation-emitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebearingedge%2Flocation-emitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebearingedge%2Flocation-emitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebearingedge%2Flocation-emitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thebearingedge","download_url":"https://codeload.github.com/thebearingedge/location-emitter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thebearingedge%2Flocation-emitter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34083848,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-11T10:10:33.537Z","updated_at":"2026-06-08T22:32:25.661Z","avatar_url":"https://github.com/thebearingedge.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# location-emitter\n\nAn observable facade for interacting with the browser path.\n\n```bash\nnpm install location-emitter\n```\n\nDuring construction `location-emitter` will detect if `history.pushState` is available and fall back to using `location.hash`.\n\n# example\n\n```javascript\nvar domready = require('domready');\nvar LocationEmitter = require('location-emitter');\n\nvar le = new LocationEmitter();\n\nle.onChange(function (path) {\n  console.log(path);\n});\n\ndomready(function () {\n  // start\n  le.listen(); // -\u003e log current path, e.g. \"/\"\n  le.url('/foo'); // -\u003e log \"/foo\"\n  le.hash('bar'); // -\u003e log \"/foo#bar\"\n});\n```\n\n# constructor\n\n```javascript\nvar LocationEmitter = require('location-emitter');\n\nvar location = new LocationEmitter();\n```\n\n`pushState` is opt-out. Force the use of hashes by passing an option.\n\n```javascript\nvar location = new LocationEmitter({ html5: false });\n```\n\n# methods\n\n`location-emitter` has some simple functions for interacting with the browser path.\n\n## location.url([path])\n\n```javascript\nlocation.url('/foo'); // -\u003e sets path or hash to \"/foo\";\n\nlocation.url(); // -\u003e \"/foo\"\n```\n\n## location.hash([hash])\n\nYou may want to interact with the hash directly.\n\n```javascript\nlocation.hash('hashy-hashy'); // -\u003e hash is now \"#hashy-hashy\"\n\nlocation.hash(); // -\u003e \"hashy-hashy\"\n```\n\n## location.replace([path])\n\nReplace the current browser history entry. Uses `history.replaceState` unless it's unavailable or `html5` was set to false;\n\n```javascript\nvar location = new LocationEmitter();\nlocation.replace('/') // -\u003e replace history entry with \"/\"\n\nvar location = new LocationEmitter({ html5: false });\nlocation.replace('/') // -\u003e replace history entry with \"/#/\"\n```\n\n## location.onChange(listener) -\u003e unsubscribe\n\nAdds `listener` functions to handle path changes. Returns an `unsubscribe` function.\n\n```javascript\nvar stopCaring = location.onChange(function (path) {\n  // that's a cool path!... maybe.\n});\n\nstopCaring(); // -\u003e meh.\n```\n\n## location.listen()\n\nSubscribers are not notified of path changes until `location-emitter` is listening to the DOM. **Note:** You'll want to make sure the DOM is ready before calling `listen`.\n\n```javascript\nlocation.listen(); // -\u003e Notify all subscribers of current and future paths\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthebearingedge%2Flocation-emitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthebearingedge%2Flocation-emitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthebearingedge%2Flocation-emitter/lists"}