{"id":19504028,"url":"https://github.com/mysticatea/event-source-shim","last_synced_at":"2026-06-13T12:02:18.017Z","repository":{"id":65974379,"uuid":"166209524","full_name":"mysticatea/event-source-shim","owner":"mysticatea","description":"An implementation for `EventSource` of Server-sent events standard.","archived":false,"fork":false,"pushed_at":"2019-01-29T11:55:03.000Z","size":59,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-25T21:45:10.580Z","etag":null,"topics":[],"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/mysticatea.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}},"created_at":"2019-01-17T10:47:02.000Z","updated_at":"2022-05-26T21:45:30.000Z","dependencies_parsed_at":"2023-02-19T17:45:17.767Z","dependency_job_id":null,"html_url":"https://github.com/mysticatea/event-source-shim","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mysticatea/event-source-shim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mysticatea%2Fevent-source-shim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mysticatea%2Fevent-source-shim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mysticatea%2Fevent-source-shim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mysticatea%2Fevent-source-shim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mysticatea","download_url":"https://codeload.github.com/mysticatea/event-source-shim/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mysticatea%2Fevent-source-shim/sbom","scorecard":{"id":671375,"data":{"date":"2025-08-11","repo":{"name":"github.com/mysticatea/event-source-shim","commit":"eabbd6e13bd2314512bf5b52a3192740d7eb4a31"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/2 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-21T20:11:09.836Z","repository_id":65974379,"created_at":"2025-08-21T20:11:09.836Z","updated_at":"2025-08-21T20:11:09.836Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34283391,"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-13T02:00:06.617Z","response_time":62,"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-11-10T22:24:01.434Z","updated_at":"2026-06-13T12:02:17.996Z","avatar_url":"https://github.com/mysticatea.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# event-source-shim\n\n[![npm version](https://img.shields.io/npm/v/event-source-shim.svg)](https://www.npmjs.com/package/event-source-shim)\n[![Downloads/month](https://img.shields.io/npm/dm/event-source-shim.svg)](http://www.npmtrends.com/event-source-shim)\n[![Build Status](https://travis-ci.com/mysticatea/event-source-shim.svg?branch=master)](https://travis-ci.com/mysticatea/event-source-shim)\n[![Coverage Status](https://codecov.io/gh/mysticatea/event-source-shim/branch/master/graph/badge.svg)](https://codecov.io/gh/mysticatea/event-source-shim)\n[![Dependency Status](https://david-dm.org/mysticatea/event-source-shim.svg)](https://david-dm.org/mysticatea/event-source-shim)\n\nAn implementation of [WHATWG EventSource interface](https://html.spec.whatwg.org/multipage/server-sent-events.html#the-eventsource-interface).\n\nYou can support Server-sent events on also Internet Explorer and Edge.\nThis package includes type definition for TypeScript.\n\n## 💿 Installation\n\nUse [npm] or a compatible tool to install.\n\n```bash\nnpm install event-source-shim\n```\n\n## 📖 Usage\n\nUse a bundler such as [webpack]. You have to configure the bundler to transpile this package and [event-target-shim] package to ES5 from ES2015 for Internet Explorer.\n\nFor example:\n\n```js\nmodule.exports = {\n    //....\n    module: {\n        rules: [\n            {\n                test: /\\.mjs$/u,\n                include: [\n                    path.resolve(__dirname, \"node_modules/event-source-shim\"),\n                    path.resolve(__dirname, \"node_modules/event-target-shim\"),\n                ],\n                loader: \"babel-loader\", // with @babel/preset-env.\n            },\n        ]\n    },\n    //....\n}\n```\n\n## 📚 API References\n\n### § `EventSource` class\n\nThis is same as standard. See [MDN page of EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource).\n\n```ts\nimport { EventSource } from \"event-source-shim\"\n\nconst source = new EventSource(\"/events\")\nsource.addEventListener(\"message\", event =\u003e {\n    console.log(event.data)\n})\n```\n\n### § `setDefaultReconnectionTime(value: number): void` function\n\nIn the specification, the interval of reestablishing the connection is a user-agent-defined value (see [reconnection time](https://html.spec.whatwg.org/multipage/server-sent-events.html#concept-event-stream-reconnection-time)). As following the recommendation in the spec, this package set four seconds to the reconnection time by default. But you can configure the reconnection time with an arbitrary value.\n\n```ts\nimport { setDefaultReconnectionTime } from \"event-source-shim\"\n\nsetDefaultReconnectionTime(10000) // 10sec.\n```\n\n### § `setMaxBufferSize(value: number): void` function\n\nThis package uses `XMLHttpRequest` and that `onprogress` event to implement `EventSource` class. This means that it must disconnect and reestablish the connection at random intervals in order to avoid memory leaks. This package does the reconnecting when the length of `XMLHttpRequest#responseText` gets greater than configured max buffer size. The max buffer size is 64KB by default. But you can configure the max buffer size with an arbitrary value.\n\n```ts\nimport { setMaxBufferSize } from \"event-source-shim\"\n\nsetMaxBufferSize(256 * 1024) // 256KB.\n```\n\n### § `setReconnectionTimeIncreasingRate(value: number): void` function\n\nThe spec allows additional wait time between reestablishing the connection.\n\n\u003e Optionally, wait some more. In particular, if the previous attempt failed, then user agents might introduce an exponential backoff delay to avoid overloading a potentially already overloaded server. Alternatively, if the operating system has reported that there is no network connectivity, user agents might wait for the operating system to announce that the network connection has returned before retrying.\n\u003e\n\u003e https://html.spec.whatwg.org/multipage/server-sent-events.html#reestablish-the-connection\n\nThis package multiplies the reconnection time by the configured increasing rate on every disconnection. The increasing rate is `1.5` by default. But you can configure the increasing rate with an arbitrary value.\n\n```ts\nimport { setReconnectionTimeIncreasingRate } from \"event-source-shim\"\n\nsetReconnectionTimeIncreasingRate(2.0) // x2 on every failure. E.g., 4sec → 8sec → 16sec → ....\n```\n\n## ⚠️ Known Limitations\n\n- Reconnecting happens at random intervals in order to clear `XMLHttpRequest#responseText`.\n- `MessageEvent#origin` is not supported on Internet Explorer because `XMLHttpRequest#responseURL` is not supported.\n\n## 📰 Release notes\n\n- https://github.com/mysticatea/event-source-shim/releases\n\n## ❤️ Contributions\n\nContributing is always welcome!\n\nPlease use GitHub issues and pull requests.\n\n### Development tools\n\n- `npm run build` generates files into `dist` directory.\n- `npm run clean` removes temporary files.\n- `npm run coverage` opens the coverage report the last `npm test` command generated.\n- `npm run lint` runs ESLint.\n- `npm test` runs tests.\n- `npm run watch` runs tests on each file edits.\n\n[event-target-shim]: https://www.npmjs.com/package/event-target-shim\n[npm]: https://www.npmjs.com/\n[Webpack]: https://webpack.js.org/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmysticatea%2Fevent-source-shim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmysticatea%2Fevent-source-shim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmysticatea%2Fevent-source-shim/lists"}