{"_id":"@alessiofrittoli/server-sent-events","_rev":"12-7b9a101511019ceab26141a951875a03","name":"@alessiofrittoli/server-sent-events","dist-tags":{"latest":"2.4.0"},"versions":{"1.0.0":{"name":"@alessiofrittoli/server-sent-events","version":"1.0.0","keywords":["server-sent-events","streaming"],"author":{"url":"https://alessiofrittoli.it","name":"Alessio Frittoli","email":"info@alessiofrittoli.it"},"license":"MIT","_id":"@alessiofrittoli/server-sent-events@1.0.0","maintainers":[{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"}],"homepage":"https://github.com/alessiofrittoli/server-sent-events#readme","bugs":{"url":"https://github.com/alessiofrittoli/server-sent-events/issues","email":"project@hostname.com"},"dist":{"shasum":"80c314e37292157370b085876c83ef3b1d25d40f","tarball":"https://registry.npmjs.org/@alessiofrittoli/server-sent-events/-/server-sent-events-1.0.0.tgz","fileCount":7,"integrity":"sha512-wY2m4KRFuRNHxFlDXh7Zpwb5BmuqGQxpfXD0B4mAcFewePTIYePIjW4N/qbSa2uoDrWdTpZSFuYMbgfc9h+uPA==","signatures":[{"sig":"MEUCIQCJODqn4PCqvQTqwv3E0JLKr3UpfQ8M095YNg8R/sLChwIgO+qwtgLvY4XpFvKpRUzFevoDnxBwQRWXqp6N7fFrp3w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":30793},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","gitHead":"e6ebce31e40c5d6a29caaac3404312acebac4dd7","scripts":{"build":"tsup"},"_npmUser":{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"},"repository":{"url":"git+https://github.com/alessiofrittoli/server-sent-events.git","type":"git"},"_npmVersion":"10.9.0","description":"Class Based ismplementation for Server-Sent events","directories":{},"_nodeVersion":"20.18.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","typescript":"^5.6.3"},"_npmOperationalInternal":{"tmp":"tmp/server-sent-events_1.0.0_1732198053959_0.9515073532396621","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@alessiofrittoli/server-sent-events","version":"1.0.1","keywords":["server-sent-events","streaming"],"author":{"url":"https://alessiofrittoli.it","name":"Alessio Frittoli","email":"info@alessiofrittoli.it"},"license":"MIT","_id":"@alessiofrittoli/server-sent-events@1.0.1","maintainers":[{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"}],"homepage":"https://github.com/alessiofrittoli/server-sent-events#readme","bugs":{"url":"https://github.com/alessiofrittoli/server-sent-events/issues","email":"project@hostname.com"},"dist":{"shasum":"c8eb53cdc844ad2a204c54ceb9c2354abcc674de","tarball":"https://registry.npmjs.org/@alessiofrittoli/server-sent-events/-/server-sent-events-1.0.1.tgz","fileCount":7,"integrity":"sha512-UdaMBQ73bgFvMqie+37iKmci01ULkRDwfxrbP5PYQ81D0D31q7nDCX9onlP/OpsAtSKnlX7/R0aFAKqGtaHlkw==","signatures":[{"sig":"MEQCICEVsGjw4aB+CBn7FlUOd0/sYF99f8p6v3v/3flhxO3bAiA97qC/gH458jtedrOKkOvGVdi8EY2as6RUpQZUyQ89uA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":30792},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","gitHead":"849ca458b49942885edffbc52b6bc5fe8ff9a6b0","scripts":{"build":"tsup"},"_npmUser":{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"},"repository":{"url":"git+https://github.com/alessiofrittoli/server-sent-events.git","type":"git"},"_npmVersion":"10.9.0","description":"Class Based implementation for Server-Sent events","directories":{},"_nodeVersion":"20.18.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","typescript":"^5.6.3"},"_npmOperationalInternal":{"tmp":"tmp/server-sent-events_1.0.1_1732217472915_0.9292641074676697","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"@alessiofrittoli/server-sent-events","version":"1.1.0","keywords":["server-sent-events","streaming"],"author":{"url":"https://alessiofrittoli.it","name":"Alessio Frittoli","email":"info@alessiofrittoli.it"},"license":"MIT","_id":"@alessiofrittoli/server-sent-events@1.1.0","maintainers":[{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"}],"homepage":"https://github.com/alessiofrittoli/server-sent-events#readme","bugs":{"url":"https://github.com/alessiofrittoli/server-sent-events/issues","email":"project@hostname.com"},"dist":{"shasum":"d91f281bcafa2dcf737dd31b58cba462f92aeaa9","tarball":"https://registry.npmjs.org/@alessiofrittoli/server-sent-events/-/server-sent-events-1.1.0.tgz","fileCount":7,"integrity":"sha512-guY1mWkYP7nXsFgv45aGYPobEhZvjGXy3zVOx9a/n1A6rTzB4UVEpy1XSi+/aRtgGtXxYbcGrNj+27YZ0ycHbA==","signatures":[{"sig":"MEQCIAvhsywcBZN1gzKIildG79UTqcPXsfVNBKNO2K6EZifaAiBXKCWP1NvHEHKB2lWZ1tQrcLEMqDwfX9k2OfD9r2hVgA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":31595},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","gitHead":"d76f4c1a02090aa77e9a0170287cbf4ce1b257f9","scripts":{"build":"tsup"},"_npmUser":{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"},"repository":{"url":"git+https://github.com/alessiofrittoli/server-sent-events.git","type":"git"},"_npmVersion":"10.9.0","description":"Class Based implementation for Server-Sent events","directories":{},"_nodeVersion":"20.18.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","typescript":"^5.6.3"},"_npmOperationalInternal":{"tmp":"tmp/server-sent-events_1.1.0_1732218429611_0.6044897267082892","host":"s3://npm-registry-packages"}},"1.2.0":{"name":"@alessiofrittoli/server-sent-events","version":"1.2.0","keywords":["server-sent-events","streaming"],"author":{"url":"https://alessiofrittoli.it","name":"Alessio Frittoli","email":"info@alessiofrittoli.it"},"license":"MIT","_id":"@alessiofrittoli/server-sent-events@1.2.0","maintainers":[{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"}],"homepage":"https://github.com/alessiofrittoli/server-sent-events#readme","bugs":{"url":"https://github.com/alessiofrittoli/server-sent-events/issues","email":"project@hostname.com"},"dist":{"shasum":"54ae11d1810d48c177edd4fbd2fefce0d180c102","tarball":"https://registry.npmjs.org/@alessiofrittoli/server-sent-events/-/server-sent-events-1.2.0.tgz","fileCount":7,"integrity":"sha512-p7BtyIzyWr6wBq4ysbbQMEMp7fa9bMtE0VMg0WFpzRGKUVKyv1h7hwAFbsFN9VlA3vpkOW3YUSr8jyKgeTKAyA==","signatures":[{"sig":"MEYCIQCQ+IyqRSlHFRHFFyeQ+Sh7N7wBVfkmDEeIdWyL9O3hGAIhAMspkbVXH5i+L2V38/3jL2TGVUykLIPNgDY8FWHvCXNS","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":32817},"main":"./dist/index.js","_from":"file:alessiofrittoli-server-sent-events-1.2.0.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","scripts":{"lint":"eslint","test":"jest --watchAll --verbose","build":"pnpm lint && pnpm test:ci && tsup","release":"node scripts/publish.js --verbose --npm","test:ci":"jest --ci --verbose","test:jest":"pnpm test jest.test.ts","build:watch":"tsup --watch","test:coverage":"concurrently --prefix none --kill-others \"pnpm jest --watchAll --verbose --coverage\" \"pnpm test:serve-coverage\"","test:jest:jsdom":"JSDOM=true pnpm test:jest","test:server-events":"pnpm test server-events.test.ts","test:coverage:jsdom":"JSDOM=true pnpm test:coverage","test:serve-coverage":"http-server ./coverage/lcov-report --gzip true -p 0 -o --silent"},"_npmUser":{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"},"_resolved":"/private/var/folders/vw/x6y06sz974x6xd8ft1h5dh1r0000gn/T/89b15cbdbf4ab1faf7d5707c2f8e0c32/alessiofrittoli-server-sent-events-1.2.0.tgz","_integrity":"sha512-p7BtyIzyWr6wBq4ysbbQMEMp7fa9bMtE0VMg0WFpzRGKUVKyv1h7hwAFbsFN9VlA3vpkOW3YUSr8jyKgeTKAyA==","repository":{"url":"git+https://github.com/alessiofrittoli/server-sent-events.git","type":"git"},"_npmVersion":"10.9.0","description":"Class Based implementation for Server-Sent events","directories":{},"_nodeVersion":"20.18.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","tsup":"^8.3.5","dotenv":"^16.4.7","eslint":"^9.17.0","globals":"^15.14.0","ts-jest":"^29.2.5","ts-node":"^10.9.2","@eslint/js":"^9.17.0","typescript":"^5.7.2","@types/jest":"^29.5.14","@types/node":"^22.10.2","http-server":"^14.1.1","concurrently":"^9.1.0","@jest/globals":"^29.7.0","typescript-eslint":"^8.18.2","jest-environment-jsdom":"^29.7.0","@alessiofrittoli/node-scripts":"^2.0.1","@alessiofrittoli/stream-reader":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/server-sent-events_1.2.0_1735137155897_0.5947873519763476","host":"s3://npm-registry-packages-npm-production"}},"1.3.1":{"name":"@alessiofrittoli/server-sent-events","version":"1.3.1","keywords":["server-sent-events","streaming"],"author":{"url":"https://alessiofrittoli.it","name":"Alessio Frittoli","email":"info@alessiofrittoli.it"},"license":"MIT","_id":"@alessiofrittoli/server-sent-events@1.3.1","maintainers":[{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"}],"homepage":"https://github.com/alessiofrittoli/server-sent-events#readme","bugs":{"url":"https://github.com/alessiofrittoli/server-sent-events/issues","email":"project@hostname.com"},"dist":{"shasum":"af806c94c41f7807b99ce3ab67b48feee022b1bc","tarball":"https://registry.npmjs.org/@alessiofrittoli/server-sent-events/-/server-sent-events-1.3.1.tgz","fileCount":7,"integrity":"sha512-QD5Jgd3+yLzcGdkSmlXL41MKWnLdI4+tuDYMzfuWhV3Y6rOmRPPbnydl5Y2jeP1ZA5FhFbapPedhFF38iyKKKA==","signatures":[{"sig":"MEYCIQCzrXiK005bY2M4hyvu8LrQT76HS6HRRABkGH5iwLuFTwIhAJH2nI03odV9L6wL02rythS5SgAqN+rdEbvWRM/S+JhK","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33414},"main":"./dist/index.js","_from":"file:alessiofrittoli-server-sent-events-1.3.1.tgz","types":"./dist/index.d.ts","module":"./dist/index.mjs","scripts":{"lint":"eslint","test":"jest --watchAll --verbose","build":"pnpm lint && pnpm test:ci && tsup","release":"node scripts/publish.js --verbose --npm","test:ci":"jest --ci --verbose","test:jest":"pnpm test jest.test.ts","test:jsdom":"JSDOM=true pnpm test","build:watch":"tsup --watch","test:ci:jsdom":"JSDOM=true pnpm test:ci","test:coverage":"pnpm test --coverage","test:jest:jsdom":"JSDOM=true pnpm test:jest","test:ci:coverage":"pnpm test:ci --coverage","test:server-events":"pnpm test server-events.test.ts","test:coverage:jsdom":"JSDOM=true pnpm test:coverage","test:coverage:serve":"concurrently --prefix none --kill-others \"jest --watchAll --verbose --coverage\" \"pnpm test:serve-coverage\"","test:serve-coverage":"http-server ./coverage/lcov-report --gzip true -p 0 -o --silent","test:coverage:jsdom:serve":"JSDOM=true pnpm test:coverage:serve"},"_npmUser":{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"},"_resolved":"/private/var/folders/vw/x6y06sz974x6xd8ft1h5dh1r0000gn/T/822f21f9377ff5f7f9790b8835111b07/alessiofrittoli-server-sent-events-1.3.1.tgz","_integrity":"sha512-QD5Jgd3+yLzcGdkSmlXL41MKWnLdI4+tuDYMzfuWhV3Y6rOmRPPbnydl5Y2jeP1ZA5FhFbapPedhFF38iyKKKA==","repository":{"url":"git+https://github.com/alessiofrittoli/server-sent-events.git","type":"git"},"_npmVersion":"10.9.0","description":"Class Based implementation for Server-Sent events","directories":{},"_nodeVersion":"20.18.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","tsup":"^8.3.5","dotenv":"^16.4.7","eslint":"^9.17.0","globals":"^15.14.0","ts-jest":"^29.2.5","ts-node":"^10.9.2","@eslint/js":"^9.17.0","typescript":"^5.7.2","@types/jest":"^29.5.14","@types/node":"^22.10.2","http-server":"^14.1.1","concurrently":"^9.1.0","@jest/globals":"^29.7.0","typescript-eslint":"^8.18.2","jest-environment-jsdom":"^29.7.0","@alessiofrittoli/node-scripts":"^2.0.1","@alessiofrittoli/stream-reader":"^1.1.0"},"_npmOperationalInternal":{"tmp":"tmp/server-sent-events_1.3.1_1735240729530_0.9100706912084859","host":"s3://npm-registry-packages-npm-production"}},"1.4.0":{"name":"@alessiofrittoli/server-sent-events","version":"1.4.0","keywords":["server-sent-events","streaming"],"author":{"url":"https://alessiofrittoli.it","name":"Alessio Frittoli","email":"info@alessiofrittoli.it"},"license":"MIT","_id":"@alessiofrittoli/server-sent-events@1.4.0","maintainers":[{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"}],"homepage":"https://github.com/alessiofrittoli/server-sent-events#readme","bugs":{"url":"https://github.com/alessiofrittoli/server-sent-events/issues","email":"info@alessiofrittoli.it"},"dist":{"shasum":"be736e770b42c3c29c377d2a9a7b7fcec82a591d","tarball":"https://registry.npmjs.org/@alessiofrittoli/server-sent-events/-/server-sent-events-1.4.0.tgz","fileCount":7,"integrity":"sha512-TmzlPqBtNIJdl7G4k1T4dVMcnimfJj22FwOUMqOTkmlIFgWvua+Z/jHDM9hsx6XXZ/OAud4sd5a2ULatmrbiCg==","signatures":[{"sig":"MEQCIGUxpPfn1kz+wCGThHFyUMe5xxJUWN8ibxyH611z4GNRAiBGgIZjhL1Bc088BCaEKlR0EDgw1q2eq3eFn9Pvv2SZ+A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":35259},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","gitHead":"49cf20b9b0fb0e34713cd8a962c6117fca349e73","scripts":{"lint":"eslint","test":"jest","build":"pnpm lint && pnpm test:ci && tsup","release":"node scripts/publish.js --verbose --npm","test:ci":"jest --ci --verbose","test:jest":"test:watch jest.test.ts","test:jsdom":"JSDOM=true pnpm test:watch","test:watch":"jest --watchAll --verbose","build:watch":"tsup --watch","test:ci:jsdom":"JSDOM=true pnpm test:ci","test:coverage":"pnpm test:watch --coverage","test:jest:jsdom":"JSDOM=true test:watch:jest","test:ci:coverage":"pnpm test:ci --coverage","test:server-events":"test:watch server-events.test.ts","test:coverage:jsdom":"JSDOM=true pnpm test:coverage","test:coverage:serve":"concurrently --prefix none --kill-others \"pnpm test:coverage\" \"pnpm test:serve-coverage\"","test:serve-coverage":"http-server ./coverage/lcov-report --gzip true -p 0 -o --silent","test:coverage:jsdom:serve":"JSDOM=true pnpm test:coverage:serve"},"_npmUser":{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"},"repository":{"url":"git+https://github.com/alessiofrittoli/server-sent-events.git","type":"git"},"_npmVersion":"10.9.0","description":"Class Based implementation for Server-Sent events","directories":{},"_nodeVersion":"22.12.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","tsup":"^8.3.5","dotenv":"^16.4.7","eslint":"^9.18.0","globals":"^15.14.0","ts-jest":"^29.2.5","ts-node":"^10.9.2","@eslint/js":"^9.18.0","typescript":"^5.7.3","@types/jest":"^29.5.14","@types/node":"^22.10.7","http-server":"^14.1.1","concurrently":"^9.1.2","@jest/globals":"^29.7.0","typescript-eslint":"^8.20.0","jest-environment-jsdom":"^29.7.0","@alessiofrittoli/node-scripts":"^2.2.1","@alessiofrittoli/stream-reader":"^1.3.0"},"_npmOperationalInternal":{"tmp":"tmp/server-sent-events_1.4.0_1737134549422_0.5170157551152599","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@alessiofrittoli/server-sent-events","version":"2.0.0","keywords":["server-sent-events","streaming"],"author":{"url":"https://alessiofrittoli.it","name":"Alessio Frittoli","email":"info@alessiofrittoli.it"},"license":"MIT","_id":"@alessiofrittoli/server-sent-events@2.0.0","maintainers":[{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"}],"homepage":"https://github.com/alessiofrittoli/server-sent-events#readme","bugs":{"url":"https://github.com/alessiofrittoli/server-sent-events/issues","email":"info@alessiofrittoli.it"},"dist":{"shasum":"b13d68db897470b4fcf8eecc370e830ec5ee9ed6","tarball":"https://registry.npmjs.org/@alessiofrittoli/server-sent-events/-/server-sent-events-2.0.0.tgz","fileCount":7,"integrity":"sha512-11ghgCooqp3ZTXdEFrl6sNtkTHHu1sraDzMbv20xC7bzCXNg8cv9hXPRXR3fZ2fy3a0F8mqro4VuvTCW4ZhsVA==","signatures":[{"sig":"MEQCIHXLUxvXrX/TDMNqLD4Nl/s/MrT5PPACk92U0EVHF04qAiBbhAAy1r8I362ggDdIHxX3gPhuHGM2hU1J+LsxD1H+Qg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33010},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","gitHead":"c83610a47941287081a46fa51abe52f9f70677dd","scripts":{"lint":"eslint","test":"jest","build":"pnpm lint && pnpm test:ci && tsup","release":"node scripts/publish.js --verbose --npm","test:ci":"jest --ci --verbose","test:jest":"test:watch jest.test.ts","test:jsdom":"JSDOM=true pnpm test:watch","test:watch":"jest --watchAll --verbose","build:watch":"tsup --watch","test:ci:jsdom":"JSDOM=true pnpm test:ci","test:coverage":"pnpm test:watch --coverage","test:jest:jsdom":"JSDOM=true test:watch:jest","test:ci:coverage":"pnpm test:ci --coverage","test:server-events":"test:watch server-events.test.ts","test:coverage:jsdom":"JSDOM=true pnpm test:coverage","test:coverage:serve":"concurrently --prefix none --kill-others \"pnpm test:coverage\" \"pnpm test:serve-coverage\"","test:serve-coverage":"http-server ./coverage/lcov-report --gzip true -p 0 -o --silent","test:coverage:jsdom:serve":"JSDOM=true pnpm test:coverage:serve"},"_npmUser":{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"},"repository":{"url":"git+https://github.com/alessiofrittoli/server-sent-events.git","type":"git"},"_npmVersion":"10.9.0","description":"Class Based implementation for Server-Sent events","directories":{},"_nodeVersion":"22.12.0","dependencies":{"@alessiofrittoli/stream-writer":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","tsup":"^8.3.5","dotenv":"^16.4.7","eslint":"^9.18.0","globals":"^15.14.0","ts-jest":"^29.2.5","ts-node":"^10.9.2","@eslint/js":"^9.18.0","typescript":"^5.7.3","@types/jest":"^29.5.14","@types/node":"^22.10.7","http-server":"^14.1.1","concurrently":"^9.1.2","@jest/globals":"^29.7.0","typescript-eslint":"^8.20.0","jest-environment-jsdom":"^29.7.0","@alessiofrittoli/node-scripts":"^2.2.1","@alessiofrittoli/stream-reader":"^1.3.0"},"_npmOperationalInternal":{"tmp":"tmp/server-sent-events_2.0.0_1737204706959_0.3548569187997175","host":"s3://npm-registry-packages-npm-production"}},"2.1.0":{"name":"@alessiofrittoli/server-sent-events","version":"2.1.0","keywords":["server-sent-events","streaming"],"author":{"url":"https://alessiofrittoli.it","name":"Alessio Frittoli","email":"info@alessiofrittoli.it"},"license":"MIT","_id":"@alessiofrittoli/server-sent-events@2.1.0","maintainers":[{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"}],"homepage":"https://github.com/alessiofrittoli/server-sent-events#readme","bugs":{"url":"https://github.com/alessiofrittoli/server-sent-events/issues","email":"info@alessiofrittoli.it"},"dist":{"shasum":"0468de54e465f4cc89c442a2c1672f03c32406e7","tarball":"https://registry.npmjs.org/@alessiofrittoli/server-sent-events/-/server-sent-events-2.1.0.tgz","fileCount":9,"integrity":"sha512-MQkX3imI7gjXxqQjVQ8+JZ4Mha32HdZAsFuS5H0kXEGE+y9gzmOTRQSsL54jr+LOvuJO0aCiWe0t2SalFjQ4Iw==","signatures":[{"sig":"MEYCIQDzFIZg8asmDLG5Ynp5VFGqRfJFeU06xaPDfunCllIpzgIhAI3Hn4O0oueLZh+FSCa8Zr42KbntVMirdRd02a6TocVC","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":55452},"main":"./dist/index.js","pnpm":{"onlyBuiltDependencies":["esbuild"]},"types":"./dist/index.d.ts","module":"./dist/index.mjs","funding":[{"url":"https://github.com/sponsors/alessiofrittoli","type":"github"}],"gitHead":"7cd352bd15ce0bcb32bc54b3453e08e00810c730","scripts":{"//1a":"*********************************************************************","//1b":"*********************** BUILD - LINT - RELEASE **********************","//1c":"*********************************************************************","//2a":"*********************************************************************","//2b":"***************************** UNIT TESTS ****************************","//2c":"*********************************************************************","//3a":"*********************************************************************","//3b":"************************ UNIT TESTS COVERAGE ************************","//3c":"*********************************************************************","//4a":"*********************************************************************","//4b":"************************ TARGETED UNIT TESTS ************************","//4c":"*********************************************************************","lint":"eslint","test":"jest --verbose","build":"pnpm lint && pnpm test:ci && tsup","release":"node scripts/publish.js --verbose --npm","test:ci":"jest --ci --verbose","test:jest":"pnpm test:watch jest.test.ts","test:jsdom":"JSDOM=true pnpm test:watch","test:watch":"jest --watchAll --verbose","build:watch":"tsup --watch","test:ci:jsdom":"JSDOM=true pnpm test:ci","test:coverage":"pnpm test:watch --coverage","test:jest:jsdom":"JSDOM=true pnpm test:jest","test:ci:coverage":"pnpm test:ci --coverage","test:server-events":"test:watch server-events.test.ts","test:coverage:jsdom":"JSDOM=true pnpm test:coverage","test:coverage:serve":"concurrently --prefix none --kill-others \"pnpm test:coverage\" \"pnpm test:serve-coverage\"","test:serve-coverage":"http-server ./coverage/lcov-report --gzip true -p 0 -o --silent","test:coverage:jsdom:serve":"JSDOM=true pnpm test:coverage:serve"},"_npmUser":{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"},"repository":{"url":"git+https://github.com/alessiofrittoli/server-sent-events.git","type":"git"},"_npmVersion":"10.9.0","description":"Class Based implementation for Server-Sent events","directories":{},"_nodeVersion":"22.12.0","dependencies":{"@alessiofrittoli/stream-writer":"^1.1.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","tsup":"^8.4.0","dotenv":"^16.4.7","eslint":"^9.22.0","globals":"^16.0.0","ts-jest":"^29.2.6","ts-node":"^10.9.2","@eslint/js":"^9.22.0","typescript":"^5.8.2","@types/jest":"^29.5.14","@types/node":"^22.13.10","http-server":"^14.1.1","concurrently":"^9.1.2","@jest/globals":"^29.7.0","typescript-eslint":"^8.26.1","jest-environment-jsdom":"^29.7.0","@alessiofrittoli/node-scripts":"^2.3.0","@alessiofrittoli/stream-reader":"^2.2.0"},"_npmOperationalInternal":{"tmp":"tmp/server-sent-events_2.1.0_1742403470029_0.15331068096342593","host":"s3://npm-registry-packages-npm-production"}},"2.1.1":{"name":"@alessiofrittoli/server-sent-events","version":"2.1.1","keywords":["server-sent-events","streaming"],"author":{"url":"https://alessiofrittoli.it","name":"Alessio Frittoli","email":"info@alessiofrittoli.it"},"license":"MIT","_id":"@alessiofrittoli/server-sent-events@2.1.1","maintainers":[{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"}],"homepage":"https://github.com/alessiofrittoli/server-sent-events#readme","bugs":{"url":"https://github.com/alessiofrittoli/server-sent-events/issues","email":"info@alessiofrittoli.it"},"dist":{"shasum":"2e5868d6cc9e108629948c53e4358db36b8c0f0a","tarball":"https://registry.npmjs.org/@alessiofrittoli/server-sent-events/-/server-sent-events-2.1.1.tgz","fileCount":9,"integrity":"sha512-MTU7GHV9zzvyw//cV7/8uZvV80JE2l9Jlyc5SuKNZEPYuL1Nzyv/orTfo8U/Lgj1AGJOanbCNC4iCn01cBhSDA==","signatures":[{"sig":"MEUCIHzmvWbDxX2Z7Nudv53zBwKhNCeI7p2NgaV+nNk4pjPEAiEAuFFpT1R9MFpA584RG+1StvyEvGLqFs3nHvo/r9aPOHs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":55680},"main":"./dist/index.js","pnpm":{"onlyBuiltDependencies":["esbuild"]},"types":"./dist/index.d.ts","module":"./dist/index.mjs","funding":[{"url":"https://github.com/sponsors/alessiofrittoli","type":"github"}],"gitHead":"dbbba36f3f617867ea032481d6dae561fb4d72a3","scripts":{"//1a":"*********************************************************************","//1b":"*********************** BUILD - LINT - RELEASE **********************","//1c":"*********************************************************************","//2a":"*********************************************************************","//2b":"***************************** UNIT TESTS ****************************","//2c":"*********************************************************************","//3a":"*********************************************************************","//3b":"************************ UNIT TESTS COVERAGE ************************","//3c":"*********************************************************************","//4a":"*********************************************************************","//4b":"************************ TARGETED UNIT TESTS ************************","//4c":"*********************************************************************","lint":"eslint","test":"jest --verbose","build":"pnpm lint && pnpm test:ci && tsup","release":"node scripts/publish.js --verbose --npm","test:ci":"jest --ci --verbose","test:jest":"pnpm test:watch jest.test.ts","test:jsdom":"JSDOM=true pnpm test:watch","test:watch":"jest --watchAll --verbose","build:watch":"tsup --watch","test:ci:jsdom":"JSDOM=true pnpm test:ci","test:coverage":"pnpm test:watch --coverage","test:jest:jsdom":"JSDOM=true pnpm test:jest","test:ci:coverage":"pnpm test:ci --coverage","test:server-events":"test:watch server-events.test.ts","test:coverage:jsdom":"JSDOM=true pnpm test:coverage","test:coverage:serve":"concurrently --prefix none --kill-others \"pnpm test:coverage\" \"pnpm test:serve-coverage\"","test:serve-coverage":"http-server ./coverage/lcov-report --gzip true -p 0 -o --silent","test:coverage:jsdom:serve":"JSDOM=true pnpm test:coverage:serve"},"_npmUser":{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"},"repository":{"url":"git+https://github.com/alessiofrittoli/server-sent-events.git","type":"git"},"_npmVersion":"10.9.0","description":"Class Based implementation for Server-Sent events","directories":{},"_nodeVersion":"22.12.0","dependencies":{"@alessiofrittoli/stream-writer":"^1.1.1"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","tsup":"^8.4.0","dotenv":"^16.4.7","eslint":"^9.22.0","globals":"^16.0.0","ts-jest":"^29.2.6","ts-node":"^10.9.2","@eslint/js":"^9.22.0","typescript":"^5.8.2","@types/jest":"^29.5.14","@types/node":"^22.13.10","http-server":"^14.1.1","concurrently":"^9.1.2","@jest/globals":"^29.7.0","typescript-eslint":"^8.26.1","jest-environment-jsdom":"^29.7.0","@alessiofrittoli/node-scripts":"^2.3.1","@alessiofrittoli/stream-reader":"^2.2.1"},"_npmOperationalInternal":{"tmp":"tmp/server-sent-events_2.1.1_1742408906501_0.6835059171665536","host":"s3://npm-registry-packages-npm-production"}},"2.2.0":{"name":"@alessiofrittoli/server-sent-events","version":"2.2.0","keywords":["server-sent-events","streaming"],"author":{"url":"https://alessiofrittoli.it","name":"Alessio Frittoli","email":"info@alessiofrittoli.it"},"license":"MIT","_id":"@alessiofrittoli/server-sent-events@2.2.0","maintainers":[{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"}],"homepage":"https://github.com/alessiofrittoli/server-sent-events#readme","bugs":{"url":"https://github.com/alessiofrittoli/server-sent-events/issues","email":"info@alessiofrittoli.it"},"dist":{"shasum":"4ec3199935280ff067b60138b0f2309011e7bd70","tarball":"https://registry.npmjs.org/@alessiofrittoli/server-sent-events/-/server-sent-events-2.2.0.tgz","fileCount":9,"integrity":"sha512-Oo/Cq8q1SfI2yCVcrZiAAc7mAq7m3iKAwHKssfj5GNvKe2UFdX7GaCf6tiwOsC5KzSAz1Rm//aDKYIX+/hIwwg==","signatures":[{"sig":"MEUCIC5j0wQr63tL2YySNAFT1m66mOoLvM4j15V/RqT7gtjZAiEA9nZ64uFYYa7iY7m9wsoPUwd3fwfJWi+kGV4EFuRCj6g=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54963},"main":"./dist/index.js","pnpm":{"onlyBuiltDependencies":["esbuild"]},"types":"./dist/index.d.ts","module":"./dist/index.mjs","funding":[{"url":"https://github.com/sponsors/alessiofrittoli","type":"github"}],"gitHead":"8a5efe91c77e3bb2882e7e52aea4622d30bdd289","scripts":{"//1a":"*********************************************************************","//1b":"*********************** BUILD - LINT - RELEASE **********************","//1c":"*********************************************************************","//2a":"*********************************************************************","//2b":"***************************** UNIT TESTS ****************************","//2c":"*********************************************************************","//3a":"*********************************************************************","//3b":"************************ UNIT TESTS COVERAGE ************************","//3c":"*********************************************************************","lint":"eslint","test":"jest --verbose","build":"pnpm lint && pnpm test:ci && tsup","release":"node scripts/publish.js --verbose --npm","test:ci":"jest --ci --verbose","test:watch":"jest --watchAll --verbose","build:watch":"tsup --watch","test:coverage":"pnpm test:watch --coverage","test:ci:coverage":"pnpm test:ci --coverage","test:coverage:serve":"concurrently --prefix none --kill-others \"pnpm test:coverage\" \"pnpm test:serve-coverage\"","test:serve-coverage":"http-server ./coverage/lcov-report --gzip true -p 0 -o --silent"},"_npmUser":{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"},"repository":{"url":"git+https://github.com/alessiofrittoli/server-sent-events.git","type":"git"},"_npmVersion":"10.9.0","description":"Class Based implementation for Server-Sent events","directories":{},"_nodeVersion":"22.12.0","dependencies":{"@alessiofrittoli/stream-writer":"^1.2.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","tsup":"^8.4.0","dotenv":"^16.4.7","eslint":"^9.22.0","globals":"^16.0.0","ts-jest":"^29.2.6","ts-node":"^10.9.2","@eslint/js":"^9.22.0","typescript":"^5.8.2","@types/jest":"^29.5.14","@types/node":"^22.13.11","http-server":"^14.1.1","concurrently":"^9.1.2","@jest/globals":"^29.7.0","typescript-eslint":"^8.27.0","@alessiofrittoli/node-scripts":"^2.4.0","@alessiofrittoli/stream-reader":"^2.3.0"},"_npmOperationalInternal":{"tmp":"tmp/server-sent-events_2.2.0_1742559667100_0.23154867149646496","host":"s3://npm-registry-packages-npm-production"}},"2.3.0":{"name":"@alessiofrittoli/server-sent-events","version":"2.3.0","keywords":["server-sent-events","streaming"],"author":{"url":"https://alessiofrittoli.it","name":"Alessio Frittoli","email":"info@alessiofrittoli.it"},"license":"MIT","_id":"@alessiofrittoli/server-sent-events@2.3.0","maintainers":[{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"}],"homepage":"https://github.com/alessiofrittoli/server-sent-events#readme","bugs":{"url":"https://github.com/alessiofrittoli/server-sent-events/issues","email":"info@alessiofrittoli.it"},"dist":{"shasum":"083931475c131a864e012cda5a9622a7a4827d3c","tarball":"https://registry.npmjs.org/@alessiofrittoli/server-sent-events/-/server-sent-events-2.3.0.tgz","fileCount":7,"integrity":"sha512-Y3MQqJoLjTMg3FTctCFIYB9vs2+hImzo8zX/K8yJKM+Z54X3Ll2OtLhQwHTu3TEgBvBgZUMvYrdHskp1cV5hOg==","signatures":[{"sig":"MEUCICxSX0XnZ7w7AyHUHA283kKXOI2XDiOts/i+NtVr9n3WAiEAjjAqqmWy1NlSyUxFIRaBtPsaBBAZh4uG4n3A+wHKZDk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":35833},"main":"./dist/index.js","pnpm":{"onlyBuiltDependencies":["esbuild"]},"types":"./dist/index.d.ts","module":"./dist/index.mjs","funding":[{"url":"https://github.com/sponsors/alessiofrittoli","type":"github"}],"gitHead":"388be14d12f8c18dfc61e7e179bca9549000efaf","scripts":{"dev":"NODE_ENV=development tsup --watch","//1a":"*********************************************************************","//1b":"******************** DEV - BUILD - LINT - RELEASE *******************","//1c":"*********************************************************************","//2a":"*********************************************************************","//2b":"***************************** UNIT TESTS ****************************","//2c":"*********************************************************************","//3a":"*********************************************************************","//3b":"************************ UNIT TESTS COVERAGE ************************","//3c":"*********************************************************************","lint":"eslint","test":"jest --verbose","build":"pnpm lint && pnpm test:ci && pnpm build:prod","release":"node scripts/publish.js --verbose --npm","test:ci":"jest --ci --verbose","build:prod":"NODE_ENV=production tsup","test:watch":"jest --watchAll --verbose","test:coverage":"pnpm test:watch --coverage","test:coverage:ci":"pnpm test:ci --coverage","test:coverage:serve":"concurrently --prefix none --kill-others \"pnpm test:coverage\" \"pnpm test:serve-coverage\"","test:serve-coverage":"http-server ./coverage/lcov-report --gzip true -p 0 -o --silent"},"_npmUser":{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"},"repository":{"url":"git+https://github.com/alessiofrittoli/server-sent-events.git","type":"git"},"_npmVersion":"11.0.0","description":"Class Based implementation for Server-Sent events","directories":{},"_nodeVersion":"22.12.0","dependencies":{"@alessiofrittoli/stream-writer":"^1.3.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","tsup":"^8.4.0","dotenv":"^16.5.0","eslint":"^9.25.1","globals":"^16.0.0","ts-jest":"^29.3.2","ts-node":"^10.9.2","@eslint/js":"^9.25.1","typescript":"^5.8.3","@types/jest":"^29.5.14","@types/node":"^22.15.3","http-server":"^14.1.1","concurrently":"^9.1.2","@jest/globals":"^29.7.0","typescript-eslint":"^8.31.1","@alessiofrittoli/node-scripts":"^2.5.0","@alessiofrittoli/stream-reader":"^2.5.0"},"_npmOperationalInternal":{"tmp":"tmp/server-sent-events_2.3.0_1746207496228_0.9681878896182075","host":"s3://npm-registry-packages-npm-production"}},"2.4.0":{"name":"@alessiofrittoli/server-sent-events","version":"2.4.0","description":"Class Based implementation for Server-Sent events","author":{"name":"Alessio Frittoli","email":"info@alessiofrittoli.it","url":"https://alessiofrittoli.it"},"license":"MIT","funding":[{"type":"github","url":"https://github.com/sponsors/alessiofrittoli"}],"keywords":["server-sent-events","streaming"],"homepage":"https://github.com/alessiofrittoli/server-sent-events#readme","bugs":{"url":"https://github.com/alessiofrittoli/server-sent-events/issues","email":"info@alessiofrittoli.it"},"repository":{"type":"git","url":"git+https://github.com/alessiofrittoli/server-sent-events.git"},"main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","scripts":{"//1a":"*********************************************************************","//1b":"******************** DEV - BUILD - LINT - RELEASE *******************","//1c":"*********************************************************************","dev":"cross-env NODE_ENV=development tsup --watch","build:prod":"cross-env NODE_ENV=production tsup","build":"pnpm lint && pnpm test:ci && pnpm build:prod","lint":"eslint","release":"node scripts/release.js --verbose --npm","//2a":"*********************************************************************","//2b":"***************************** UNIT TESTS ****************************","//2c":"*********************************************************************","test":"jest --verbose","test:watch":"jest --watchAll --verbose","test:ci":"jest --ci --verbose","//3a":"*********************************************************************","//3b":"************************ UNIT TESTS COVERAGE ************************","//3c":"*********************************************************************","test:coverage":"pnpm test:watch --coverage","test:coverage:ci":"pnpm test:ci --coverage","test:serve-coverage":"http-server ./coverage/lcov-report --gzip true -p 0 -o --silent","test:coverage:serve":"concurrently --prefix none --kill-others \"pnpm test:coverage\" \"pnpm test:serve-coverage\""},"devDependencies":{"@alessiofrittoli/node-scripts":"^3.2.0","@alessiofrittoli/stream-reader":"^2.6.1","@eslint/js":"^9.39.1","@jest/globals":"^30.2.0","@types/jest":"^30.0.0","@types/node":"^24.10.1","concurrently":"^9.2.1","cross-env":"^10.1.0","dotenv":"^17.2.3","eslint":"^9.39.1","globals":"^16.5.0","http-server":"^14.1.1","jest":"^30.2.0","ts-jest":"^29.4.6","ts-node":"^10.9.2","tsup":"^8.5.1","typescript":"^5.9.3","typescript-eslint":"^8.48.1"},"dependencies":{"@alessiofrittoli/stream-writer":"^1.4.0"},"_id":"@alessiofrittoli/server-sent-events@2.4.0","gitHead":"825019038a4b52102e522f7c72ccbeaedc71c595","_nodeVersion":"22.15.0","_npmVersion":"11.5.2","dist":{"integrity":"sha512-vlJ6zZgnCEUEC/QEFLVgrckPY479vZS2mUrNagQNPfHFr1d0UlXsMxfUXgtyN695yVPQNbH4BTGU7o8p0mR7TQ==","shasum":"5af58a305d5646db13cf1d6facaa720431fa9a46","tarball":"https://registry.npmjs.org/@alessiofrittoli/server-sent-events/-/server-sent-events-2.4.0.tgz","fileCount":7,"unpackedSize":35817,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDhXYSZMRgOpllijRUV1+jw5Pp5sgFfpE6vQWbDkYorGAiEA3G2eFKM3359okBBW6HWuW5G3v9ypNfMMDNtK7zHgpc0="}]},"_npmUser":{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"},"directories":{},"maintainers":[{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/server-sent-events_2.4.0_1764786104895_0.1994530583194929"},"_hasShrinkwrap":false}},"time":{"created":"2024-11-21T14:07:33.859Z","modified":"2025-12-03T18:21:45.368Z","1.0.0":"2024-11-21T14:07:34.152Z","1.0.1":"2024-11-21T19:31:13.104Z","1.1.0":"2024-11-21T19:47:09.770Z","1.2.0":"2024-12-25T14:32:36.106Z","1.3.1":"2024-12-26T19:18:49.686Z","1.4.0":"2025-01-17T17:22:29.640Z","2.0.0":"2025-01-18T12:51:47.173Z","2.1.0":"2025-03-19T16:57:50.200Z","2.1.1":"2025-03-19T18:28:26.703Z","2.2.0":"2025-03-21T12:21:07.276Z","2.3.0":"2025-05-02T17:38:16.397Z","2.4.0":"2025-12-03T18:21:45.095Z"},"bugs":{"url":"https://github.com/alessiofrittoli/server-sent-events/issues","email":"info@alessiofrittoli.it"},"author":{"name":"Alessio Frittoli","email":"info@alessiofrittoli.it","url":"https://alessiofrittoli.it"},"license":"MIT","homepage":"https://github.com/alessiofrittoli/server-sent-events#readme","keywords":["server-sent-events","streaming"],"repository":{"type":"git","url":"git+https://github.com/alessiofrittoli/server-sent-events.git"},"description":"Class Based implementation for Server-Sent events","maintainers":[{"name":"alessiofrittoli","email":"info@alessiofrittoli.it"}],"readme":"# Server-Sent Events ✅\n\n[![NPM Latest Version][version-badge]][npm-url] [![Coverage Status][coverage-badge]][coverage-url] [![Socket Status][socket-badge]][socket-url] [![NPM Monthly Downloads][downloads-badge]][npm-url] [![Dependencies][deps-badge]][deps-url]\n\n[![GitHub Sponsor][sponsor-badge]][sponsor-url]\n\n[version-badge]: https://img.shields.io/npm/v/%40alessiofrittoli%2Fserver-sent-events\n[npm-url]: https://npmjs.org/package/%40alessiofrittoli%2Fserver-sent-events\n[coverage-badge]: https://coveralls.io/repos/github/alessiofrittoli/server-sent-events/badge.svg\n[coverage-url]: https://coveralls.io/github/alessiofrittoli/server-sent-events\n[socket-badge]: https://socket.dev/api/badge/npm/package/@alessiofrittoli/server-sent-events\n[socket-url]: https://socket.dev/npm/package/@alessiofrittoli/server-sent-events/overview\n[downloads-badge]: https://img.shields.io/npm/dm/%40alessiofrittoli%2Fserver-sent-events.svg\n[deps-badge]: https://img.shields.io/librariesio/release/npm/%40alessiofrittoli%2Fserver-sent-events\n[deps-url]: https://libraries.io/npm/%40alessiofrittoli%2Fserver-sent-events\n\n[sponsor-badge]: https://img.shields.io/static/v1?label=Fund%20this%20package&message=%E2%9D%A4&logo=GitHub&color=%23DB61A2\n[sponsor-url]: https://github.com/sponsors/alessiofrittoli\n\n## Class Based implementation for [Server-Sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events)\n\n### Table of Contents\n\n- [Getting started](#getting-started)\n  - [Server-Side](#server-side)\n    - [Streaming events data](#streaming-events-data)\n    - [Writing into the stream](#writing-into-the-stream)\n    - [Custom events](#custom-events)\n    - [Closing the stream](#closing-the-stream)\n    - [Error handling](#error-handling)\n    - [Abort handling](#abort-handling)\n  - [Client-Side](#client-side)\n    - [Reading server-sent events data](#reading-server-sent-events-data)\n    - [Reading server-sent custom events data](#reading-server-sent-custom-events-data)\n    - [Closing the EventSource](#closing-the-eventsource)\n    - [EventSource Error handling](#eventsource-error-handling)\n- [Development](#development)\n  - [Install depenendencies](#install-depenendencies)\n  - [Build the source code](#build-the-source-code)\n  - [ESLint](#eslint)\n  - [Jest](#jest)\n- [Contributing](#contributing)\n- [Security](#security)\n- [Credits](#made-with-)\n\n### Getting started\n\n#### Server-Side\n\n##### Streaming events data\n\nWith server-sent events, it's possible for a server to send new data to a web page at any time, by pushing messages to the web page. These incoming messages can be treated as Events + data inside the web page.\n\nBy creating a new instance of `ServerSentEvents` class you will get access to methods required to stream data to the client.\n\nSimple return `ServerSentEvents.stream.readable` in a `Response` instance to start streaming data.\\\n⚠️ Do not forget to return the proper response headers.\\\n⚠️ The streaming Response implementation depends on your back-end application.\n\n```typescript\nimport { ServerSentEvents } from '@alessiofrittoli/server-sent-events'\n\nconst sse = new ServerSentEvents()\n\nreturn (\n  new Response( sse.stream.readable, { headers: sse.headers } )\n)\n```\n\n##### Writing into the stream\n\nBy using the method `ServerSentEvents.write()` you can write and push any serializeable data to the client.\\\nThis method will serialize your data before sending it to the client by using `JSON.stringify()`.\\\nThe data is then read by the client by listening to the default `message` event on the `EventSource` instance (See **_[Reading server-sent events data](#reading-server-sent-events-data)_** for more information about reading received data).\n\nFor this example we are going to execute a function which simulates an asynchronous long task.\n\n```typescript\nimport { ServerSentEvents } from '@alessiofrittoli/server-sent-events'\n\nexport const sleep = ( ms: number ) => (\n  new Promise<void>( resolve => setTimeout( resolve, ms ) )\n)\n\nconst longRunningTask = async ( stream: ServerSentEvents ) => {\n  await stream.write( { message: 'Started' } )\n  await sleep( 1000 )\n  await stream.write( { message: 'Done 15%' } )\n  await sleep( 1000 )\n  await stream.write( { message: 'Done 35%' } )\n  await sleep( 1000 )\n  await stream.write( { message: 'Done 75%' } )\n  await sleep( 1000 )\n  await stream.write( { message: 'Final data' } )\n}\n\n\nconst businessLogic = () => {\n\n  const sse = new ServerSentEvents()\n\n  longRunningTask( sse )\n\n  return (\n      new Response( sse.stream.readable )\n  )\n\n}\n```\n\n##### Custom events\n\nBy default our data is implicitly sent over the default `message` event.\n\nHowever, you may need to push new data into the same connection stream under a custom event.\\\nWe can then specify its name as 2nd argument of the `ServerSentEvents.write()` method like so:\n\n```typescript\n...\n\nsse.write( { message: 'My data' }, 'customEvent' )\n\n...\n```\n\nNotice that the client should now add a new listener to the `EventSource` instance referring to the name of the custom event.\\\nPlease refer to the **_[Reading server-sent custom events data](#reading-server-sent-custom-events-data)_** section for more information.\n\n##### Closing the stream\n\nThe `EventSource` API has a built-in automatic reconnection mechanism. If the connection to the server is lost (due to network issues, server restart, etc.), the `EventSource` will try to reconnect after a delay if the client is not explicitly calling the [EventSource.close()](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/close) method. By default, this delay is 3 seconds, see **_[Reconnection policies](#reconnection-policies)_** section for more information.\n\nDue to the `EventSource` automatic recconnection mechanism the previous code will eventually end up in a sort of an infinite loop.\n\nTo tell the client that streaming is complete we can execute the `ServerSentEvents.close()` method.\nThis method will push a custom event named \"end\" in the stream and close the `ServerSentEvents.writer` (See **_[Custom events](#custom-events)_** section to learn more about custom events).\\\n⚠️ The client should listen for the \"end\" event and then close the `EventSource` connection with [EventSource.close()](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/close).\n\nSince our previous function returns a void Promise, we can await it and then call the `ServerSentEvents.close()` method like so:\n\n```typescript\n...\n\nconst businessLogic = () => {\n\n  const sse = new ServerSentEvents()\n\n  longRunningTask( sse )\n      .then( () => {\n          console.log( 'Streaming done.' )\n          sse.close()\n      } )\n\n  return (\n      new Response( sse.stream.readable )\n  )\n\n}\n```\n\n##### Reconnection policies\n\nThe `EventSource` API has a built-in automatic reconnection mechanism. If the connection to the server is lost (due to network issues, server restart, etc.), the `EventSource` will try to reconnect after a delay if the client is not explicitly calling the [EventSource.close()](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/close) method. By default, this delay is 3 seconds but the server can override this timing by setting the \"retry\" policy.\n\nWhen creating a new instance of `ServerSentEvents` we can specify the reconnection delay value in milliseconds to the \"retry\" property of the constructor like so:\n\n```typescript\nconst sse = new ServerSentEvents( { retry: 5000 } )\n```\n\n##### Error handling\n\nIf an error occures in our `longRunningTask` example function we can use the `ServerSentEvents.error()` method to push a custom `error` event to the stream.\nThe client should listen the default `error` event on the `EventSource` to handle errors client side.\n\nGood to know - Since the `ServerSentEvents.error()` will push an event with the name `error`, the client could use a single listener to listen default and custom errors (See **_[EventSource Error handling](#eventsource-error-handling)_** section to learn more about error handling on client).\n\n```typescript\n...\n\nconst businessLogic = () => {\n\n  ...\n\n  longRunningTask( sse )\n      .then( () => {\n          ...\n      } )\n      .catch( error => {\n          console.error( 'Failed', error )\n          sse.error( { message: error.message } )\n      } )\n\n  ...\n\n}\n```\n\n##### Abort handling\n\nSometimes, error handling or awaiting a task to be finished before closing the stream could be not enough.\nLet's assume your task is an infinite task (like returning the time once a second) and the user abort the `EventSource` request by closing the client or by calling the [EventSource.close()](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/close) method: your infinite task will be still running.\n\nMost back-end server applications will allow you to listen for an abort signal that will be fired when the request has been aborted by the client by forcibly shutting down the connection or by calling the [EventSource.close()](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/close) method.\nBy listening for an abort signal, we can then execute the `ServerSentEvents.abort()` which will abort the `ServerSentEvents.writer` and prevent subsequent write events by setting the `ServerSentEvents.closed` flag to `true`.\n\nFor this example, we are going to desing a function that will push to the stream the current date in a ISO string format once a second.\nIn our interval we check if `ServerSentEvents.closed` has been set to `true` before pushing new data into the stream and resolve the Promise if so.\n\n```typescript\n...\n\nconst timer = async ( stream: ServerSentEvents ) => {\n  await stream.write( { message: new Date().toISOString() } )\n  await new Promise<void>( resolve => {\n    const interval = setInterval( () => {\n      if ( stream.closed ) {\n        clearInterval( interval )\n        return resolve()\n      }\n      stream.write( { message: new Date().toISOString() } )\n    }, 1000 )\n  } )\n}\n\nconst businessLogic = request => {\n\n  ...\n\n  request.signal.addEventListener( 'abort', event => {\n    sse.abort( 'Request has been aborted from user.' )\n  } )\n\n  timer( sse )\n    .then( () => {\n        ...\n    } )\n    .catch( error => {\n        console.error( 'Failed', error )\n        if ( error.name === 'AbortError' ) return\n        sse.error( { message: error.message } )\n    } )\n\n  ...\n\n}\n```\n\n---\n\nIf you do not check if `ServerSentEvents.closed` is `true` before pushing new data, the `ServerSentEvents.write()` method will throw a `DOMException` with the given `AbortError` reason.\n\n```typescript\n...\n\nconst timer = async ( stream: ServerSentEvents ) => {\n  await stream.write( { message: new Date().toISOString() } )\n  await new Promise<void>( resolve => {\n    const interval = setInterval( () => {\n      stream.write( { message: new Date().toISOString() } )\n        .catch( error => {\n          clearInterval( interval )\n          return reject( error )\n          } )\n    }, 1000 )\n  } )\n}\n\nconst businessLogic = request => {\n\n  ...\n\n  request.signal.addEventListener( 'abort', event => {\n    sse.abort( 'Request has been aborted from user.' )\n  } )\n\n  timer( sse )\n      .then( () => {\n        ...\n      } )\n      .catch( error => {\n        console.error( 'Failed', error )\n        if ( error.name === 'AbortError' ) {\n          return console.log( 'Streaming stopped:', error.message )\n        }\n        sse.error( { message: error.message } )\n      } )\n\n  ...\n\n}\n```\n\n---\n\n#### Client-Side\n\n##### Reading server-sent events data\n\nTo listen server-sent events we can use the native [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) Web API.\\\nThe connection remains open until closed by calling [EventSource.close()](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/close).\n\nOnce the connection is opened, incoming messages from the server are delivered to your code in the form of events. If there is an event field in the incoming message, the triggered event is the same as the event field value. If no event field is present, then a generic `message` event is fired.\n\n```typescript\nconst eventSource = new EventSource( new URL( ... ) )\n\neventSource.addEventListener( 'open', event => {\n  console.log( 'Connection opened', event )\n} )\n\neventSource.addEventListener( 'message', event => {\n  const data = JSON.parse( event.data )\n  console.log( '\"message\" event received data', data )\n} )\n```\n\n##### Reading server-sent custom events data\n\nTo listen for incoming messages from the server sent over a custom event, we just add an event listener on the [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) instance like we've done in the previous example.\n\n```typescript\n...\n\neventSource.addEventListener( 'customEvent', event => {\n  const data = JSON.parse( event.data )\n  console.log( '\"customEvent\" event received data', data )\n} )\n```\n\n##### Closing the EventSource\n\nWe can call the [EventSource.close()](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/close) method arbitrarily or listen to the \"end\" event sent by the server to close the EventSource connection.\n\n```typescript\n...\n\nconst cancelRequestButton = document.querySelector( '#cancel' )\n\ncancelRequestButton.addEventListener( 'click', e vent=> {\n  eventSource.close()\n  console.log( 'User aborted the request.', eventSource.readyState )\n} )\n```\n\n```typescript\n...\n\neventSource.addEventListener( 'end', event => {\n  eventSource.close()\n  console.log( '\"end\" event received', eventSource.readyState, event )\n} )\n```\n\n##### EventSource Error handling\n\nBy default, errors are handled by listening to the \"error\" event on the EventSource instance.\\\nThe server may use this event too to return handled errors occured on the server while running its tasks.\n\n```typescript\neventSource.addEventListener( 'error', event => {\n  eventSource.close()\n  console.log( '\"error\" event', eventSource.readyState, event )\n} )\n```\n\n---\n\n### Development\n\n#### Install depenendencies\n\n```bash\nnpm install\n```\n\nor using `pnpm`\n\n```bash\npnpm i\n```\n\n#### Build the source code\n\nRun the following command to test and build code for distribution.\n\n```bash\npnpm build\n```\n\n#### [ESLint](https://www.npmjs.com/package/eslint)\n\nwarnings / errors check.\n\n```bash\npnpm lint\n```\n\n#### [Jest](https://npmjs.com/package/jest)\n\nRun all the defined test suites by running the following:\n\n```bash\n# Run tests and watch file changes.\npnpm test:watch\n\n# Run tests in a CI environment.\npnpm test:ci\n```\n\n- See [`package.json`](./package.json) file scripts for more info.\n\nRun tests with coverage.\n\nAn HTTP server is then started to serve coverage files from `./coverage` folder.\n\n⚠️ You may see a blank page the first time you run this command. Simply refresh the browser to see the updates.\n\n```bash\ntest:coverage:serve\n```\n\n---\n\n### Contributing\n\nContributions are truly welcome!\n\nPlease refer to the [Contributing Doc](./CONTRIBUTING.md) for more information on how to start contributing to this project.\n\nHelp keep this project up to date with [GitHub Sponsor][sponsor-url].\n\n[![GitHub Sponsor][sponsor-badge]][sponsor-url]\n\n---\n\n### Security\n\nIf you believe you have found a security vulnerability, we encourage you to **_responsibly disclose this and NOT open a public issue_**. We will investigate all legitimate reports. Email `security@alessiofrittoli.it` to disclose any security vulnerabilities.\n\n### Made with ☕\n\n<table style='display:flex;gap:20px;'>\n  <tbody>\n    <tr>\n      <td>\n        <img alt=\"avatar\" src='https://avatars.githubusercontent.com/u/35973186' style='width:60px;border-radius:50%;object-fit:contain;'>\n      </td>\n      <td>\n        <table style='display:flex;gap:2px;flex-direction:column;'>\n          <tbody>\n              <tr>\n                <td>\n                  <a href='https://github.com/alessiofrittoli' target='_blank' rel='noopener'>Alessio Frittoli</a>\n                </td>\n              </tr>\n              <tr>\n                <td>\n                  <small>\n                    <a href='https://alessiofrittoli.it' target='_blank' rel='noopener'>https://alessiofrittoli.it</a> |\n                    <a href='mailto:info@alessiofrittoli.it' target='_blank' rel='noopener'>info@alessiofrittoli.it</a>\n                  </small>\n                </td>\n              </tr>\n          </tbody>\n        </table>\n      </td>\n    </tr>\n  </tbody>\n</table>\n","readmeFilename":"README.md"}