{"_id":"@dancrumb/event-sink","_rev":"4-6c80778fa1fa5dc7527d9cf8e7b5a3ef","name":"@dancrumb/event-sink","dist-tags":{"latest":"2.2.0"},"versions":{"2.0.0":{"name":"@dancrumb/event-sink","version":"2.0.0","keywords":[],"author":{"name":"Dan Rumney","email":"dancrumb@gmail.com"},"license":"MIT","_id":"@dancrumb/event-sink@2.0.0","maintainers":[{"name":"dancrumb","email":"dancrumb@gmail.com"}],"dist":{"shasum":"2a411229afcf5861eb322e9fc2017ab71b971d8e","tarball":"https://registry.npmjs.org/@dancrumb/event-sink/-/event-sink-2.0.0.tgz","fileCount":11,"integrity":"sha512-q6UOhV/4JxJk9mUMlXi0R/OFYoH9FHpZk7RZDZfmq55r8uQpnAzXo1ekqKQKa4jzcAHPsibR4mYjqmKBiymSJg==","signatures":[{"sig":"MEUCIC97PdeDpuCSpgpDaDSOxZ/jc1C/NuaDIe9BT624zn/YAiEA9PDORXcz62A8sf0VsMM+7YddPnhURebg9m6GSJQxEFE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20271},"type":"module","exports":{".":"./dist/event-sink.js","./package.json":"./package.json"},"gitHead":"f24fcad50421b168a19665fbc9d05ecc8a215c7c","private":false,"scripts":{"test":"vitest","build":"tsc"},"_npmUser":{"name":"dancrumb","email":"dancrumb@gmail.com"},"_npmVersion":"10.9.2","description":"This module provides a complement to the [`EventSource`](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) interface defined as part of the Web APIs. The `EventSink` can be used in a server to provide a simple interface to sending Server-sent ","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.15.0","devDependencies":{"vitest":"^3.2.4","typescript":"^5.9.2","@types/node":"^24.3.1","@vitest/coverage-v8":"3.2.4"},"_npmOperationalInternal":{"tmp":"tmp/event-sink_2.0.0_1757631816352_0.10835566425292686","host":"s3://npm-registry-packages-npm-production"}},"2.1.0":{"name":"@dancrumb/event-sink","version":"2.1.0","keywords":[],"author":{"name":"Dan Rumney","email":"dancrumb@gmail.com"},"license":"MIT","_id":"@dancrumb/event-sink@2.1.0","maintainers":[{"name":"dancrumb","email":"dancrumb@gmail.com"}],"homepage":"https://github.com/dancrumb/event-sink#readme","bugs":{"url":"https://github.com/dancrumb/event-sink/issues"},"dist":{"shasum":"043c02b5974d47bbb3217f559970c0d3a0b0d069","tarball":"https://registry.npmjs.org/@dancrumb/event-sink/-/event-sink-2.1.0.tgz","fileCount":11,"integrity":"sha512-q8aECxEkvUnWDpqLa6CFJjPieeeMydNwKFP0DqdzVYG1r9C7RkQtakggFZZ4Q+Jy+vflJscja+6KLTl3iIstxA==","signatures":[{"sig":"MEYCIQCpmcbiQdQdpLATUaavud3s92Rman8mkJnbKarl3HsYggIhAK+f7I0SKVRtXj2BYDywVReYqW14tR2mmd3hDdyNWxDw","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@dancrumb%2fevent-sink@2.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":20711},"type":"module","exports":{".":"./dist/event-sink.js","./package.json":"./package.json"},"gitHead":"85ee75e3240111f9c32a48bc44bc74381ef48aa5","private":false,"scripts":{"test":"vitest","build":"tsc"},"_npmUser":{"name":"dancrumb","email":"dancrumb@gmail.com"},"repository":{"url":"git+https://github.com/dancrumb/event-sink.git","type":"git"},"_npmVersion":"10.8.2","description":"This module provides a complement to the [`EventSource`](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) interface defined as part of the Web APIs. The `EventSink` can be used in a server to provide a simple interface to sending Server-sent ","directories":{},"_nodeVersion":"20.19.5","_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.2.4","typescript":"^5.9.2","@types/node":"^24.3.1","@vitest/coverage-v8":"3.2.4"},"_npmOperationalInternal":{"tmp":"tmp/event-sink_2.1.0_1757632307055_0.5818954322146792","host":"s3://npm-registry-packages-npm-production"}},"2.1.1":{"name":"@dancrumb/event-sink","version":"2.1.1","keywords":[],"author":{"name":"Dan Rumney","email":"dancrumb@gmail.com"},"license":"MIT","_id":"@dancrumb/event-sink@2.1.1","maintainers":[{"name":"dancrumb","email":"dancrumb@gmail.com"}],"homepage":"https://github.com/dancrumb/event-sink#readme","bugs":{"url":"https://github.com/dancrumb/event-sink/issues"},"dist":{"shasum":"37d363ee1955f572b0bf9e475aa908452dab170f","tarball":"https://registry.npmjs.org/@dancrumb/event-sink/-/event-sink-2.1.1.tgz","fileCount":20,"integrity":"sha512-yvrbJA5NQq6AYnXHw+1pjurpcz6Ergw3sKM0ihxmr9nm1KnP/JOGXRO0Rs4TQMeDAoXXY7jRGye9AxQya/CG0A==","signatures":[{"sig":"MEQCIB9M6VfOtzTeV6O5oi4P/K1AZM6lZrKsz5sAVtuszlHXAiBOJ4oTeDQlusKeJxVD9ZuyPNTKrO3xMu6EvMXRQTbseg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@dancrumb%2fevent-sink@2.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":24520},"type":"module","exports":{".":{"types":"./dist/event-sink.d.ts","import":"./dist/event-sink.js"}},"gitHead":"163352fed2462c4c6d9fe5297ff238dafe8e8447","private":false,"scripts":{"test":"vitest","build":"tsc"},"_npmUser":{"name":"dancrumb","email":"dancrumb@gmail.com"},"repository":{"url":"git+https://github.com/dancrumb/event-sink.git","type":"git"},"_npmVersion":"10.8.2","description":"This module provides a complement to the [`EventSource`](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) interface defined as part of the Web APIs. The `EventSink` can be used in a server to provide a simple interface to sending Server-sent ","directories":{},"_nodeVersion":"20.19.5","_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.2.4","typescript":"^5.9.2","@types/node":"^24.3.1","@vitest/coverage-v8":"3.2.4"},"_npmOperationalInternal":{"tmp":"tmp/event-sink_2.1.1_1757685479067_0.21507486490895977","host":"s3://npm-registry-packages-npm-production"}},"2.2.0":{"name":"@dancrumb/event-sink","version":"2.2.0","description":"This module provides a complement to the [`EventSource`](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) interface defined as part of the Web APIs. The `EventSink` can be used in a server to provide a simple interface to sending Server-sent ","private":false,"exports":{".":{"import":"./dist/event-sink.js","types":"./dist/event-sink.d.ts"}},"engines":{"node":">=22.14.0"},"type":"module","scripts":{"build":"tsc","test":"vitest"},"keywords":[],"author":{"name":"Dan Rumney","email":"dancrumb@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/dancrumb/event-sink.git"},"license":"MIT","devDependencies":{"@types/node":"22","@vitest/coverage-v8":"3.2.4","typescript":"^5.9.2","vitest":"^3.2.4"},"packageManager":"pnpm@10.16.1+sha512.0e155aa2629db8672b49e8475da6226aa4bdea85fdcdfdc15350874946d4f3c91faaf64cbdc4a5d1ab8002f473d5c3fcedcd197989cf0390f9badd3c04678706","_id":"@dancrumb/event-sink@2.2.0","gitHead":"a5f4b7a477a7a914b34f29eb0196c318bfb56706","bugs":{"url":"https://github.com/dancrumb/event-sink/issues"},"homepage":"https://github.com/dancrumb/event-sink#readme","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-mgOPxouEbpIT1sTfoNYXFe1CiV8Nm8Oqtb7y6Ka6QzDxXA2Gik3A525gm02uxFyKqN5Bi6W0JXxN8Q/BNUbVqA==","shasum":"0a2dba3b44be0229bf76fd4be2faa91282b8e9c7","tarball":"https://registry.npmjs.org/@dancrumb/event-sink/-/event-sink-2.2.0.tgz","fileCount":21,"unpackedSize":24766,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD/6DUXmUP1j2n8IZMDl62u2qVRU43Hjh/cSPzu1fG1twIgSpPLSMtp/WAM6uHVo/qE5y6FCN3TBK+7beHWgYEGYso="}]},"_npmUser":{"name":"dancrumb","email":"dancrumb@gmail.com"},"directories":{},"maintainers":[{"name":"dancrumb","email":"dancrumb@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/event-sink_2.2.0_1758809900492_0.3413845927472785"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-11T23:03:36.262Z","modified":"2025-09-25T14:18:20.944Z","2.0.0":"2025-09-11T23:03:36.553Z","2.1.0":"2025-09-11T23:11:47.242Z","2.1.1":"2025-09-12T13:57:59.231Z","2.2.0":"2025-09-25T14:18:20.739Z"},"bugs":{"url":"https://github.com/dancrumb/event-sink/issues"},"author":{"name":"Dan Rumney","email":"dancrumb@gmail.com"},"license":"MIT","homepage":"https://github.com/dancrumb/event-sink#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/dancrumb/event-sink.git"},"description":"This module provides a complement to the [`EventSource`](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) interface defined as part of the Web APIs. The `EventSink` can be used in a server to provide a simple interface to sending Server-sent ","maintainers":[{"name":"dancrumb","email":"dancrumb@gmail.com"}],"readme":"# EventSink\n\nThis module provides a complement to the\n[`EventSource`](https://developer.mozilla.org/en-US/docs/Web/API/EventSource)\ninterface defined as part of the Web APIs. The `EventSink` can be used in a\nserver to provide a simple interface to sending Server-sent Events.\n\n## Usage\n\n```typescript\nconst sink = new EventSink();\nconst response = sink.getResponse(); // HTTP Response with appropriate headers for SSE\n\n// Can pass in an event object\nawait sink.dispatchEvent({\n  name: \"test\",\n  content: \"testing\",\n});\n\n// Can pass in event name, content (and optional ID)\nawait sink.dispatchEvent(\"test2\", \"testing2\", \"2\");\n\nawait sink.close();\n```\n\n### History\n\nAn `EventSink` can take an `EventHistory` object. If this is provided, every\ndispatched event is pushed into the history object. Each entry is a single\nServer-sent event.\n\n## CircularBuffer\n\nThe `CircularBuffer` object implements the `EventHistory` (along with a number\nof other `Array<T>` methods).\n\nIt's designed to be a fixed size buffer that can be constantly added to and\nremoved from. As such, it can retain the last _N_ events.\n\nThis can be used to replay events for a client that has to reconnect and who\nsends the `Last-Event-ID` header.\n\nSince it's a circular buffer, if it fills faster than it is drained, older\nevents will get lost; however, this is generally reasonable behaviour for SSEs,\nsince old events will have limited value.\n","readmeFilename":"README.md"}