{"_id":"@alshdavid/chi","_rev":"7-8ca676ee4c96481670425079ed69e09e","name":"@alshdavid/chi","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@alshdavid/chi","version":"0.1.0","license":"MIT","type":"module","exports":{".":{"import":"./dist/module/index.js","require":"./dist/require/index.js","source":"./src/index.ts","types":"./dist/types/index.d.ts","default":"./dist/require/index.js"},"./*":{"import":"./dist/module/*","require":"./dist/require/*","source":"./src/*","types":"./dist/types/*","default":"./dist/require/*"}},"devDependencies":{"@types/node":"^20.11.4","typescript":"^5.3.3"},"description":"Lightweight Node.js http-library for use with the Node standard library","_id":"@alshdavid/chi@0.1.0","_integrity":"sha512-RXRCyKKgzN/YqKvbNSSytDd0pGfjiMt0yglyyHY32wZUPnVzOYLwYH6WN3oOw9gQrGRDi6q37sKak6GG0qmDBg==","_resolved":"/tmp/439941e6ea3fd153f277d304c6370fa6/alshdavid-chi-0.1.0.tgz","_from":"file:alshdavid-chi-0.1.0.tgz","_nodeVersion":"18.19.0","_npmVersion":"10.3.0","dist":{"integrity":"sha512-RXRCyKKgzN/YqKvbNSSytDd0pGfjiMt0yglyyHY32wZUPnVzOYLwYH6WN3oOw9gQrGRDi6q37sKak6GG0qmDBg==","shasum":"a35c2b24cfc0fc653e4db44f0af4e9f6a6bb697f","tarball":"https://registry.npmjs.org/@alshdavid/chi/-/chi-0.1.0.tgz","fileCount":13,"unpackedSize":10079,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHzJZiCak48uTDEuU0MtQE7gtYquEo2NxdTQPFHdAhyPAiEA6TKj7/e5VzjP9aWwEa1CJPp3u/Xl1NbvBC3F1WlBVdY="}]},"_npmUser":{"name":"alshdavid","email":"alshdavid@gmail.com"},"directories":{},"maintainers":[{"name":"alshdavid","email":"alshdavid@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chi_0.1.0_1705470661267_0.7971147069227222"},"_hasShrinkwrap":false},"0.1.1":{"name":"@alshdavid/chi","version":"0.1.1","license":"MIT","type":"module","exports":{".":{"import":"./dist/module/index.js","require":"./dist/require/index.js","source":"./src/index.ts","types":"./dist/types/index.d.ts","default":"./dist/require/index.js"},"./*":{"import":"./dist/module/*","require":"./dist/require/*","source":"./src/*","types":"./dist/types/*","default":"./dist/require/*"}},"devDependencies":{"@types/node":"^20.11.4","typescript":"^5.3.3"},"description":"Lightweight Node.js http-library for use with the Node standard library","_id":"@alshdavid/chi@0.1.1","_integrity":"sha512-w8pBFha7LBcwzNhh2wQPjZkhJLZPhSc6Ni600Zr4HRvHpcLUmKDCsTu0s3g+vPkLpYTibvnZyOWjcVhVGYrZjg==","_resolved":"/tmp/687dc005e5b501d5cc903a74a8f11123/alshdavid-chi-0.1.1.tgz","_from":"file:alshdavid-chi-0.1.1.tgz","_nodeVersion":"18.19.0","_npmVersion":"10.3.0","dist":{"integrity":"sha512-w8pBFha7LBcwzNhh2wQPjZkhJLZPhSc6Ni600Zr4HRvHpcLUmKDCsTu0s3g+vPkLpYTibvnZyOWjcVhVGYrZjg==","shasum":"d4c350d82ecd7fdd9f02de9bf154ffaff0fe3cca","tarball":"https://registry.npmjs.org/@alshdavid/chi/-/chi-0.1.1.tgz","fileCount":13,"unpackedSize":10151,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDEZmF4DGmUNQ3IoAbI2UeXvPbIJiQ+Huc1ze2pgV7t8AIhAITcCKHM8VhxiywOugNMthtlk7y1uIvDkJxt7zRcEBUr"}]},"_npmUser":{"name":"alshdavid","email":"alshdavid@gmail.com"},"directories":{},"maintainers":[{"name":"alshdavid","email":"alshdavid@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chi_0.1.1_1705471170479_0.3236499460888791"},"_hasShrinkwrap":false},"0.1.2":{"name":"@alshdavid/chi","version":"0.1.2","license":"MIT","type":"module","exports":{".":{"import":"./dist/module/index.js","require":"./dist/require/index.js","source":"./src/index.ts","types":"./dist/types/index.d.ts","default":"./dist/require/index.js"},"./*":{"import":"./dist/module/*","require":"./dist/require/*","source":"./src/*","types":"./dist/types/*","default":"./dist/require/*"}},"devDependencies":{"@types/node":"^20.11.4","typescript":"^5.3.3"},"description":"Lightweight Node.js http-library for use with the Node standard library","_id":"@alshdavid/chi@0.1.2","_integrity":"sha512-xX/JC/h0veFg20WfOClUVT/0FO2RIOIWkqO7RmCxsNsLdoEXRlNBtcdg/jZp914nxAYbI89aYWlwvQZPcW9E1A==","_resolved":"/tmp/036ca749e6d9a4b4c43ec61bd445be0c/alshdavid-chi-0.1.2.tgz","_from":"file:alshdavid-chi-0.1.2.tgz","_nodeVersion":"18.19.0","_npmVersion":"10.3.0","dist":{"integrity":"sha512-xX/JC/h0veFg20WfOClUVT/0FO2RIOIWkqO7RmCxsNsLdoEXRlNBtcdg/jZp914nxAYbI89aYWlwvQZPcW9E1A==","shasum":"d6dec8e79297424044be63564b4ccba8719d4f99","tarball":"https://registry.npmjs.org/@alshdavid/chi/-/chi-0.1.2.tgz","fileCount":29,"unpackedSize":24829,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEYW1v+L1Utt0CnADVQcdg91ev9O1rklLqbUROYBEdDyAiEApj0KXHNQrbEpGvCcfglXc+GOHoz4Of8IfDDOCV4bL7s="}]},"_npmUser":{"name":"alshdavid","email":"alshdavid@gmail.com"},"directories":{},"maintainers":[{"name":"alshdavid","email":"alshdavid@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chi_0.1.2_1705471298778_0.485925005860554"},"_hasShrinkwrap":false},"0.1.3":{"name":"@alshdavid/chi","version":"0.1.3","license":"MIT","type":"commonjs","main":"./dist/require/index.js","types":"./dist/types/index.d.ts","exports":{".":{"import":"./dist/module/index.js","require":"./dist/require/index.js","source":"./src/index.ts","types":"./dist/types/index.d.ts","default":"./dist/require/index.js"},"./*":{"import":"./dist/module/*","require":"./dist/require/*","source":"./src/*","types":"./dist/types/*","default":"./dist/require/*"}},"devDependencies":{"@types/node":"^20.11.4","typescript":"^5.3.3"},"description":"Lightweight Node.js http-library for use with the Node standard library","_id":"@alshdavid/chi@0.1.3","_integrity":"sha512-uAdWkOGjykwwlQoeOl73Dupo76semxb5Yz6zwkBhnKmp08c/VZ7sNsgwDyn2KjHQ9t6O82DT95Q0K/UlzgcDPg==","_resolved":"/tmp/a86e8e646d3e1c5ce054c03cf6f2e725/alshdavid-chi-0.1.3.tgz","_from":"file:alshdavid-chi-0.1.3.tgz","_nodeVersion":"18.19.0","_npmVersion":"10.3.0","dist":{"integrity":"sha512-uAdWkOGjykwwlQoeOl73Dupo76semxb5Yz6zwkBhnKmp08c/VZ7sNsgwDyn2KjHQ9t6O82DT95Q0K/UlzgcDPg==","shasum":"4aff54af6517ae86391c5b5f3d6f99efe496cb31","tarball":"https://registry.npmjs.org/@alshdavid/chi/-/chi-0.1.3.tgz","fileCount":31,"unpackedSize":28525,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD2fzx4/ZhDFd826e0vZPSKU+TO+O1+MXPchkBHJ+KaagIgbDDytC4lozc3yumRJ9ppTc+sGlG00fpk+6Gt1NXh9BM="}]},"_npmUser":{"name":"alshdavid","email":"alshdavid@gmail.com"},"directories":{},"maintainers":[{"name":"alshdavid","email":"alshdavid@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chi_0.1.3_1705471751409_0.3834206419659594"},"_hasShrinkwrap":false},"0.1.4":{"name":"@alshdavid/chi","version":"0.1.4","license":"MIT","type":"commonjs","main":"./dist/require/index.js","types":"./dist/types/index.d.ts","exports":{".":{"import":"./dist/module/index.js","require":"./dist/require/index.js","source":"./src/index.ts","types":"./dist/types/index.d.ts","default":"./dist/require/index.js"},"./*":{"import":"./dist/module/*","require":"./dist/require/*","source":"./src/*","types":"./dist/types/*","default":"./dist/require/*"}},"devDependencies":{"@types/node":"^20.11.4","typescript":"^5.3.3"},"description":"Lightweight Node.js http-library for use with the Node standard library","_id":"@alshdavid/chi@0.1.4","_integrity":"sha512-jn/pWLhFC9Ng62mJO3bnMW6MZtxdphh2HmipgXbG8aUEqwA+2mqKTT/h5J91dFj/W5RMO83jEPbzvGbxoLyrRQ==","_resolved":"/tmp/ef1ad44e94f1ce63778a8260a1e8d02e/alshdavid-chi-0.1.4.tgz","_from":"file:alshdavid-chi-0.1.4.tgz","_nodeVersion":"18.19.0","_npmVersion":"10.3.0","dist":{"integrity":"sha512-jn/pWLhFC9Ng62mJO3bnMW6MZtxdphh2HmipgXbG8aUEqwA+2mqKTT/h5J91dFj/W5RMO83jEPbzvGbxoLyrRQ==","shasum":"81b13e27e3392909cbbf9e7296c6455c9cda6603","tarball":"https://registry.npmjs.org/@alshdavid/chi/-/chi-0.1.4.tgz","fileCount":31,"unpackedSize":27608,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEyUXmK9u3T+tMJgLbZ3dTIbSaIxpGgjj9oWLb99QXlrAiB1Qlmnp6xVDiyWdznPUmRQCUhW0v2BZWGqpPerf4Ioyg=="}]},"_npmUser":{"name":"alshdavid","email":"alshdavid@gmail.com"},"directories":{},"maintainers":[{"name":"alshdavid","email":"alshdavid@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chi_0.1.4_1705472853749_0.26466463703027143"},"_hasShrinkwrap":false},"0.1.5":{"name":"@alshdavid/chi","version":"0.1.5","license":"MIT","type":"commonjs","main":"./dist/require/index.js","types":"./dist/types/index.d.ts","exports":{".":{"import":"./dist/module/index.js","require":"./dist/require/index.js","source":"./src/index.ts","types":"./dist/types/index.d.ts","default":"./dist/require/index.js"},"./*":{"import":"./dist/module/*","require":"./dist/require/*","source":"./src/*","types":"./dist/types/*","default":"./dist/require/*"}},"devDependencies":{"@types/node":"^20.11.4","typescript":"^5.3.3"},"description":"Lightweight Node.js http-library for use with the Node standard library","_id":"@alshdavid/chi@0.1.5","_integrity":"sha512-CicJItzF854X0scDx2gaVQATgX2E86oXdzNjO2T4GoCCB6TXXb+x4v3FCLQrSr9PaW7NBT+616bIRpC/uUpK6w==","_resolved":"/tmp/df5e865cd38dd1a58cef52ae8ea4c472/alshdavid-chi-0.1.5.tgz","_from":"file:alshdavid-chi-0.1.5.tgz","_nodeVersion":"18.19.0","_npmVersion":"10.3.0","dist":{"integrity":"sha512-CicJItzF854X0scDx2gaVQATgX2E86oXdzNjO2T4GoCCB6TXXb+x4v3FCLQrSr9PaW7NBT+616bIRpC/uUpK6w==","shasum":"c207b7e96a38ac473084c78e400be8b156714f86","tarball":"https://registry.npmjs.org/@alshdavid/chi/-/chi-0.1.5.tgz","fileCount":31,"unpackedSize":24211,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICWCepXA6HKVT2GF2VlrFgeF9XggkOAA7y6ojWV2o08AAiAlVbBXBBlvP+UYeW9j6SKaGlEsT5UyWp5vwuBHDmfOCA=="}]},"_npmUser":{"name":"alshdavid","email":"alshdavid@gmail.com"},"directories":{},"maintainers":[{"name":"alshdavid","email":"alshdavid@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chi_0.1.5_1705473385123_0.4402782503765852"},"_hasShrinkwrap":false},"0.1.7":{"name":"@alshdavid/chi","version":"0.1.7","license":"MIT","type":"commonjs","main":"./dist/require/index.js","types":"./dist/types/index.d.ts","exports":{".":{"import":"./dist/module/index.js","require":"./dist/require/index.js","source":"./src/index.ts","types":"./dist/types/index.d.ts","default":"./dist/require/index.js"},"./*":{"import":"./dist/module/*","require":"./dist/require/*","source":"./src/*","types":"./dist/types/*","default":"./dist/require/*"}},"devDependencies":{"@types/node":"^20.11.4","typescript":"^5.3.3"},"description":"Lightweight Node.js http-library for use with the Node standard library","_id":"@alshdavid/chi@0.1.7","_integrity":"sha512-3IK5mfBSPr18dVZ3iCgjhEr5K7YxnBqNw0gMiufx32TIjQB7BGI0HDX8uQhUQ1Ou+7PIhNodjh8yAEpwbvYjkw==","_resolved":"/tmp/a8c1ac5aee776cf4ec0582e68cc12f85/alshdavid-chi-0.1.7.tgz","_from":"file:alshdavid-chi-0.1.7.tgz","_nodeVersion":"18.19.0","_npmVersion":"10.3.0","dist":{"integrity":"sha512-3IK5mfBSPr18dVZ3iCgjhEr5K7YxnBqNw0gMiufx32TIjQB7BGI0HDX8uQhUQ1Ou+7PIhNodjh8yAEpwbvYjkw==","shasum":"45519987a4579383c0c8cd085be7254cd4ac5128","tarball":"https://registry.npmjs.org/@alshdavid/chi/-/chi-0.1.7.tgz","fileCount":31,"unpackedSize":33489,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDFOv3PYL7NaX4NGB+FbKcIf5+9K0mIsM0ApiW71gZydAIhAO9XW8/19sizN3WwUyCbAusJdtOjkWodMjeR7pU+zzMH"}]},"_npmUser":{"name":"alshdavid","email":"alshdavid@gmail.com"},"directories":{},"maintainers":[{"name":"alshdavid","email":"alshdavid@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chi_0.1.7_1705478559705_0.380197166417366"},"_hasShrinkwrap":false},"0.2.0":{"name":"@alshdavid/chi","version":"0.2.0","license":"MIT","type":"commonjs","main":"./dist/require/index.js","types":"./dist/types/index.d.ts","exports":{".":{"import":"./dist/module/index.js","require":"./dist/require/index.js","source":"./src/index.ts","types":"./dist/types/index.d.ts","default":"./dist/require/index.js"},"./*":{"import":"./dist/module/*","require":"./dist/require/*","source":"./src/*","types":"./dist/types/*","default":"./dist/require/*"}},"devDependencies":{"@types/node":"^20.11.4","typescript":"^5.3.3"},"description":"Lightweight utilities for use with the Node standard http library","_id":"@alshdavid/chi@0.2.0","_integrity":"sha512-P3M7Q7RrkV6jV56iJGZBfyFjdqFZ3nXfkQJTI6fwEBQxAukJpE/C66ImCwcffKykQk+0chl2ah4BYZyYOX9w4w==","_resolved":"/tmp/e515adc6f41ee5399b1597f811435223/alshdavid-chi-0.2.0.tgz","_from":"file:alshdavid-chi-0.2.0.tgz","_nodeVersion":"18.19.0","_npmVersion":"10.3.0","dist":{"integrity":"sha512-P3M7Q7RrkV6jV56iJGZBfyFjdqFZ3nXfkQJTI6fwEBQxAukJpE/C66ImCwcffKykQk+0chl2ah4BYZyYOX9w4w==","shasum":"c76b8c23eca711026fb429c7e4917dad9b7fc0d8","tarball":"https://registry.npmjs.org/@alshdavid/chi/-/chi-0.2.0.tgz","fileCount":43,"unpackedSize":45557,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCzN4bKEVVnNLAuqzlVpXybOdWTuLNvAbQnsXO7jYLyhAIgMfVDiqHxBjiYwWpW3zABZI5HFQAVarn3s23lm8uV6zU="}]},"_npmUser":{"name":"alshdavid","email":"alshdavid@gmail.com"},"directories":{},"maintainers":[{"name":"alshdavid","email":"alshdavid@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chi_0.2.0_1705480217932_0.8374155623228783"},"_hasShrinkwrap":false}},"time":{"created":"2024-01-17T05:51:01.112Z","0.1.0":"2024-01-17T05:51:01.444Z","modified":"2024-01-17T08:30:18.258Z","0.1.1":"2024-01-17T05:59:30.620Z","0.1.2":"2024-01-17T06:01:38.943Z","0.1.3":"2024-01-17T06:09:11.580Z","0.1.4":"2024-01-17T06:27:33.916Z","0.1.5":"2024-01-17T06:36:25.282Z","0.1.7":"2024-01-17T08:02:39.904Z","0.2.0":"2024-01-17T08:30:18.081Z"},"maintainers":[{"name":"alshdavid","email":"alshdavid@gmail.com"}],"description":"Lightweight utilities for use with the Node standard http library","license":"MIT","readme":"# chi\n\nLightweight utilities for use with the Node standard http library\n\n## ServerEventSource\n\nBidirectional communication using server sent events\n\nServer\n```javascript\nimport * as http from 'node:http'\nimport { ServerSentEvents } from '@alshdavid/chi'\n\nconst hostname = '0.0.0.0';\nconst port = 3000;\n\nconst sse = new ServerSentEvents()\n\n// Run when a new client connects\nsse.on_connect(({ id }) => {\n  console.log('Connected', id)\n\n  // Broadcast to all connected clients\n  sse.send_all({ message: 'New client joined!', id })\n\n  // When a specific client sends message\n  sse.on_message(id, (msg) => {\n    console.log('from client', id, msg)\n  })\n\n  // Send a message to a specific client\n  setTimeout(async () => {\n    while (true) {\n      sse.send(id, { message: 'Hello!' })\n      await new Promise(res => setTimeout(res, 1000))\n    }\n  })\n})\n\n// Listen for a message from all clients\nsse.on_message_all((id, msg) => {\n  console.log('from client (all)', id, msg)\n})\n\n// Run when a new client disconnects\nsse.on_disconnect(({ id }) => {\n  console.log('Disconnected', id)\n})\n\n// Set up a standard HTTP server\nconst server = http.createServer(async (req, res) => {\n  // Add route for server-to-client\n  if (req.url === '/sse' && req.method === 'GET') {\n    await sse.http_handler_on_connection(req, res)\n    return\n  }\n\n  // Add route for client-to-server\n  if (req.url === '/sse' && req.method === 'POST') {\n    await sse.http_handler_on_message(req, res)\n    return\n  }\n\n  res.statusCode = 404\n  res.end()\n})\n\nserver.listen(port, hostname, () => {\n  console.log(`Server running on http://${hostname}:${port}/`);\n});\n```\n\nClient\n```javascript\nimport { SSEClient } from '@alshdavid/chi'\n\nconst sse = new SSEClient({ \n  endpoint: '/sse',\n})\n\nsse.on(msg => console.log(msg))\n\nsse.send({ message: 'hello world' })\n```","readmeFilename":"README.md"}