{"_id":"@edenware/conn-racing","_rev":"3-925fdaeefa6beddeab44d1c13049eae8","name":"@edenware/conn-racing","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@edenware/conn-racing","version":"1.0.0","keywords":["connection","racing","url","parallel","fetch","head","latency","fastest","retry","timeout"],"author":{"name":"Edenware"},"license":"MIT","_id":"@edenware/conn-racing@1.0.0","maintainers":[{"name":"efoxbr","email":"efox.web@gmail.com"}],"homepage":"https://edenware.app","bugs":{"url":"https://github.com/EdenwareApps/conn-racing/issues"},"dist":{"shasum":"22ea6d37184f45a2946216661803a31e1a97062f","tarball":"https://registry.npmjs.org/@edenware/conn-racing/-/conn-racing-1.0.0.tgz","fileCount":4,"integrity":"sha512-/aeLwLBzNk6gNFyo6Cft1NMG381hBHh2FAb+Ey8GEqBB6I4YdI8okQHTNUVWqvdxHgZMWI7fOTAiOwCgHA3ozA==","signatures":[{"sig":"MEYCIQC7inH8/aO36zILFEL8cr2605cNQiVPPLuT2lrvN750WwIhAPRXrIEMrOOGVViNLIGSKYtVW9iVUObL3fISKrFF4/RK","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10764},"main":"./conn-racing.js","type":"module","engines":{"node":">=18"},"exports":"./conn-racing.js","gitHead":"8619f76ca9f60045879aface9b7a243e924cb47f","scripts":{"test":"node --test test/*.test.js"},"_npmUser":{"name":"efoxbr","email":"efox.web@gmail.com"},"repository":{"url":"git+https://github.com/EdenwareApps/conn-racing.git","type":"git"},"_npmVersion":"11.4.2","description":"High-performance connection testing and racing: test multiple URLs in parallel to find the fastest and most reliable connection.","directories":{},"_nodeVersion":"22.11.0","dependencies":{"needle":"^3.3.0","p-limit":"^6.1.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/conn-racing_1.0.0_1770066095635_0.5016076764429327","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@edenware/conn-racing","version":"1.0.1","keywords":["connection","racing","url","parallel","fetch","head","latency","fastest","retry","timeout"],"author":{"name":"Edenware"},"license":"MIT","_id":"@edenware/conn-racing@1.0.1","maintainers":[{"name":"efoxbr","email":"efox.web@gmail.com"}],"homepage":"https://edenware.app","bugs":{"url":"https://github.com/EdenwareApps/conn-racing/issues"},"dist":{"shasum":"e898f79b1d7c7a669bfd162e1eae2c1148bf94a2","tarball":"https://registry.npmjs.org/@edenware/conn-racing/-/conn-racing-1.0.1.tgz","fileCount":5,"integrity":"sha512-bqfpBZuEQmD/zmBX3LfTQEq7wPLNaLFRizTTV/VMIw25kpd8p3meeyhjsKRy1CSpnhFklvriQXMkiQ8U8aAI9w==","signatures":[{"sig":"MEQCIHQw0aPuspDAYwOehSkK4NIoUVzasyb1WoxiXQKEEHp6AiB6bUNm7PNpQJ3WdSNMzVItujyJFlW4gi+6lAdSBLcz1g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":23258},"main":"./conn-racing.cjs","type":"module","module":"./conn-racing.js","engines":{"node":">=18"},"exports":{"import":"./conn-racing.js","require":"./conn-racing.cjs"},"gitHead":"c4c58e1c980a7e642f7051db127bd83ea4829f34","scripts":{"test":"node --test test/*.test.js test/*.test.cjs","build":"npx esbuild conn-racing.js --bundle --format=cjs --platform=node --external:needle --outfile=conn-racing.cjs","postbuild":"node scripts/postbuild.cjs"},"_npmUser":{"name":"efoxbr","email":"efox.web@gmail.com"},"repository":{"url":"git+https://github.com/EdenwareApps/conn-racing.git","type":"git"},"_npmVersion":"11.4.2","description":"High-performance connection testing and racing: test multiple URLs in parallel to find the fastest and most reliable connection.","directories":{},"_nodeVersion":"22.11.0","dependencies":{"needle":"^3.3.0","p-limit":"^6.1.0"},"_hasShrinkwrap":false,"devDependencies":{"esbuild":"^0.27.0"},"_npmOperationalInternal":{"tmp":"tmp/conn-racing_1.0.1_1770083600632_0.3427946045812349","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@edenware/conn-racing","version":"1.0.2","description":"High-performance connection testing and racing: test multiple URLs in parallel to find the fastest and most reliable connection.","type":"module","exports":{"import":"./conn-racing.js","require":"./conn-racing.cjs"},"main":"./conn-racing.cjs","module":"./conn-racing.js","scripts":{"build":"npx esbuild conn-racing.js --bundle --format=cjs --platform=node --outfile=conn-racing.cjs","postbuild":"node scripts/postbuild.cjs","test":"node --test test/*.test.js test/*.test.cjs"},"keywords":["connection","racing","url","parallel","fetch","head","latency","fastest","retry","timeout"],"author":{"name":"Edenware"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/EdenwareApps/conn-racing.git"},"bugs":{"url":"https://github.com/EdenwareApps/conn-racing/issues"},"homepage":"https://edenware.app","devDependencies":{"esbuild":"^0.27.0"},"dependencies":{"p-limit":"^6.1.0"},"engines":{"node":">=18"},"_id":"@edenware/conn-racing@1.0.2","gitHead":"621f5d9ca4c4bab7cd494fa793bc7920fd30ec19","_nodeVersion":"22.11.0","_npmVersion":"11.4.2","dist":{"integrity":"sha512-1DNRvzTbcwL72qM6dQGG4PTjv9BPYFPcV5LBDF19wpJwiBAFNo3hswtQJf4l5GAs8ieBb7wDKHPe/p9h0gE74A==","shasum":"fbbecc96224bce86c792ded5a4a2a91b1ceb8a88","tarball":"https://registry.npmjs.org/@edenware/conn-racing/-/conn-racing-1.0.2.tgz","fileCount":5,"unpackedSize":26080,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCg//tXnwiTWTYUCtnCttLQhTEAbjM6JbSyhU/VE4wd+AIgAQXWA9oRPNTMCKSzwdTlut66ol2bHud+70I5+6Mxtzs="}]},"_npmUser":{"name":"efoxbr","email":"efox.web@gmail.com"},"directories":{},"maintainers":[{"name":"efoxbr","email":"efox.web@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/conn-racing_1.0.2_1770684460251_0.7009097486399614"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-02T21:01:35.516Z","modified":"2026-02-10T00:47:40.548Z","1.0.0":"2026-02-02T21:01:35.769Z","1.0.1":"2026-02-03T01:53:20.809Z","1.0.2":"2026-02-10T00:47:40.409Z"},"bugs":{"url":"https://github.com/EdenwareApps/conn-racing/issues"},"author":{"name":"Edenware"},"license":"MIT","homepage":"https://edenware.app","keywords":["connection","racing","url","parallel","fetch","head","latency","fastest","retry","timeout"],"repository":{"type":"git","url":"git+https://github.com/EdenwareApps/conn-racing.git"},"description":"High-performance connection testing and racing: test multiple URLs in parallel to find the fastest and most reliable connection.","maintainers":[{"name":"efoxbr","email":"efox.web@gmail.com"}],"readme":"# conn-racing\n\nHigh-performance connection testing and racing: test multiple URLs in parallel to find the fastest and most reliable connection.\n\n**[Edenware](https://edenware.app)** · **GitHub:** [EdenwareApps/conn-racing](https://github.com/EdenwareApps/conn-racing) · **npm:** [@edenware/conn-racing](https://www.npmjs.com/package/@edenware/conn-racing)\n\n## Install\n\n```bash\nnpm install @edenware/conn-racing\n```\n\n## Features\n\n- **Parallel testing** – Multiple URLs tested concurrently (HEAD requests)\n- **Connection racing** – Results ordered by response time (fastest first)\n- **Automatic retry** – Configurable retries per URL\n- **Performance metrics** – Response times and status per URL\n- **Streaming results** – Consume results as they arrive via `next()` or events\n- **Cancellation** – Abort in-flight requests with `destroy()`\n\n## Usage\n\n### ESM\n\n```javascript\nimport ConnRacing from '@edenware/conn-racing';\n\nconst racing = new ConnRacing(\n  [\n    'https://server1.com/stream',\n    'https://server2.com/stream',\n    'https://server3.com/stream',\n  ],\n  { retries: 3, timeout: 5000 }\n);\n\n// Consume results (fastest first)\nlet result;\nwhile ((result = await racing.next()) !== false) {\n  console.log(result.url, result.time, result.valid, result.status);\n}\n\n// Or wait for all to finish and use events\nracing.on('end', () => {\n  console.log('Racing finished');\n});\n```\n\n### CommonJS\n\n```javascript\nconst ConnRacing = require('@edenware/conn-racing');\n\nconst racing = new ConnRacing(\n  ['https://server1.com/stream', 'https://server2.com/stream'],\n  { retries: 3, timeout: 5000 }\n);\n\nlet result;\nwhile ((result = await racing.next()) !== false) {\n  console.log(result.url, result.time, result.valid, result.status);\n}\n```\n\nThe package supports both ESM and CommonJS via conditional exports.\n\n### Options\n\n| Option             | Default | Description                          |\n| ------------------ | ------- | ------------------------------------ |\n| `retries`          | `3`     | Number of attempts per URL           |\n| `timeout`          | `5000`  | Timeout per attempt (ms)             |\n| `triggerInterval`  | `0`     | Delay before each URL (ms)           |\n\n### Result shape\n\n- `url` – Requested URL  \n- `time` – Response time in seconds  \n- `valid` – `true` if status 2xx  \n- `status` – HTTP status code  \n- `headers` – Response headers (when valid)  \n- `error` – Error message (when invalid)\n\n## Testing\n\n```bash\nnpm test\n```\n\nUses Node.js built-in test runner (`node --test`). Tests use a local HTTP server to simulate fast/slow/failing URLs and cover: empty URLs, single/multiple URLs, `next()` API, `end` event, `destroy()`, options (timeout, retries), invalid URLs, and result shape.\n\n## License\n\nMIT · [Edenware](https://edenware.app)\n","readmeFilename":"README.md"}