{"_id":"mocksse","_rev":"7-d8bc490a2535d356bfb92207a7c220b1","time":{"0.1.0-alpha.1":"2018-08-25T03:06:23.966Z","created":"2018-08-26T08:18:30.279Z","1.0.0":"2018-08-26T08:18:30.422Z","modified":"2022-05-09T14:56:40.530Z","1.0.1":"2018-08-26T08:31:32.008Z","1.0.2":"2020-11-17T06:49:46.032Z","1.0.3":"2021-05-30T00:19:55.518Z","1.0.4":"2022-04-09T23:48:23.122Z"},"name":"mocksse","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"mocksse","version":"1.0.0","description":"Allows testing of EventSource / Server Sent Events","main":"src/mocksse.js","scripts":{"lint":"eslint .","deps":"npm-check","update:deps":"npm-check -u","test":"lab --assert code --coverage","test:debug":"node --inspect-brk ./node_modules/.bin/lab --assert code --timeout 0","pretest":"npm run lint"},"repository":{"type":"git","url":"git+https://gitlab.com/binarymist/mocksse.git"},"keywords":["Server Sent Events","SSE","mock","mocking","test","testing","EventSource"],"author":{"name":"BinaryMist","email":"services@binarymist.net"},"dependencies":{},"devDependencies":{"code":"^5.2.0","eslint":"^4.19.1","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.12.0","lab":"^15.5.0","npm-check":"^5.7.1","pre-commit":"^1.2.2"},"license":"MIT","bugs":{"url":"https://gitlab.com/binarymist/mocksse/issues"},"gitHead":"9d9c437f203bbe02f4af584893f890dd9fe7200c","homepage":"https://gitlab.com/binarymist/mocksse#README","_id":"mocksse@1.0.0","_npmVersion":"5.7.1","_nodeVersion":"8.9.4","_npmUser":{"name":"binarymist","email":"devout@hotmail.com"},"dist":{"integrity":"sha512-cCJ3/7PmaLiAF2czOTW5NwYgzo7bl+NuIngwbgzsR7RuolIw9/5urvy9qFJpNJNKdnvOIR/72WEvxx3vKj7yDg==","shasum":"32e767ae73c911f34e1e15f7e823a5126bc04f2f","tarball":"https://registry.npmjs.org/mocksse/-/mocksse-1.0.0.tgz","fileCount":9,"unpackedSize":36896,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbgmJWCRA9TVsSAnZWagAAFBcP/0FCkvG7hVCT3Qkk0UWV\ny39bZcZ76crvFhihhtRDqYMJ7xEsh2HNjqJ3v0JIBHLQ8M82g5x9+38SnqHQ\nbHKI7/rcxLsVy+6HLJ1Tol43VQMO9zutCFcQScCuYLjjdC2O7urQmoQlYlo3\nSazwG1yO6mJVPW3zwoGVOQiYQd71hG83xQ2PWu9ErjQIDv5wSWS0QRJfr+/E\nDJ7np4MiLhwENPvQergf6e3w8srHvADBUWfOcBp0fzBuDllFBAKG6niOx5Aw\n+Chkd8AdXCFCgBoh02hTkRjoAc6Yv3IRtsUSSdne4hkutHlNpvG369WfNf9z\nzRHHMzfVRSP3ySwU99oh9s1noqumM5hCbUI3cMAEYfXF8o2glUBLNeBhzPLK\n4LbqCuPKPZ5YYmamnRcSrjeCsNQwEC6U13CjQdxQKiKvOEcKornRopCa5t0s\n8MLcd2MPZQJuIFXndQhvky98M/nGRVdDXbNZd8vEiIRtzaERm+34Lxi3K8vQ\n+DulZeNzSas1ev4L/dHZQKe8f8YW40CW17mMA0z8vygXBpp6cU4SJXq2uyqS\nZ4UtrQfkxjJZkvr69W6GSAx0IhdyKCUmezcQT4jK5p3dVu1FBL5Trb9Bje51\nDz2JxZcVywslgpn+zP99qEqdbyKVS5ItpVkV7AAgvisj1aGb55cmUsaFMFkg\nosxP\r\n=fBXr\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCaro84wsl1LyyyEnRb4fJ07GiMyi5ttcuj6cW5oZavxgIgPDgShRL/AhnPNcVDYqwCPfdT3wBaI1O5/V0pRSUxCao="}]},"maintainers":[{"name":"binarymist","email":"devout@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mocksse_1.0.0_1535271510279_0.8064292568795048"},"_hasShrinkwrap":false},"1.0.1":{"name":"mocksse","version":"1.0.1","description":"Allows testing of EventSource / Server Sent Events","main":"src/mocksse.js","scripts":{"lint":"eslint .","deps":"npm-check","update:deps":"npm-check -u","test":"lab --assert code --coverage","test:debug":"node --inspect-brk ./node_modules/.bin/lab --assert code --timeout 0","pretest":"npm run lint"},"repository":{"type":"git","url":"git+https://gitlab.com/binarymist/mocksse.git"},"keywords":["Server Sent Events","SSE","mock","mocking","test","testing","EventSource"],"author":{"name":"BinaryMist","email":"services@binarymist.net"},"dependencies":{},"devDependencies":{"code":"^5.2.0","eslint":"^4.19.1","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.12.0","lab":"^15.5.0","npm-check":"^5.7.1","pre-commit":"^1.2.2"},"license":"MIT","bugs":{"url":"https://gitlab.com/binarymist/mocksse/issues"},"gitHead":"86342904fcf28a153948790086339d444baa414c","homepage":"https://gitlab.com/binarymist/mocksse#README","_id":"mocksse@1.0.1","_npmVersion":"5.7.1","_nodeVersion":"8.9.4","_npmUser":{"name":"binarymist","email":"devout@hotmail.com"},"dist":{"integrity":"sha512-Wi2QCDFGqyuooQYjkaue1GekFaH2msim+GGAu1zc6aQ6TOcRjbYJgCp+81P2tx8/YjuF3U0/DLnV1dc3EVafag==","shasum":"33152ff936b729700694880c9fe04ca73ca468a5","tarball":"https://registry.npmjs.org/mocksse/-/mocksse-1.0.1.tgz","fileCount":9,"unpackedSize":36896,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbgmVkCRA9TVsSAnZWagAABVIP/jl4PPClM+d+ZSPgAI90\nHQDyjZqbEr+f2cLxxlVh29RDfOUlm/+m4/eZzFmIbhheFAwn28XDBZW+dlwv\nxppf+3fE2LylPw8TZp6y9cjdalrKONgMC7Vfz94HVjmaINAW4Jeh3bJ2zUHI\n+6GesfChtjbHHx0Z//uNqPYaBQmu/iH7J5H/mVxrqWwpuCrj5Zj7qhjioSzl\nOImvTRyoguihm7WRWHTR+xjaqUpVw7njDlUQFL5f963OJ6k2sxXLsv6jSSMI\n1UV7h4xug7LTr8a/SLonGfUoJIB3c1xCTn8iLiOFWxpIwevDlJDqMUSm4/Gl\nDQt3Qxf486C7oARZq9j9Lp4DUxGWhE/XfNpQB/aGS9fpHpnNhu1FJBo42dvM\nmKxeEXSin6h5t5j18DQkhsH/tie2jcS9na7SbuIOVJf/LkrHYwNENVJMuyhH\nONgpd0FfDa+ZocWpZmDZ1f2J4ZmP5Jfi2TmRpfoPk1elZVX9S2DJAHOXYDJz\nDRX9AZgMOTiHgkLP3KS88DKiInSU92xOLGDiQF58OjydvI+11/0aAgBuaw8n\nZ5bHWDr7UB+IxOZ2rYHNoTw/mSSgZTRwBvclcRAG+vfY4ij0OGc819Rcxc+k\n8PYqVTcvRlrFplVCGzMvUjEgy5KjSQFOPNdTWQqRNR8tFAaeVSrXIkOptqti\niZa+\r\n=2iq9\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD1ZkKXnalMQpIsC6RDSPCCnvvT76OOkXfHI5ZHxUpH7wIgEk0opPhwOeG7CW5WoK1OrG305xUgz0ZwiXSP4FOmS+I="}]},"maintainers":[{"name":"binarymist","email":"devout@hotmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mocksse_1.0.1_1535272291941_0.09303311830246264"},"_hasShrinkwrap":false},"1.0.2":{"name":"mocksse","version":"1.0.2","description":"Allows testing of EventSource / Server Sent Events","main":"src/mocksse.js","scripts":{"lint":"eslint .","deps":"npm-check","update:deps":"npm-check -u","test":"lab --assert @hapi/code --coverage","test:debug":"node --inspect-brk ./node_modules/.bin/lab --assert @hapi/code --timeout 0","pretest":"npm run lint"},"repository":{"type":"git","url":"git+https://gitlab.com/binarymist/mocksse.git"},"keywords":["Server Sent Events","SSE","mock","mocking","test","testing","EventSource"],"author":{"name":"BinaryMist","email":"services@binarymist.net"},"dependencies":{},"devDependencies":{"@hapi/code":"^8.0.2","eslint":"^7.13.0","eslint-config-airbnb-base":"^14.2.1","eslint-plugin-import":"^2.22.1","@hapi/lab":"^24.1.0","npm-check":"^5.9.2","pre-commit":"^1.2.2"},"license":"MIT","bugs":{"url":"https://gitlab.com/binarymist/mocksse/issues"},"gitHead":"6494cde1c75f1282655408709324229a854e5cff","homepage":"https://gitlab.com/binarymist/mocksse#readme","_id":"mocksse@1.0.2","_nodeVersion":"14.15.0","_npmVersion":"6.14.8","dist":{"integrity":"sha512-QuBVLoEEikbSIL4DLfxvW05XvTJonsQnRCPjKXnHD67/Uiet57ssRbj7lFnsHFzGM5kJTn86WhjD5nKjt2DZKA==","shasum":"5c20148a7f997531f9e1c1dfb513b259a36fab57","tarball":"https://registry.npmjs.org/mocksse/-/mocksse-1.0.2.tgz","fileCount":9,"unpackedSize":37289,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfs3KKCRA9TVsSAnZWagAA7HEP/0j9nDFfKQocUTNGP5Sb\nKRR+5K5OukHPIsQ5iMwdY1SF9PeekJh1zAAcAgUiTe0U6+6WfQAjMwu7U54x\nxFcThTOS+tLnNH3JklPOyz/2mI8T5Y9h+dSxll/+QwOcSMN55ntr4b5dV93X\nRlDeOFnWUDr3Qk51Dj2ihI9stVYtVQrSpOgq52AAEYClNT4ln9MbZc1RkRsX\nxH2jugMkhsg13/Xu/v57nF/CiV3o1/QtSmzLIYGrl3du67qvJogo/vivQRvR\nVQkAI+S0Ppf1+VVGHpFikfKZ9QA7NVrVu3ey4/jOCtj8+VZq3NQzYxACILpc\npROEcahdFmuz0aF/0IZsc9N0mQOIGP/AM0mJuAP1OGcsS4DZAl53zWTZ/W9E\nLQdoFjRy1Z4NpDblohDLwAjY9Fm9mPiz53y2hexCISBaws7C5K/D+IixXZe9\neTxYpvR6+r63WgsKzCs/n4CZGNls1+YoU+qJe1biOCt/DnLk85sbC9h/a41Y\nSxbzrW34rSdKNERcKig19b89ozNVINRa/UL/h9JX8GSXAjczRf33oJMspZv6\nHiPSKByKRDjUAH4EWT5sTsANHQzztN1hgGg0MrOr/Rm2tHpF7lhstu/h/ad8\nVPPQA00ai42E8nnUmMtl+YnVJRw1NBI+0GOI1IMeHScOdRVYOyJPPzcz9g/j\nUwvN\r\n=1dyS\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGgxPlTHU2Qwlr99lv+adRNuKlMEbnW6qy2R3l2N4d6rAiEAhjW6thxgAFvOMJCOk9le0Z0FjcMWLgu4Iv6pouO8n0E="}]},"_npmUser":{"name":"binarymist","email":"devout@hotmail.com"},"directories":{},"maintainers":[{"name":"binarymist","email":"devout@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mocksse_1.0.2_1605595785915_0.14572339478637297"},"_hasShrinkwrap":false},"1.0.3":{"name":"mocksse","version":"1.0.3","description":"Allows testing of EventSource / Server Sent Events","main":"src/mocksse.js","scripts":{"lint":"eslint .","deps":"npm-check","update:deps":"npm-check -u","test":"lab --assert @hapi/code --coverage","test:debug":"node --inspect-brk ./node_modules/.bin/lab --assert @hapi/code --timeout 0","pretest":"npm run lint","prepare":"husky install"},"repository":{"type":"git","url":"git+https://gitlab.com/binarymist/mocksse.git"},"keywords":["Server Sent Events","SSE","mock","mocking","test","testing","EventSource"],"author":{"name":"BinaryMist","email":"services@binarymist.net"},"dependencies":{},"devDependencies":{"@hapi/code":"^8.0.3","eslint":"^7.27.0","eslint-config-airbnb-base":"^14.2.1","eslint-plugin-import":"^2.23.4","@hapi/lab":"^24.2.1","npm-check":"^5.9.2","husky":"^6.0.0"},"license":"MIT","bugs":{"url":"https://gitlab.com/binarymist/mocksse/issues"},"gitHead":"b2f4f7a01990bd565a5d41b0b55b348d3ec56f1c","homepage":"https://gitlab.com/binarymist/mocksse#readme","_id":"mocksse@1.0.3","_nodeVersion":"14.16.1","_npmVersion":"6.14.12","dist":{"integrity":"sha512-z3HFHTprGWyk0bwwu+1ES6FhZvjdX/u8qnrruaLxegLO+AVaEg/DIlvclTvhUS/QfGize0FgnTSsh1uvHH+bPQ==","shasum":"64cafed65b09d5c727d0b0b229849cd4f6bde958","tarball":"https://registry.npmjs.org/mocksse/-/mocksse-1.0.3.tgz","fileCount":4,"unpackedSize":21563,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgstorCRA9TVsSAnZWagAAOvUQAJkvwDAyhLPNhp/qTOTb\nHNVKz030B/bLfpb6HnWLYgCGPV5nQOJIlAvF9SFJRea0fQC3DrDPnLlez7c6\nJqRXxK8ge+UTDPENiKTejN7i+GP6eWixYeiiLxjnIT6wBDo145lEBnpNLKDn\nrXp4V6Nz3kXQWg4kxAbnRoQfvOqstanSAvKFS4lOkyUpY0NZCnyl2hPW8a/5\nCWsFtxpp+LeX38yuwL65F/1JQIFRkW+uHgaa3Flfk3lFkT3ymj9wqVIFZPxz\n56R7YXp3/xXXVYhX3TDtRtNEHtQ6AwivJvAqtiRgtYpE/Cy9bQ8qd9HN/Y8h\nf3S/i3XP1MaMVpYyeTVcXE5uZBXGJuaq6PJkyKRkx6fJHUItvOr04HXv/Bim\nAXM+BAGXOpsOzGceMdWSFBRI+q6bi7A612YxBh7t7XOvScfaQYm8xFe6CN8U\n4NZMjWOvxl4XTse/f3tYpyGEd6u8k4W+wh1CfslYIap0A7XpspicEDg1s2aC\n8BZrfYLU/s9vmXg3Zq9UuAYmV/Fs/EiJGKmjM6xXhSmENcoDbTf6daQYaYQF\nQmH4gmwVcaxT4BpKGcj+7T9p35vF5utkZ8PVRxSVuCNfcR+vRQXd4d+VgfB/\nZ2GtOlQAHiA5CBil3N1YqggVaNXmSXJN4ovXnmG+UfJ0YeFSe7phXufoGg6+\n1GTA\r\n=RzH5\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAt1zBub6kbmt9JKQyNuKzqe+XCQocVf2ObzcfoBWNBTAiEAkpVk8DRnUeHv/dDbftsHEWNhZGBmP75WrNsWqi2cQ8E="}]},"_npmUser":{"name":"binarymist","email":"services@binarymist.net"},"directories":{},"maintainers":[{"name":"binarymist","email":"services@binarymist.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mocksse_1.0.3_1622333995353_0.806107602024247"},"_hasShrinkwrap":false},"1.0.4":{"name":"mocksse","version":"1.0.4","description":"Allows testing of EventSource / Server Sent Events","main":"src/mocksse.js","scripts":{"lint":"eslint .","deps":"npm-check","update:deps":"npm-check -u","test":"lab --assert @hapi/code --coverage","test:debug":"node --inspect-brk ./node_modules/.bin/lab --assert @hapi/code --timeout 0","pretest":"npm run lint","prepare":"husky install"},"repository":{"type":"git","url":"git+https://github.com/binarymist/mocksse.git"},"keywords":["Server Sent Events","SSE","mock","mocking","test","testing","EventSource"],"author":{"name":"BinaryMist","email":"services@binarymist.net"},"dependencies":{},"devDependencies":{"@hapi/code":"^8.0.7","eslint":"^8.13.0","eslint-config-airbnb-base":"^15.0.0","eslint-plugin-import":"^2.26.0","@hapi/lab":"^24.6.0","npm-check":"^5.9.2","husky":"^7.0.4"},"license":"MIT","bugs":{"url":"https://github.com/binarymist/mocksse/issues"},"gitHead":"705730cfec7fe4c6b29e83bbf44cca612d9243f7","homepage":"https://github.com/binarymist/mocksse#readme","_id":"mocksse@1.0.4","_nodeVersion":"16.13.1","_npmVersion":"8.1.2","dist":{"integrity":"sha512-W5DR/wwmx/EZUgjN1g+pvlhvFFtRJ3CqGRKqsK/B1hTxrjMb/t3JCbk6aomJD4WomrnueqMaTAhcAkIZJYd73w==","shasum":"281385fd9759b8f6d78643d5116008e1b76e3368","tarball":"https://registry.npmjs.org/mocksse/-/mocksse-1.0.4.tgz","fileCount":4,"unpackedSize":21608,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFYHeBBDq4gH6mTL/KtLivj8/Bet5sBg4S6m8EZuISPkAiAckT+bjsNahueCzyUS6vGqejJC/SmOzJ5y2DrjwLvZlA=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiUhtHACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr++w//XKP/vfwI3fTdMdseJNtL78VXfouSmSgq2JgmuJZFdmAJSnJu\r\nzD5g5Sx/RPQYlMsjpg7vTwykhwdsidXac9lPbquo2D6LuidcPGtBLJWV4q6m\r\nbtu74r8nfpctCFzGduPoWD2vgfb5Xr34GB94g3PJnex6lD/mqdSg/zYGo2Pr\r\nLMw0aEUMFD6WI7cU+B1044HRuXYnefW7OtvNxm60SBsZGmWVvLCTiY9p2yfh\r\n0Z0uiHd1oiKPhGEmnE04EnfPNJ/V5xlck1HDw4p3n1BOKX8MQV2snnbyhFuu\r\nF9LjjM8ydOSzjBJNIOvQxcM0OF76VTtWVW6hChQ1jK5PhDlNKElgp8r70ObE\r\nk7sDmcZnifYz3UdxgD2zV44MQoYTpRgr/lkUGJh89/HwTsF89rJ9xvW7rui7\r\nJbypQvnDxpzTDd/gGaOeUpncSKFcWmKtWVlPv2pg75yKJPTVeNCcAd+2J0ZM\r\n9sTyxWvHNv74nu0JA6868S3MafjGw5TuVT15F2Lx1h7sL3ENGZ6QUHbYbITt\r\nNSt/NUeKQEKf3amqDUDCr/eH6Kozes/k7lQ4Qsh9bdLbzgNB1Gh8jyeDEiiJ\r\nOsJtjwYTUBCCd71WvGliowgOnE4i0G5rpVcVTzP0Pe2kX4Af9e/XRRW8Slsh\r\nkDqN0M1ryC3vsaGaf+XtP20gWuCIdFZeqa0=\r\n=4A65\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"binarymist","email":"services@binarymist.net"},"directories":{},"maintainers":[{"name":"binarymist","email":"services@binarymist.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mocksse_1.0.4_1649548102957_0.7634510187731935"},"_hasShrinkwrap":false}},"maintainers":[{"name":"binarymist","email":"services@binarymist.net"}],"description":"Allows testing of EventSource / Server Sent Events","homepage":"https://github.com/binarymist/mocksse#readme","keywords":["Server Sent Events","SSE","mock","mocking","test","testing","EventSource"],"repository":{"type":"git","url":"git+https://github.com/binarymist/mocksse.git"},"author":{"name":"BinaryMist","email":"services@binarymist.net"},"bugs":{"url":"https://github.com/binarymist/mocksse/issues"},"license":"MIT","readme":"\n# MockSSE\n\n[![pipeline status](https://gitlab.com/binarymist/mocksse/badges/master/pipeline.svg)](https://gitlab.com/binarymist/mocksse/commits/master) &nbsp; [![test coverage](https://gitlab.com/binarymist/mocksse/badges/master/coverage.svg)](https://gitlab.com/binarymist/mocksse/commits/master) &nbsp; [![license](https://img.shields.io/badge/license-MIT-green.svg)](https://gitlab.com/binarymist/mocksse/blob/master/LICENSE)\n\nThis project is a port/rewrite of [MockEvent](https://github.com/eloyz/mockevent) (which targets the browser). Instead, this project was designed for mocking EventSource (specifically the npm package [eventsource](https://github.com/EventSource/eventsource)) /Server Sent Events (SSE) where both your server side and client side are written for the NodeJS platform.\n\nMockSSE simulates [SSE](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events).\n\nUseful if you want to:\n\n* Build the client side without having the server side available to you\n* Or simply unit testing -> C/I, rather than integration tests\n\nThis project has no dependencies other than native modules.\n\n* [Installation](#install)\n* [Usage](#usage)\n* [Contribution](#contribution)\n* [Acknowledgements](#acknowledgements)\n* [License](#license)\n\n## Install\n\n`npm install mocksse --save-dev`\n\n## Usage\n\nAll examples include:\n\n* How to instantiate a [`MockEvent`](https://gitlab.com/binarymist/mocksse/blob/494675303c32cc8f5c87e20f8482e8c10bd76742/src/mocksse.js#L234) which streams the data\n* How to instantiate an [`EventSource`](https://gitlab.com/binarymist/mocksse/blob/494675303c32cc8f5c87e20f8482e8c10bd76742/src/mocksse.js#L137) which consumes the data\n* Adding at least one event listener\n\nAs well as the following examples:\n\n* The [tests](https://gitlab.com/binarymist/mocksse/blob/master/test/mocksse.js) demonstrate how to use the project along with the feature set\n* The project that uses `mocksse` for testing the client side of its server sent events (SSE) can be seen at the [purpleteam](https://gitlab.com/purpleteam-labs/purpleteam/tree/master) repository\n\n### Example 0\n\nGetting started with the least amount of work (based on test [`should handle an event to relative url`](https://gitlab.com/binarymist/mocksse/blob/494675303c32cc8f5c87e20f8482e8c10bd76742/test/mocksse.js#L19)).\n\n```javascript\nconst { MockEvent, EventSource } = require('mocksse');\n\n// Instantiate a MockEvent.\nnew MockEvent({\n  url: '/your-relative-or-absolute-url',\n  responses: [\n    { type: 'a message event', data: 'a short message' }\n  ]\n});\n\n// Instantiate an EventSource.\nconst evtSource = new EventSource('/your-relative-or-absolute-url');\n\n// Listen for a \"a message event\" event and handle appropriately.\nevtSource.addEventListener('a message event', (event) => {\n  // event.type === 'a message event'\n  // event.data === 'a short message'\n});\n\n```\n\n### Example 1\n\nMultiple event listeners (based on test [should handle an event with setInterval, and collection of full responses](https://gitlab.com/binarymist/mocksse/blob/494675303c32cc8f5c87e20f8482e8c10bd76742/test/mocksse.js#L81)).\n\n```javascript\nconst { MockEvent, EventSource } = require('mocksse');\n\n// Instantiate a MockEvent.\nnew MockEvent({\n  url: 'http://noPlaceLikeHome:2000/your-route',\n  setInterval: 10,\n  responses: [\n    { lastEventId: 'event Id One', type: 'progressEvent', data: { progress: 'Look mum, I am making great progress' } },\n    { lastEventId: 'event Id Two', type: 'pctCompleteEvent', data: { pctComplete: 11 } },\n    { lastEventId: 'event Id three', type: 'temperatureEvent', data: { temperature: 25 } }\n  ]\n});\n\n// Instantiate an EventSource.\nconst evtSource = new EventSource('http://noPlaceLikeHome:2000/your-route');\n\n// Listen for multiple events and handle appropriately.\nevtSource.onopen = (event) => { // Optionally subscribing to the open event\n  // You can see this event in mocksse.js.\n  // event === { message: 'The opening message.', anotherCustomeProp: { prop: 'whatever' } }  \n};\nevtSource.addEventListener('progressEvent', (event) => {\n  // event.type === 'progressEvent'\n  // event.data === { progress: 'Look mum, I am making great progress' }\n  // event.origin === 'http://noPlaceLikeHome:2000'\n  // event.lastEventId === 'event Id One'\n});\nevtSource.addEventListener('pctCompleteEvent', (event) => {\n  // event.type === 'pctCompleteEvent'\n  // event.data === { pctComplete: 11 }\n  // event.origin === 'http://noPlaceLikeHome:2000'\n  // event.lastEventId === 'event Id Two'\n});\nevtSource.addEventListener('temperatureEvent', (event) => {\n  // event.type === 'temperatureEvent'\n  // event.data === { temperature: 25 }\n  // event.origin === 'http://noPlaceLikeHome:2000'\n  // event.lastEventId === 'event Id three'\n});\n```\n\n* `url`: The relative or full URL for your Server Sent Event API.  This is the URL we will subscribe to via `EventSource`\n* `setInterval`: Miliseconds to wait before sending the next event/response\n* `responses`: A list of event/responses to send and the order in which to send them\n  * `lastEventId` can be set and read\n  * `type`: Server Sent Events can have a name that you directly subscribe to in case you want to handle that name differently. In the above example we require you to subscribe to 3 different names `progressEvent`, `pctCompleteEvent`, and `temperatureEvent`. A [working example](https://gitlab.com/purpleteam-labs/purpleteam/blob/94ed3203086173d5fd06920a25b785a57673279c/src/presenter/apiDecoratingAdapter.js#L101-L103) of this can be seen in the purpleteam project\n  * `data`: The data you want to send\n\n### Example 2\n\nDynamically make responses and then have them `stream`ed (based on test [response function should be called, which then sends event](https://gitlab.com/binarymist/mocksse/blob/9362050dfeae6620b85a3827c802374ae3b14dd6/test/mocksse.js#L190)).\n\n```javascript\nconst { MockEvent, EventSource } = require('mocksse');\n\n// Instantiate a MockEvent.\nnew MockEvent({\n  url: 'http://noPlaceLikeHome:2000/your-route',\n  setInterval: [100, 200],\n  response: (mockEvent, evtSource) => {\n    const data = [\n      { lastEventId: 'event Id One', type: 'yourEvent', data: { yourProp: 'Wish I was done!' } },\n      { lastEventId: 'event Id Two', type: 'yourEvent', data: { yourProp: 'Oh, wow, nearly done!' } }\n    ];\n    // In this case we have static data, but you can build that data\n    // however you choose and then stream it when you're ready.\n    mockEvent.stream(data);\n  }\n});\n\n// Instantiate an EventSource.\nconst evtSource = new EventSource('http://noPlaceLikeHome:2000/your-route');\n\n// Listen for a \"yourEvent\" event and handle appropriately.\nevtSource.addEventListener('yourEvent', (event) => {\n  // On first invocation: event === { origin: 'http://noPlaceLikeHome:2000, lastEventId: 'event Id One', type: 'yourEvent', data: { yourProp: 'Wish I was done!' } }\n  // On second invocation: event === { origin: 'http://noPlaceLikeHome:2000, lastEventId: 'event Id Two', type: 'yourEvent', data: { yourProp: 'Oh, wow, nearly done!' } }\n});\n\n```\n\nThis uses the `response` attribute instead of the plural `responses` method.  Here you can build build a list of responses to send and then stream them when you're ready.\n\nThe `stream` method respects the `setInterval` property you specified. Also notice that `setInterval` can be set to an `int`, `float`, or `array` representing a min/max range of milliseconds.\n\nTechnically you can use any method and then call `handler.stream`. The benefit of using the `response` hook is that you get the `mockEvent` and `evtSource` object in case you need those values for anything.  Example 3 shows how you can benefit from these objects.\n\n### Example 3\n\nDynamically make responses and then `stream` them yourself within your `response` function (based on test [response function should be called, which then streams events itself](https://gitlab.com/binarymist/mocksse/blob/58439a92aacde9767d4f07a44fa59b7d657d52b8/test/mocksse.js#L219)).\n\n```javascript\nconst { MockEvent, EventSource } = require('mocksse');\n\n// Instantiate a MockEvent.\nnew MockEvent({\n  url: 'http://noPlaceLikeHome:2000/your-route',\n  setInterval: [100, 200],\n  response: (mockEvent, evtSource) => {\n    const data = [\n      { lastEventId: 'event Id One', type: 'yourEvent', data: { yourProp: 'Wish I was done!' } },\n      { lastEventId: 'event Id Two', type: 'yourEvent', data: { yourProp: 'Oh, wow, nearly done!' } }\n    ];\n    // In this case we have static data, but you can build that data\n    // however you choose and then stream it when you're ready.\n    const intervalId = setInterval(() => {\n      const responseData = data.shift() || clearInterval(intervalId);\n      if (responseData) mockEvent.dispatchEvent(responseData);\n    }, mockEvent.setInterval);\n  }\n});\n\n// Instantiate an EventSource.\nconst evtSource = new EventSource('http://noPlaceLikeHome:2000/your-route');\n\n// Listen for a \"yourEvent\" event and handle appropriately.\nevtSource.addEventListener('yourEvent', (event) => {\n  // On first invocation: event === { origin: 'http://noPlaceLikeHome:2000, lastEventId: 'event Id One', type: 'yourEvent', data: { yourProp: 'Wish I was done!' } }\n  // On second invocation: event === { origin: 'http://noPlaceLikeHome:2000, lastEventId: 'event Id Two', type: 'yourEvent', data: { yourProp: 'Oh, wow, nearly done!' } }\n});\n```\n\nHere we write our own `stream` method that loops through data and sends. Still respecting the `setInterval` attribute and leveraging the internal `dispatchEvent` method of the `mockEvent`.  This is not recommended, it's just used as an example to show the amount of access you have to all attributes.  Using the `dispatchEvent` method directly overwrites the `stream` attribute and will not respect other queues that maybe set by you later.\n\n### Example 4\n\nClosing the EventSource then subscribing to an event will invoke the error handler if you have subscribed to `onerror` (based on test [`closing the EventSource then subscribing to an event should invoke the error handler`](https://gitlab.com/binarymist/mocksse/blob/494675303c32cc8f5c87e20f8482e8c10bd76742/test/mocksse.js#L265)).\n\n```javascript\nconst { MockEvent, EventSource } = require('mocksse');\n\n// Instantiate a MockEvent.\nconst mockEvent = new MockEvent({\n  url: 'http://noPlaceLikeHome:2000/your-route',\n  verbose: true, // Feel free to turn verbosity on.\n  responses: [\n    { type: 'a message event', data: 'a short message' }\n  ]\n});\n\n// Instantiate an EventSource.\nconst evtSource = new EventSource('http://noPlaceLikeHome:2000/your-route');\n\nevtSource.close();\n\n// Listen for a \"a message event\" event and handle appropriately.\nevtSource.addEventListener('a message event', (event) => {\n  // The event handler will not be invoked on a closed EventSource.\n});\n\nevtSource.onerror = (error) => {\n  // Expect to see the following message\n  // error.message === '`EventSource` instance closed while sending.'\n};\n```\n\n## Contribution\n\nPlease open an [issue](https://gitlab.com/binarymist/mocksse/issues) to discus the proposed change before submitting a [merge request](https://gitlab.com/binarymist/mocksse/merge_requests).\n\n\n## Acknowledgements\n\nThis project is a port/rewrite of [MockEvent](https://github.com/eloyz/mockevent), which targets the browser.  \nInspiration was also taken from [eventsourcemock](https://github.com/gcedo/eventsourcemock), which is also browser focussed and very minimal.\n\n## License\n\nCopyright [Kim Carter](https://gitlab.com/binarymist) and other contributors, Licensed under [MIT](./LICENSE).\n","readmeFilename":"README.md"}