{"_id":"@balena/happy-eyeballs","_rev":"51-aa832d7a985988e6818217435d18a7ff","name":"@balena/happy-eyeballs","dist-tags":{"latest":"0.0.6"},"versions":{"0.0.2-publish-branch-b39fcca26175a6cae085e11c0ec8f4e1a06b7ac8":{"name":"@balena/happy-eyeballs","version":"0.0.2-publish-branch-b39fcca26175a6cae085e11c0ec8f4e1a06b7ac8","keywords":[],"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","_id":"@balena/happy-eyeballs@0.0.2-publish-branch-b39fcca26175a6cae085e11c0ec8f4e1a06b7ac8","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"}],"contributors":[{"name":"Miguel Casquiera","email":"miguel@balena.io"}],"homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"dist":{"shasum":"fea8d585863d822d1ac382cf91e54870465c3a06","tarball":"https://registry.npmjs.org/@balena/happy-eyeballs/-/happy-eyeballs-0.0.2-publish-branch-b39fcca26175a6cae085e11c0ec8f4e1a06b7ac8.tgz","fileCount":23,"integrity":"sha512-+ImfP1W6RupJ+J1G+7+rtUYSuecFAxaIlM3lshnsMZKjGXO8A4GvN96vpPebzEOCU5ez0NzhEXFtgtKTgJ1EFw==","signatures":[{"sig":"MEUCIQCKV1LL9kW2evPo/iAADmh0m0OLxvLnrV5udVJPr1nLqQIgBpvRJr/cR7lMKMtszmXwc+BJFOljCBAjyrmClPYR6j4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":43695,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhll+2CRA9TVsSAnZWagAAKWUP+wYb1nK2WoYbev5RtmIe\nZC4C7eewHbRTZP7+GgiYfRQrKIQ/Au1X4yk3gN+1YkFrzY9GQ9eNmDH8kroW\nKLW4/YB/JkDQ6/olbCFxmFbAdj5BADkQi9ULArSpqQBKV75xlxlDAppdmTyT\nAzbnHo9PdhKKwoFJf1z0oIbi7eKdPWG7Xiegl9fbnXljtKJkiHPMPUtgdOsO\nbuCKT1qL1eLZNyJCOSCHK34AoLZpXFxtLgFlYZc81nRhHxmHzZbiGD+dkrwP\ncpp3iUaRnIctw3wr1DAnDj30bRbAmPRjCzj4NP/8pxKOtiyQPGonCdmhGj5D\nW5IxZg7KtZyzB/BgscMOHocJV388ekN1DG3GIdCr0tm16bNoXr0J+3P0w6pa\n0I/qAD0z7Lvk50jMxp2itTQb+N/eeXuIZ/et1Tk2PsdncxA1uv/E79LM3y76\nC2GwJa/WxmaS/GL9iZnFpHdCiE5u14Wc3COn08thBD4bR+d5ItAQT7mdeq7G\nQRa9Rop/kJUD9IPcK097okMdufsUOO7MRSqO9sRXoHJ92b6xL5nSw1UMx4qI\n3VeuOxypS/e+lI3f12WI3ymDN5XUvJh0bb3AkoeEmMBXh7SwCcTb4b+KrOSY\nI4Z87hdRBqWQxJAs42fW88XdJXBrTa32cAjEy2N8On0q/Ghl5Vqgh8Ld/Oax\ntgPn\r\n=KNa4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/src/index.js","gitHead":"b39fcca26175a6cae085e11c0ec8f4e1a06b7ac8","scripts":{"lint":"balena-lint --typescript src test","test":"node -r ts-node/register ./test/cli.ts","build":"tsc","debug":"NODE_DEBUG=@balena/happy-eyeballs-debug npm test","verbose":"NODE_DEBUG=@balena/eye-patch,@balena/happy-eyeballs-debug npm test"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"versionist":{"publishedAt":"2021-11-18T14:12:06.968Z"},"_npmVersion":"6.14.15","description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","directories":{},"_nodeVersion":"14.17.1","dependencies":{"tslib":"^2.3.1","abort-controller":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"chalk":"^4.1.2","busboy":"^0.3.1","expect":"^27.2.2","request":"^2.88.2","ts-node":"^10.2.1","node-fetch":"^2.6.5","typescript":"^4.4.3","@types/node":"^16.10.1","@types/chalk":"^2.2.0","@types/busboy":"^0.2.4","@types/expect":"^24.3.0","@types/request":"^2.48.7","@types/node-fetch":"^2.5.12"},"_npmOperationalInternal":{"tmp":"tmp/happy-eyeballs_0.0.2-publish-branch-b39fcca26175a6cae085e11c0ec8f4e1a06b7ac8_1637244854513_0.44487017728780565","host":"s3://npm-registry-packages"}},"0.0.2":{"name":"@balena/happy-eyeballs","version":"0.0.2","keywords":[],"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","_id":"@balena/happy-eyeballs@0.0.2","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"}],"contributors":[{"name":"Miguel Casquiera","email":"miguel@balena.io"}],"homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"dist":{"shasum":"b4ff091a4b7f3704a31e72561f68c546e91a7045","tarball":"https://registry.npmjs.org/@balena/happy-eyeballs/-/happy-eyeballs-0.0.2.tgz","fileCount":23,"integrity":"sha512-KnZ437emJ8HiruDbEeeNipoRjXTjYtz7ckxbBsPoA0bGWg16F5rL3jWT/XRB35fKAp3MZgc4kAvwLa6PzWFemw==","signatures":[{"sig":"MEUCIQDeMTSYQWmNgxAC0cYkKIayVm0zNH9MBKSqkvrJXzuxCwIgZ8SsMYX1jmCyd+DUHYWwOad5otEvv2WwzDrzyWev0qU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":43639,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhlmJnCRA9TVsSAnZWagAApZAQAInsbr/eh53c3MCwQ0Y9\ngrJ+6uoRQI0WfEFwsDFk4kva6fBBdhkNeVsYxxCQico6j6t14Gtxtn+6pe/1\n+xpBWP2mgFg22FZgp43l8I25utnF8MJtCjFc5v8VCGTyt3OlLhG823uZPNZ3\nkwcPnd5Yi76KDTxc+FS3xqPcpIUsc9AZFjSOXt8G7osHYYH7ZrW0yL00lCR8\noOEY64B1TwTPlcouJ9C5jA5PC1XXS3XgNR04joPiy7XcSs+ChREqIZZpAPw4\nKcBr5UH50g3eqftGhQXubYGnUpAprpTHt13GD6ddHjKk6sWs+eYxzmvDcqES\neUJ6WOpj/YPKJA3d71ubtnmHRcRCeflYlmrCh3WxRGEUeYlvSQVy6SXCQAFo\n1LxdNXmJz/3/Int0IXrtIuh9Lkpiyz5Mb711VpL+P3XDWeXwbK4eFOtm1fiy\nXFkP8g9SoFzX2p5ijGK7qHVP27LaA2VciCXYU1qCzL2dAX7p4sarNINE+hot\nOIlX/+SKdvJWmMtYMlNpu3ztIf/RnouUkKzM2uQOltlJopIvtK7KhGanZC4+\nIloWpAKPLL9sKEDHsZodXhmF4sAmIrk/cOqaliwhVbE/pW2oUWfPTCZ1OVYf\nwi/a8eF5rZHF+g1PDVLc4gZcppQZUpBC0TH53BY/tPVQ6EFBiqQBwAftqCtj\npkpt\r\n=APxX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/src/index.js","gitHead":"0af8cf5f13889bb3e91f2fffb6b357264b1bf64f","scripts":{"lint":"balena-lint --typescript src test","test":"node -r ts-node/register ./test/cli.ts","build":"tsc","debug":"NODE_DEBUG=@balena/happy-eyeballs-debug npm test","verbose":"NODE_DEBUG=@balena/eye-patch,@balena/happy-eyeballs-debug npm test"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"versionist":{"publishedAt":"2021-11-18T14:24:03.214Z"},"_npmVersion":"6.14.15","description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","directories":{},"_nodeVersion":"14.17.1","dependencies":{"tslib":"^2.3.1","abort-controller":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"chalk":"^4.1.2","busboy":"^0.3.1","expect":"^27.2.2","request":"^2.88.2","ts-node":"^10.2.1","node-fetch":"^2.6.5","typescript":"^4.4.3","@types/node":"^16.10.1","@types/chalk":"^2.2.0","@types/busboy":"^0.2.4","@types/expect":"^24.3.0","@types/request":"^2.48.7","@types/node-fetch":"^2.5.12"},"_npmOperationalInternal":{"tmp":"tmp/happy-eyeballs_0.0.2_1637245543144_0.8797131926454043","host":"s3://npm-registry-packages"}},"0.0.2-publish-branch-8c4d939d95e89e44f3e047e1e3422da64debefaa":{"name":"@balena/happy-eyeballs","version":"0.0.2-publish-branch-8c4d939d95e89e44f3e047e1e3422da64debefaa","keywords":[],"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","_id":"@balena/happy-eyeballs@0.0.2-publish-branch-8c4d939d95e89e44f3e047e1e3422da64debefaa","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"}],"contributors":[{"name":"Miguel Casquiera","email":"miguel@balena.io"}],"homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"dist":{"shasum":"32adfa23b2f9401affdd523bfc22fc1b9d1f34e8","tarball":"https://registry.npmjs.org/@balena/happy-eyeballs/-/happy-eyeballs-0.0.2-publish-branch-8c4d939d95e89e44f3e047e1e3422da64debefaa.tgz","fileCount":23,"integrity":"sha512-UG/10++SquXasb84zJTaVVQuDT2MwcL3LbE9BGNNMv6sjMGoFO78uUibE9+3W2edgmuempmBFgyusR4hGamiiw==","signatures":[{"sig":"MEUCIQDP1tSG2ICAuR7Nrh2AXt3BjDJtHM5jnygVY3YNfqy/0AIgXcn2FVql2jri7O0/3P0u/3DUJn7BTaSkZqL3lGgiD9Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":43731,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhlmQRCRA9TVsSAnZWagAAIxoP/Rb4H6FN1rxD8yWSwWBI\nLH5Np5Kq8gz7d8+/Hej1kECdnQ6o5yFG8NzNGWOxW3QXVuAvnBuMmCryV7w3\nrsCPyVe2g/+ewUk6lQI7wLyfrXY+uQJpUHEQisBcv0r7Yx5lxpyG63zxZe1g\nNYCmGp6dlDNIPmSfafA9+HgezUnZxyHa9DbT49/gVelE3RjRvLM3SnpYgzFF\nwiid11s1Q+FIVrAq6lq+54+MI3qYMFhfHBu028j1AKy2pmqiLeZD0Jk6pjYV\n3CSq57Q+0lQw6uoIqe5FsdaA9LNpwaXky17oYeg8EDgmQ8n3etsE9f2vKHec\nYrQF8FGhliJIQlK/UXipv+tgQAG3q5zikLokUUk6+i1wAxG1yocoO7usyAf3\nGU+3VmxECfBwpb8eU9j+02b3nB4/kTOMXHgbP5aGO4QFaM8mMEncJGHeDoXt\nMD0LZ0RDZAcLxOsL/1w+NX++zDbUkT9eVCfReEzY5lpQy8zzZZESwU5rLGZw\nbVBneMSvHi5SH3GW52VRyiLXeKpwC6TAweYA4JZnhrypogl3khO8YkcGW6qn\nWN118zyYvaLU4AxhbCIEDeh7kA8n3FnM5Dt8MlLUUl0rubUZunKY4crNuNMT\nfW357eidUbsCVJicW6DIgdUeJ9JB39mv5Ym/cuMlTN2QcJLVUyFz+yD/mmKP\npw+w\r\n=5wW/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/src/index.js","readme":"## @balena-io/happy-eyeballs\n\nThis package patches NodeJS's `http(s).Agent` to implement the IETF standard, \"Happy Eyeballs 2\" ([rfc8305](https://datatracker.ietf.org/doc/html/rfc8305)).\n\nIt improves client performance and reliability by trying concurrently trying multiple ip addresses for a given host name. See [Explanation](#explanation) for more detail.\n\n### Installation\n\n```\nnpm i --save-dev @balena/happy-eyeballs\n```\n\n```\nyarn add --dev @balena/happy-eyeballs\n```\n\n\n### Quick Usage\n\nTo use this library, simply import\n\n```ts\nimport '@balena/happy-eyeballs/eye-patch';\n```\n\nor\n\n```js\nrequire('@balena/happy-eyeballs/eye-patch')\n```\n\nto the top of your `.js`/`.ts` entry file.\n\nNote: this will replace `http.Agent.prototype.createConnection` and `https.Agent.prototype.createConnection`, but it tries to preserve existing functionality as much as possible.\n\n### Explicit Usage\n\nIf you want to be more explicit, you can explicitly patch the `http(s).Agent`:\n\n```ts\nimport { patch } from '@balena/eye-patch';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\npatch(HttpAgent, {delay: 300});\npatch(HttpsAgent, {delay: 300});\n```\n\nAlthough, this is exactly what the `import '@balena/happy-eyeballs/eye-patch';` does anyway.\n\nNote that `delay` refers to the delay before attempting the next addresses. This is the delay browsers use.\n\nLater you can unpatch, which will undo the last patch:\n\n```ts\nunpatch([HttpsAgent, HttpAgent])\n```\n\nor reset to the original values of an agent:\n\n```ts\nreset([HttpsAgent, HttpAgent])\n```\n\nAlso, note that the default is `HttpAgent` and `HttpsAgent`, so this has the same effect as\n\n```ts\nreset()\n```\n\nAnd that goes for `patch` and `unpatch` too.\n\nYou could also implement your own agent and replace the `createConnection` method:\n\n```ts\nimport { createConnection } from '@balena/happy-eyeballs';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\nexport class MyHttpAgent extends HttpAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n\nexport class MyHttpsAgent extends HttpsAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n```\n\nThis does basically the same thing as the previous examples though.\n\n### Explanation\n\nEssentially, the algorithm amounts to this:\n\n1. Receive a hostname\n2. Have we connected to this host before?\n  * If yes:\n    * Try the family (Ipv4 or IPv6) of last successful connection if we have connected to this host before\n    * If connection is not successful within 300ms, proceed to next step\n  * If no: proceed to next step.\n3. Did the DNS lookup return both IPv4 and IPv6 addresses?\n  * If yes: try, both addresses concurrently until all have been tried\n  * If no: just try the address of the existent family\n4. Proceed with each address in chain, trying both families concurrently until either:\n  *. A connection is made\n  *. All connection attempts time out\n  *. All connection attempt fail\n5. If no connection was successful, return error of the first connection attempt or a \"time out\" error if all connections timed out\n","gitHead":"8c4d939d95e89e44f3e047e1e3422da64debefaa","scripts":{"lint":"balena-lint --typescript src test","test":"node -r ts-node/register ./test/cli.ts","build":"tsc","debug":"NODE_DEBUG=@balena/happy-eyeballs-debug npm test","verbose":"NODE_DEBUG=@balena/eye-patch,@balena/happy-eyeballs-debug npm test"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"versionist":{"publishedAt":"2021-11-18T14:30:57.950Z"},"_npmVersion":"6.14.15","description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","directories":{},"_nodeVersion":"14.17.1","dependencies":{"tslib":"^2.3.1","abort-controller":"^3.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chalk":"^4.1.2","busboy":"^0.3.1","expect":"^27.2.2","request":"^2.88.2","ts-node":"^10.2.1","node-fetch":"^2.6.5","typescript":"^4.4.3","@types/node":"^16.10.1","@types/chalk":"^2.2.0","@types/busboy":"^0.2.4","@types/expect":"^24.3.0","@types/request":"^2.48.7","@types/node-fetch":"^2.5.12"},"_npmOperationalInternal":{"tmp":"tmp/happy-eyeballs_0.0.2-publish-branch-8c4d939d95e89e44f3e047e1e3422da64debefaa_1637245969047_0.6276588495915671","host":"s3://npm-registry-packages"}},"0.0.3-publish-branch-64714e661bd5f264b748d29b7260ba1249112e50":{"name":"@balena/happy-eyeballs","version":"0.0.3-publish-branch-64714e661bd5f264b748d29b7260ba1249112e50","keywords":[],"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","_id":"@balena/happy-eyeballs@0.0.3-publish-branch-64714e661bd5f264b748d29b7260ba1249112e50","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"}],"contributors":[{"name":"Miguel Casquiera","email":"miguel@balena.io"}],"homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"dist":{"shasum":"4f4df58d94e648fda8c26437d11ad45181281143","tarball":"https://registry.npmjs.org/@balena/happy-eyeballs/-/happy-eyeballs-0.0.3-publish-branch-64714e661bd5f264b748d29b7260ba1249112e50.tgz","fileCount":23,"integrity":"sha512-T6V5mMz+J762S2CdWlUf8zLmB8fk6zzAU9K4yAZTTaGegjqcxeBvhspiwQVVqZ1QF6UZo3jlWuoD1XeGrUQu0A==","signatures":[{"sig":"MEUCID5aXe2ICySxWFCjn4D1oNGNIkrKesGfHRW4JuziuArnAiEA1mwZoaFAJkYoHPrerUY2MrpcI5hAUxYqluIDccAkQZ4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":43755,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhloVICRA9TVsSAnZWagAAF+sP/2yFemRZUSeO75WB5IaX\ncOoZuZfftV1idd8wdA3Y+n4EOnSuhjsUO2F8fe5FDgeXEJQvwP+bEXE+us6D\nZUeylWm0/K/EAsz3yhaF1kZzpeWDvU7mjCbq1pt49hPytT/AUUhYAUx1BEvH\n+a+CVKprjspyL5T9u/GlSZ+KvjBqvFLBbV0TSwl8rD7pvcFXJdSlsEMGiBHo\nfZevYPvDj6fuF7/xnZsPacUO7sNrQaZzfaF7fEYo9ser/Fijqjr53of9T7Zs\nKYXbp3o+wSaaMlxExmBN1HhGDlB31Xu26evV30gjtDTMU2p+S0Jl59sxOEue\nvZaFG9fF+TiR4Z0l/zs8ocfUENMHCln/3Jr2QsYFjwHgpFwL/0GrTFZnWZVE\nuGEfOUvy6Qzborq/oo/3oGQhfGkzaUP7/V+2yH/ScASfLoO9lLmFVE2PdgBr\nkgMhZxscpVq+5gNNeFCXTSmCQewExxW7Hms0HAaQBT320aA5IXGjbI+xNT5u\nV04FNYI8guYVAZZa6v07gz1WuXs0K8YjpApdEn9bl3W4V8ES9odGoH92e1Es\nFuNXBuxm3JV1nF1wfXqWWmvK0qBHoa9yoaN7Yq8hvC4iHd1AS6WyrrCXMV6r\nGEjbPcVJETSLCOTmVIzwTlqzdngpWuIIxS8aeOxSlhIobFbixjcT7MBsSEt2\nyxg0\r\n=xE2H\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/src/index.js","readme":"## @balena-io/happy-eyeballs\n\nThis package patches NodeJS's `http(s).Agent` to implement the IETF standard, \"Happy Eyeballs 2\" ([rfc8305](https://datatracker.ietf.org/doc/html/rfc8305)).\n\nIt improves client performance and reliability by trying concurrently trying multiple ip addresses for a given host name. See [Explanation](#explanation) for more detail.\n\n### Installation\n\n```\nnpm i --save-dev @balena/happy-eyeballs\n```\n\n```\nyarn add --dev @balena/happy-eyeballs\n```\n\n\n### Quick Usage\n\nTo use this library, simply import\n\n```ts\nimport '@balena/happy-eyeballs/eye-patch';\n```\n\nor\n\n```js\nrequire('@balena/happy-eyeballs/eye-patch')\n```\n\nto the top of your `.js`/`.ts` entry file.\n\nNote: this will replace `http.Agent.prototype.createConnection` and `https.Agent.prototype.createConnection`, but it tries to preserve existing functionality as much as possible.\n\n### Explicit Usage\n\nIf you want to be more explicit, you can explicitly patch the `http(s).Agent`:\n\n```ts\nimport { patch } from '@balena/eye-patch';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\npatch(HttpAgent, {delay: 300});\npatch(HttpsAgent, {delay: 300});\n```\n\nAlthough, this is exactly what the `import '@balena/happy-eyeballs/eye-patch';` does anyway.\n\nNote that `delay` refers to the delay before attempting the next addresses. This is the delay browsers use.\n\nLater you can unpatch, which will undo the last patch:\n\n```ts\nunpatch([HttpsAgent, HttpAgent])\n```\n\nor reset to the original values of an agent:\n\n```ts\nreset([HttpsAgent, HttpAgent])\n```\n\nAlso, note that the default is `HttpAgent` and `HttpsAgent`, so this has the same effect as\n\n```ts\nreset()\n```\n\nAnd that goes for `patch` and `unpatch` too.\n\nYou could also implement your own agent and replace the `createConnection` method:\n\n```ts\nimport { createConnection } from '@balena/happy-eyeballs';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\nexport class MyHttpAgent extends HttpAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n\nexport class MyHttpsAgent extends HttpsAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n```\n\nThis does basically the same thing as the previous examples though.\n\n### Explanation\n\nEssentially, the algorithm amounts to this:\n\n1. Receive a hostname\n2. Have we connected to this host before?\n  * If yes:\n    * Try the family (Ipv4 or IPv6) of last successful connection if we have connected to this host before\n    * If connection is not successful within 300ms, proceed to next step\n  * If no: proceed to next step.\n3. Did the DNS lookup return both IPv4 and IPv6 addresses?\n  * If yes: try, both addresses concurrently until all have been tried\n  * If no: just try the address of the existent family\n4. Proceed with each address in chain, trying both families concurrently until either:\n  *. A connection is made\n  *. All connection attempts time out\n  *. All connection attempt fail\n5. If no connection was successful, return error of the first connection attempt or a \"time out\" error if all connections timed out\n","gitHead":"64714e661bd5f264b748d29b7260ba1249112e50","scripts":{"lint":"balena-lint --typescript src test","test":"node -r ts-node/register ./test/cli.ts","build":"tsc","debug":"NODE_DEBUG=@balena/happy-eyeballs-debug npm test","verbose":"NODE_DEBUG=@balena/eye-patch,@balena/happy-eyeballs-debug npm test"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"versionist":{"publishedAt":"2021-11-18T16:52:39.476Z"},"_npmVersion":"6.14.15","description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","directories":{},"_nodeVersion":"14.17.1","dependencies":{"tslib":"^2.3.1","abort-controller":"^3.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chalk":"^4.1.2","busboy":"^0.3.1","expect":"^27.2.2","request":"^2.88.2","ts-node":"^10.2.1","node-fetch":"^2.6.5","typescript":"^4.4.3","@types/node":"^16.10.1","@types/chalk":"^2.2.0","@types/busboy":"^0.2.4","@types/expect":"^24.3.0","@types/request":"^2.48.7","@types/node-fetch":"^2.5.12"},"_npmOperationalInternal":{"tmp":"tmp/happy-eyeballs_0.0.3-publish-branch-64714e661bd5f264b748d29b7260ba1249112e50_1637254472401_0.07870285521539566","host":"s3://npm-registry-packages"}},"0.0.3-publish-branch-35111c93f010c1452cfe1d29dcba92392a28c704":{"name":"@balena/happy-eyeballs","version":"0.0.3-publish-branch-35111c93f010c1452cfe1d29dcba92392a28c704","keywords":[],"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","_id":"@balena/happy-eyeballs@0.0.3-publish-branch-35111c93f010c1452cfe1d29dcba92392a28c704","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"}],"contributors":[{"name":"Miguel Casquiera","email":"miguel@balena.io"}],"homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"dist":{"shasum":"18bd69428e6fa928af5e82811f86c90bd2ef0519","tarball":"https://registry.npmjs.org/@balena/happy-eyeballs/-/happy-eyeballs-0.0.3-publish-branch-35111c93f010c1452cfe1d29dcba92392a28c704.tgz","fileCount":24,"integrity":"sha512-auDYKVaqVlEl6iZad7LRvkERWxWXamXiXlLviUrRxB+2ActCalChtQy044xEJ8qp99tCibu0x3YCSJjZLsH82g==","signatures":[{"sig":"MEUCIDlOusTfXFlZ8/3bGRor+eZGQhBNnmKmifPZuhN3kYJTAiEAojOrBCsbUU76TAG72PJ/KT4xrDFkUvkRRVJNBoPT3Gw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":44166,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhloYoCRA9TVsSAnZWagAAPq8P/06ciROqqKTnxj5F5DPk\naxaGR6cUwcGHkiXsHWJdf901XVIwoYWVgA08L4GAyim+u+UpKrVucsNiYScS\nzFlmlPY8zfUJx/XitDovKbSrpsmhROBf++FJT/FqZMCZVnAFn2LrSgYzVZJg\npN0kJusMWC9pWI3sDCPGOWZMjQ+084SGnhlfx4wYP1QwZQUiR5HBE5+E8eib\n7bqp/6Asbg++DtjttxE2v74q7/Lc9aawjT6KOcELGPsuIqQFFy2nBKi6vaCx\n1emESo34gk8BZDZBBZLwtnaThTjHy3Oq1oFwOsQKoc21ToRObDEr5zbwfhEE\nAwA4anQQEYfOhZ3RZpZkOVxbNM3hLhQqQDF9Ye8h+0Gdc8i5UeLbnoOa+hFE\ny4QIY/vEP9cWWDDqQ1AoqJKcUQTn4qdYXMyyOrUfFuh/L0VoObUJ8yu9ELYy\nyAVlz8UMLL7zO8T8Z1itYDiF/V8DWgnCJRxyZDZzTyye+XU90qwpFss+F9b7\nwz9FOv3G2zhW/FGE3gGNLYK5VF5z+bOvehPRXyMmTdkWMb5sFQeF4zFbSD/0\noxJCHVmLUFrfZudLP+NBuy83lmAX1pTwNSkfg9V2ZWbZhPgXMDJC1ef3KO+B\nkrUcYQuxa+nGSHvp7/rGmyPgKGE5KSiv6I3tEri08LFe3tXOawEWdJdZLN7v\ndLQ6\r\n=tbrR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/src/index.js","readme":"## @balena-io/happy-eyeballs\n\nThis package patches NodeJS's `http(s).Agent` to implement the IETF standard, \"Happy Eyeballs 2\" ([rfc8305](https://datatracker.ietf.org/doc/html/rfc8305)).\n\nIt improves client performance and reliability by trying concurrently trying multiple ip addresses for a given host name. See [Explanation](#explanation) for more detail.\n\n### Installation\n\n```\nnpm i --save-dev @balena/happy-eyeballs\n```\n\n```\nyarn add --dev @balena/happy-eyeballs\n```\n\n\n### Quick Usage\n\nTo use this library, simply import\n\n```ts\nimport '@balena/happy-eyeballs/eye-patch';\n```\n\nor\n\n```js\nrequire('@balena/happy-eyeballs/eye-patch')\n```\n\nto the top of your `.js`/`.ts` entry file.\n\nNote: this will replace `http.Agent.prototype.createConnection` and `https.Agent.prototype.createConnection`, but it tries to preserve existing functionality as much as possible.\n\n### Explicit Usage\n\nIf you want to be more explicit, you can explicitly patch the `http(s).Agent`:\n\n```ts\nimport { patch } from '@balena/eye-patch';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\npatch(HttpAgent, {delay: 300});\npatch(HttpsAgent, {delay: 300});\n```\n\nAlthough, this is exactly what the `import '@balena/happy-eyeballs/eye-patch';` does anyway.\n\nNote that `delay` refers to the delay before attempting the next addresses. This is the delay browsers use.\n\nLater you can unpatch, which will undo the last patch:\n\n```ts\nunpatch([HttpsAgent, HttpAgent])\n```\n\nor reset to the original values of an agent:\n\n```ts\nreset([HttpsAgent, HttpAgent])\n```\n\nAlso, note that the default is `HttpAgent` and `HttpsAgent`, so this has the same effect as\n\n```ts\nreset()\n```\n\nAnd that goes for `patch` and `unpatch` too.\n\nYou could also implement your own agent and replace the `createConnection` method:\n\n```ts\nimport { createConnection } from '@balena/happy-eyeballs';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\nexport class MyHttpAgent extends HttpAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n\nexport class MyHttpsAgent extends HttpsAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n```\n\nThis does basically the same thing as the previous examples though.\n\n### Explanation\n\nEssentially, the algorithm amounts to this:\n\n1. Receive a hostname\n2. Have we connected to this host before?\n  * If yes:\n    * Try the family (Ipv4 or IPv6) of last successful connection if we have connected to this host before\n    * If connection is not successful within 300ms, proceed to next step\n  * If no: proceed to next step.\n3. Did the DNS lookup return both IPv4 and IPv6 addresses?\n  * If yes: try, both addresses concurrently until all have been tried\n  * If no: just try the address of the existent family\n4. Proceed with each address in chain, trying both families concurrently until either:\n  *. A connection is made\n  *. All connection attempts time out\n  *. All connection attempt fail\n5. If no connection was successful, return error of the first connection attempt or a \"time out\" error if all connections timed out\n","gitHead":"35111c93f010c1452cfe1d29dcba92392a28c704","scripts":{"lint":"balena-lint --typescript src test","test":"node -r ts-node/register ./test/cli.ts","build":"tsc","debug":"NODE_DEBUG=@balena/happy-eyeballs-debug npm test","verbose":"NODE_DEBUG=@balena/eye-patch,@balena/happy-eyeballs-debug npm test"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"versionist":{"publishedAt":"2021-11-18T16:56:19.489Z"},"_npmVersion":"6.14.15","description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","directories":{},"_nodeVersion":"14.17.1","dependencies":{"tslib":"^2.3.1","expect":"^27.2.2","abort-controller":"^3.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chalk":"^4.1.2","busboy":"^0.3.1","request":"^2.88.2","ts-node":"^10.2.1","node-fetch":"^2.6.5","typescript":"^4.4.3","@types/node":"^16.10.1","@types/chalk":"^2.2.0","@types/busboy":"^0.2.4","@types/expect":"^24.3.0","@types/request":"^2.48.7","@types/node-fetch":"^2.5.12"},"_npmOperationalInternal":{"tmp":"tmp/happy-eyeballs_0.0.3-publish-branch-35111c93f010c1452cfe1d29dcba92392a28c704_1637254695961_0.38985281204426414","host":"s3://npm-registry-packages"}},"0.0.3-publish-branch-d49c505fc5cbf426489d1386033198a6c692d26a":{"name":"@balena/happy-eyeballs","version":"0.0.3-publish-branch-d49c505fc5cbf426489d1386033198a6c692d26a","keywords":[],"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","_id":"@balena/happy-eyeballs@0.0.3-publish-branch-d49c505fc5cbf426489d1386033198a6c692d26a","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"}],"contributors":[{"name":"Miguel Casquiera","email":"miguel@balena.io"}],"homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"dist":{"shasum":"110614bfd83f0dda86f8f78525717f9b41409149","tarball":"https://registry.npmjs.org/@balena/happy-eyeballs/-/happy-eyeballs-0.0.3-publish-branch-d49c505fc5cbf426489d1386033198a6c692d26a.tgz","fileCount":24,"integrity":"sha512-XickauRKuG84Uh0382mltWRtOD9w0Jwk+G43IoyNupwvsDTk4zEU6YbTkjFoltTYjkxXeejTH6akLu9ORHmbOw==","signatures":[{"sig":"MEUCIBbqWHGDjAdAyCDXsnGJeAJUlmstMLAM3BcYphPecIz8AiEAh+AmoMH9DVOoXY4m0vodw6yTowhg6PbxKVUM6sxgxY0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":44249,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhloeYCRA9TVsSAnZWagAAVPwP/R36u4aRmwbSPbVWTVFX\nl2MTb9o4NAZVg0XfjuSuWbZTtLygstTmMqDsdPLuumt7+zjYLYnVytMJR1j0\nnAry4KRNb7jZqF6AS/8qcn9OOjmuYpXbw6PQ5NixFxeozWvtY+I7RhuZrjgh\nV0Ef1426z0b5UoPIrrppD5ypo4GmL0DUhJMVEQn92/T/WWIEwwr7sJThKV+f\nFjrlI5evzGTyXKZDpgNiOuKgE8lsCnPtbQOhklgHHhFpqOHejLICzc4YrWxU\nEYJfeobljnicnYiB3JWqIrqn0oUe/bJwhPtSLCMhCsD6+BWgevJA9yx+qCYv\nXtT3TsHb1uC9kU5zr0lRlP3mppx48VkXZo3eHNP5GNtBSpgOvRqONTMLjPLi\nr53aX0PqXINSmwhtRAHCzZ5TiDxAAtVhkbFNfFO79q4/HSLlm1hkWt/ZM+W1\n5yVb8A6yHr4QC87KN/dX23soNcNwOihM4abNhjIqWjOo7J3nOtAPbdTsgXaI\nMP2fEl/lYGStdyTvgAyrtoFRkIB+LzAQ9CE0TvIh8VJRVxLbOVJqWk3s9f7A\nKmT79Da6Cy+5IEb9LfhjOPR8Osltlx/ktJyL1T7Q73h8L17aJhD+xd850syF\nMXXdZJQw3L6fR19G6DczknYEyRI8LOWndhBPD7f6Kws9VLcKODnjP/JJbyVD\nStsf\r\n=5tXI\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/src/index.js","readme":"## @balena-io/happy-eyeballs\n\nThis package patches NodeJS's `http(s).Agent` to implement the IETF standard, \"Happy Eyeballs 2\" ([rfc8305](https://datatracker.ietf.org/doc/html/rfc8305)).\n\nIt improves client performance and reliability by trying concurrently trying multiple ip addresses for a given host name. See [Explanation](#explanation) for more detail.\n\n### Installation\n\n```\nnpm i --save-dev @balena/happy-eyeballs\n```\n\n```\nyarn add --dev @balena/happy-eyeballs\n```\n\n\n### Quick Usage\n\nTo use this library, simply import\n\n```ts\nimport '@balena/happy-eyeballs/eye-patch';\n```\n\nor\n\n```js\nrequire('@balena/happy-eyeballs/eye-patch')\n```\n\nto the top of your `.js`/`.ts` entry file.\n\nNote: this will replace `http.Agent.prototype.createConnection` and `https.Agent.prototype.createConnection`, but it tries to preserve existing functionality as much as possible.\n\n### Explicit Usage\n\nIf you want to be more explicit, you can explicitly patch the `http(s).Agent`:\n\n```ts\nimport { patch } from '@balena/eye-patch';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\npatch(HttpAgent, {delay: 300});\npatch(HttpsAgent, {delay: 300});\n```\n\nAlthough, this is exactly what the `import '@balena/happy-eyeballs/eye-patch';` does anyway.\n\nNote that `delay` refers to the delay before attempting the next addresses. This is the delay browsers use.\n\nLater you can unpatch, which will undo the last patch:\n\n```ts\nunpatch([HttpsAgent, HttpAgent])\n```\n\nor reset to the original values of an agent:\n\n```ts\nreset([HttpsAgent, HttpAgent])\n```\n\nAlso, note that the default is `HttpAgent` and `HttpsAgent`, so this has the same effect as\n\n```ts\nreset()\n```\n\nAnd that goes for `patch` and `unpatch` too.\n\nYou could also implement your own agent and replace the `createConnection` method:\n\n```ts\nimport { createConnection } from '@balena/happy-eyeballs';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\nexport class MyHttpAgent extends HttpAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n\nexport class MyHttpsAgent extends HttpsAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n```\n\nThis does basically the same thing as the previous examples though.\n\n### Explanation\n\nEssentially, the algorithm amounts to this:\n\n1. Receive a hostname\n2. Have we connected to this host before?\n  * If yes:\n    * Try the family (Ipv4 or IPv6) of last successful connection if we have connected to this host before\n    * If connection is not successful within 300ms, proceed to next step\n  * If no: proceed to next step.\n3. Did the DNS lookup return both IPv4 and IPv6 addresses?\n  * If yes: try, both addresses concurrently until all have been tried\n  * If no: just try the address of the existent family\n4. Proceed with each address in chain, trying both families concurrently until either:\n  *. A connection is made\n  *. All connection attempts time out\n  *. All connection attempt fail\n5. If no connection was successful, return error of the first connection attempt or a \"time out\" error if all connections timed out\n","gitHead":"d49c505fc5cbf426489d1386033198a6c692d26a","scripts":{"lint":"balena-lint --typescript src test","test":"node -r ts-node/register ./test/cli.ts","build":"tsc","debug":"NODE_DEBUG=@balena/happy-eyeballs-debug npm test","verbose":"NODE_DEBUG=@balena/eye-patch,@balena/happy-eyeballs-debug npm test"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"versionist":{"publishedAt":"2021-11-18T17:02:15.215Z"},"_npmVersion":"6.14.15","description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","directories":{},"_nodeVersion":"14.17.1","dependencies":{"tslib":"^2.3.1","expect":"^27.2.2","abort-controller":"^3.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chalk":"^4.1.2","busboy":"^0.3.1","request":"^2.88.2","ts-node":"^10.2.1","node-fetch":"^2.6.5","typescript":"^4.4.3","@types/node":"^16.10.1","@types/chalk":"^2.2.0","@types/busboy":"^0.2.4","@types/expect":"^24.3.0","@types/request":"^2.48.7","@types/node-fetch":"^2.5.12"},"_npmOperationalInternal":{"tmp":"tmp/happy-eyeballs_0.0.3-publish-branch-d49c505fc5cbf426489d1386033198a6c692d26a_1637255064399_0.8799902089419969","host":"s3://npm-registry-packages"}},"0.0.3-publish-branch-003c1a3a8065aa4c2230d8b11336c8808cf0a2e3":{"name":"@balena/happy-eyeballs","version":"0.0.3-publish-branch-003c1a3a8065aa4c2230d8b11336c8808cf0a2e3","keywords":[],"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","_id":"@balena/happy-eyeballs@0.0.3-publish-branch-003c1a3a8065aa4c2230d8b11336c8808cf0a2e3","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"}],"contributors":[{"name":"Miguel Casquiera","email":"miguel@balena.io"}],"homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"dist":{"shasum":"5c0cf5b9a8ac3d80b66944b97d4fa90fa8a5a57b","tarball":"https://registry.npmjs.org/@balena/happy-eyeballs/-/happy-eyeballs-0.0.3-publish-branch-003c1a3a8065aa4c2230d8b11336c8808cf0a2e3.tgz","fileCount":24,"integrity":"sha512-1SyWG5u7IyiIEeV5EeRiC7F7CaYcqnHMHIyfB7tkcQwGjDMBm3bVkNlw028mN+TGjDkBAa6st0rwd816b0gdGg==","signatures":[{"sig":"MEYCIQCH2QLDLeJAS62L2hDitHLA6cxd7ApMTFbdIk19lR8wzwIhAKmS3IIIqip+o5wZ0RufoFlDijX4WiIcn7RQI00u1lcT","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":44355,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhlohuCRA9TVsSAnZWagAA16cQAJPxHVcCrS8E06AFVlKE\nVsc/IymnLMoVGSfGSp82oKKBSt6WSASzGVFxcN1tk3Tg817JfIfbCByYQwsH\niQUOFbe5UnMBeJTkr9wYrQ+f9IoHtUiEkVPSyuS+77l2dlvsjEzJ4KoaQBZM\np0I1T6dmYBFF4leF+63q+Lpa/SHfTD5e5KkG3PgxlyeDNN9BFFnz3ydjDoys\nKIWCWuH8Ey+qmQIE7Np6UQVDsGmx3g8MCIiuLCelVutUjtP5CovbM9MMQrwW\nJrYbihAumY20zjyGE53/FGcVmWn1i3qP8cLXXIvMwrXzJBX4BRas68wNQoGo\nIp3mHFUA8Up7RW828FAE9MVQlH0yQKmBHEyhQkiDUMkKOw0M40lxwFCrfPQo\ncKBdJtqG6yvUl3c/ELVrCjaYA+NBCfVunxxgAi8ZJ5CmO5FCOq3Dua0LjMtT\nmAZqZRXlT1EmRoIVqbYBZYUmq81A4MSK9C5ckcgBSlI5WfEmRgA6ScHUmrl6\nPKtVU1aQ+8dVkJOoDv19BQCEmMkZP3pZYvNrbzk/+qGuy/d16BCFCnPQTKce\nkjndsOprG2g4g6PoVs3T57rtKWDjrKB6ztr8u/y/YJW4JD2BkzYD37YRV8P0\nMIRTBuLRK+vRH0sSwvyvweqeX8gcvKTu/Ft7mVlFIwGr91vLQduOc7MG/2TP\nO+ph\r\n=DyzG\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/src/index.js","readme":"## @balena-io/happy-eyeballs\n\nThis package patches NodeJS's `http(s).Agent` to implement the IETF standard, \"Happy Eyeballs 2\" ([rfc8305](https://datatracker.ietf.org/doc/html/rfc8305)).\n\nIt improves client performance and reliability by trying concurrently trying multiple ip addresses for a given host name. See [Explanation](#explanation) for more detail.\n\n### Installation\n\n```\nnpm i --save-dev @balena/happy-eyeballs\n```\n\n```\nyarn add --dev @balena/happy-eyeballs\n```\n\n\n### Quick Usage\n\nTo use this library, simply import\n\n```ts\nimport '@balena/happy-eyeballs/eye-patch';\n```\n\nor\n\n```js\nrequire('@balena/happy-eyeballs/eye-patch')\n```\n\nto the top of your `.js`/`.ts` entry file.\n\nNote: this will replace `http.Agent.prototype.createConnection` and `https.Agent.prototype.createConnection`, but it tries to preserve existing functionality as much as possible.\n\n### Explicit Usage\n\nIf you want to be more explicit, you can explicitly patch the `http(s).Agent`:\n\n```ts\nimport { patch } from '@balena/eye-patch';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\npatch(HttpAgent, {delay: 300});\npatch(HttpsAgent, {delay: 300});\n```\n\nAlthough, this is exactly what the `import '@balena/happy-eyeballs/eye-patch';` does anyway.\n\nNote that `delay` refers to the delay before attempting the next addresses. This is the delay browsers use.\n\nLater you can unpatch, which will undo the last patch:\n\n```ts\nunpatch([HttpsAgent, HttpAgent])\n```\n\nor reset to the original values of an agent:\n\n```ts\nreset([HttpsAgent, HttpAgent])\n```\n\nAlso, note that the default is `HttpAgent` and `HttpsAgent`, so this has the same effect as\n\n```ts\nreset()\n```\n\nAnd that goes for `patch` and `unpatch` too.\n\nYou could also implement your own agent and replace the `createConnection` method:\n\n```ts\nimport { createConnection } from '@balena/happy-eyeballs';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\nexport class MyHttpAgent extends HttpAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n\nexport class MyHttpsAgent extends HttpsAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n```\n\nThis does basically the same thing as the previous examples though.\n\n### Explanation\n\nEssentially, the algorithm amounts to this:\n\n1. Receive a hostname\n2. Have we connected to this host before?\n  * If yes:\n    * Try the family (Ipv4 or IPv6) of last successful connection if we have connected to this host before\n    * If connection is not successful within 300ms, proceed to next step\n  * If no: proceed to next step.\n3. Did the DNS lookup return both IPv4 and IPv6 addresses?\n  * If yes: try, both addresses concurrently until all have been tried\n  * If no: just try the address of the existent family\n4. Proceed with each address in chain, trying both families concurrently until either:\n  *. A connection is made\n  *. All connection attempts time out\n  *. All connection attempt fail\n5. If no connection was successful, return error of the first connection attempt or a \"time out\" error if all connections timed out\n","gitHead":"003c1a3a8065aa4c2230d8b11336c8808cf0a2e3","scripts":{"lint":"balena-lint --typescript src test","test":"node -r ts-node/register ./test/cli.ts","build":"tsc","debug":"NODE_DEBUG=@balena/happy-eyeballs-debug npm test","verbose":"NODE_DEBUG=@balena/eye-patch,@balena/happy-eyeballs-debug npm test"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"versionist":{"publishedAt":"2021-11-18T17:05:48.816Z"},"_npmVersion":"6.14.15","description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","directories":{},"_nodeVersion":"14.17.1","dependencies":{"tslib":"^2.3.1","expect":"^27.2.2","abort-controller":"^3.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chalk":"^4.1.2","busboy":"^0.3.1","request":"^2.88.2","ts-node":"^10.2.1","node-fetch":"^2.6.5","typescript":"^4.4.3","@types/node":"^16.10.1","@types/chalk":"^2.2.0","@types/busboy":"^0.2.4","@types/expect":"^24.3.0","@types/request":"^2.48.7","@types/node-fetch":"^2.5.12"},"_npmOperationalInternal":{"tmp":"tmp/happy-eyeballs_0.0.3-publish-branch-003c1a3a8065aa4c2230d8b11336c8808cf0a2e3_1637255277809_0.20967600514851203","host":"s3://npm-registry-packages"}},"0.0.3-publish-branch-2f8369f60c344ff9203ffa2f6a749f338eb010ce":{"name":"@balena/happy-eyeballs","version":"0.0.3-publish-branch-2f8369f60c344ff9203ffa2f6a749f338eb010ce","keywords":[],"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","_id":"@balena/happy-eyeballs@0.0.3-publish-branch-2f8369f60c344ff9203ffa2f6a749f338eb010ce","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"}],"contributors":[{"name":"Miguel Casquiera","email":"miguel@balena.io"}],"homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"dist":{"shasum":"99f1df1fcc089d6451e8787f46ff2afeee6d92a5","tarball":"https://registry.npmjs.org/@balena/happy-eyeballs/-/happy-eyeballs-0.0.3-publish-branch-2f8369f60c344ff9203ffa2f6a749f338eb010ce.tgz","fileCount":24,"integrity":"sha512-CCis/kYOOJka039ogDVpsbJ2ePeD3bUDnRVEZs4b+u6wLaWPb7aIPPhM3CzSkNEQJczAauC+/a+mFRyQrRoh1g==","signatures":[{"sig":"MEQCIBL0iAtxIACakxhBMMdRm39WyfLkOe7R7Ftae/xbXBtbAiBxL8emVCiFLcsy9Yg4y4CLxJKZptzChvn5nsW0eijZGg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":44401,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhlolbCRA9TVsSAnZWagAAAZwP/1xDJGQEFtueO4SQUKdq\ncn9g2VOr9S32RlEdxsSgW8w2JIA14Ufym9iwv42eKiquN6pOR2tY3xxVJjSs\nKwIzh418zmuFFYbuQfmHHpUZRsB9sL/FwrsxvfYMMdDf8pT+ksKN87jeXvP9\nLJhCuh1+ejfDQofLfpedPzBbu0PF46VpCldXU/AIwi/R2ptrBJl92ZWqJQbn\ni/FykX6qXTX+o5Hk/aZIT19ga8dF3M9OipCGl8lXCCKJLSniUUejOgZ+0GZF\nM8NIScHACQKg5FikDh9UcV+n+DGG3IPgaIvtb8fumFcKGC/AAuQYa+LMGHft\nIBVxRuqtSEJ36/RzevlyOp4kpGV3jKSdCGBOD6PiK6aGDpl+1uMGrVOOa6ZK\n6Lt3AEELwV/dS1cp517t52bfCvn8TISsKrtd/BsNyKqMgl0i0bakcYRoym3L\ni3Lwj8fe4XuCprtWAhROGuOojjz5OEDPBN/FHQRlIMrWtToj6Ev7ellDzjr4\nFw6xaN5gcZjXjE1T0OmoeiQSSwgaheiEl3qITRO1JBL4kPXD0xyAIvRuFbiO\nX/z/sKH+crIDHg4qT+NNLC8rja/UIN3aSutvHpwghPQdCIbOPEKmEqhxGjqF\nBWbPP9y+jNAxu/n449ErJLw1hqQZD03Mu38Qi1iI7pR8KMZVI1xwHjUGQoVF\nZ/Aa\r\n=wrkW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/src/index.js","readme":"## @balena-io/happy-eyeballs\n\nThis package patches NodeJS's `http(s).Agent` to implement the IETF standard, \"Happy Eyeballs 2\" ([rfc8305](https://datatracker.ietf.org/doc/html/rfc8305)).\n\nIt improves client performance and reliability by trying concurrently trying multiple ip addresses for a given host name. See [Explanation](#explanation) for more detail.\n\n### Installation\n\n```\nnpm i --save-dev @balena/happy-eyeballs\n```\n\n```\nyarn add --dev @balena/happy-eyeballs\n```\n\n\n### Quick Usage\n\nTo use this library, simply import\n\n```ts\nimport '@balena/happy-eyeballs/eye-patch';\n```\n\nor\n\n```js\nrequire('@balena/happy-eyeballs/eye-patch')\n```\n\nto the top of your `.js`/`.ts` entry file.\n\nNote: this will replace `http.Agent.prototype.createConnection` and `https.Agent.prototype.createConnection`, but it tries to preserve existing functionality as much as possible.\n\n### Explicit Usage\n\nIf you want to be more explicit, you can explicitly patch the `http(s).Agent`:\n\n```ts\nimport { patch } from '@balena/eye-patch';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\npatch(HttpAgent, {delay: 300});\npatch(HttpsAgent, {delay: 300});\n```\n\nAlthough, this is exactly what the `import '@balena/happy-eyeballs/eye-patch';` does anyway.\n\nNote that `delay` refers to the delay before attempting the next addresses. This is the delay browsers use.\n\nLater you can unpatch, which will undo the last patch:\n\n```ts\nunpatch([HttpsAgent, HttpAgent])\n```\n\nor reset to the original values of an agent:\n\n```ts\nreset([HttpsAgent, HttpAgent])\n```\n\nAlso, note that the default is `HttpAgent` and `HttpsAgent`, so this has the same effect as\n\n```ts\nreset()\n```\n\nAnd that goes for `patch` and `unpatch` too.\n\nYou could also implement your own agent and replace the `createConnection` method:\n\n```ts\nimport { createConnection } from '@balena/happy-eyeballs';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\nexport class MyHttpAgent extends HttpAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n\nexport class MyHttpsAgent extends HttpsAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n```\n\nThis does basically the same thing as the previous examples though.\n\n### Explanation\n\nEssentially, the algorithm amounts to this:\n\n1. Receive a hostname\n2. Have we connected to this host before?\n  * If yes:\n    * Try the family (Ipv4 or IPv6) of last successful connection if we have connected to this host before\n    * If connection is not successful within 300ms, proceed to next step\n  * If no: proceed to next step.\n3. Did the DNS lookup return both IPv4 and IPv6 addresses?\n  * If yes: try, both addresses concurrently until all have been tried\n  * If no: just try the address of the existent family\n4. Proceed with each address in chain, trying both families concurrently until either:\n  *. A connection is made\n  *. All connection attempts time out\n  *. All connection attempt fail\n5. If no connection was successful, return error of the first connection attempt or a \"time out\" error if all connections timed out\n","gitHead":"2f8369f60c344ff9203ffa2f6a749f338eb010ce","scripts":{"lint":"balena-lint --typescript src test","test":"node -r ts-node/register ./test/cli.ts","build":"tsc","debug":"NODE_DEBUG=@balena/happy-eyeballs-debug npm test","verbose":"NODE_DEBUG=@balena/eye-patch,@balena/happy-eyeballs-debug npm test"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"versionist":{"publishedAt":"2021-11-18T17:09:37.073Z"},"_npmVersion":"6.14.15","description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","directories":{},"_nodeVersion":"14.17.1","dependencies":{"tslib":"^2.3.1","expect":"^27.2.2","abort-controller":"^3.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chalk":"^4.1.2","busboy":"^0.3.1","request":"^2.88.2","ts-node":"^10.2.1","node-fetch":"^2.6.5","typescript":"^4.4.3","@types/node":"^16.10.1","@types/chalk":"^2.2.0","@types/busboy":"^0.2.4","@types/expect":"^24.3.0","@types/request":"^2.48.7","@types/node-fetch":"^2.5.12"},"_npmOperationalInternal":{"tmp":"tmp/happy-eyeballs_0.0.3-publish-branch-2f8369f60c344ff9203ffa2f6a749f338eb010ce_1637255515657_0.28439930117339673","host":"s3://npm-registry-packages"}},"0.0.3":{"name":"@balena/happy-eyeballs","version":"0.0.3","keywords":[],"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","_id":"@balena/happy-eyeballs@0.0.3","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"}],"contributors":[{"name":"Miguel Casquiera","email":"miguel@balena.io"}],"homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"dist":{"shasum":"215cf25f585210ef9e5d59388ac263c1dd4695c1","tarball":"https://registry.npmjs.org/@balena/happy-eyeballs/-/happy-eyeballs-0.0.3.tgz","fileCount":24,"integrity":"sha512-A7qCIQjPqdkKgGeCLU/2SBOE7N+lf54RAQdMzwTp+oFf3zHrilK63mSc3dQlUByCImamFjqrP6HQ7v/EL1rWxg==","signatures":[{"sig":"MEYCIQC5ISHgrCsaaA/ogcAR5WBi27DFHG8qdWO+3ng/zqzKrgIhAO/UDKtfzSy3QmxbMdcNKKUrzCc6qlLDcEjhMUM+H0XZ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":44345},"main":"build/src/index.js","gitHead":"9da097c172f4718293ef0400ad71e6cbfc49617e","scripts":{"lint":"balena-lint --typescript src test","test":"node -r ts-node/register ./test/cli.ts","build":"tsc","debug":"NODE_DEBUG=@balena/happy-eyeballs-debug npm test","verbose":"NODE_DEBUG=@balena/eye-patch,@balena/happy-eyeballs-debug npm test"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"versionist":{"publishedAt":"2021-11-18T17:17:05.424Z"},"_npmVersion":"6.14.15","description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","directories":{},"_nodeVersion":"14.17.1","dependencies":{"tslib":"^2.3.1","expect":"^27.2.2","abort-controller":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"chalk":"^4.1.2","busboy":"^0.3.1","request":"^2.88.2","ts-node":"^10.2.1","node-fetch":"^2.6.5","typescript":"^4.4.3","@types/node":"^16.10.1","@types/chalk":"^2.2.0","@types/busboy":"^0.2.4","@types/expect":"^24.3.0","@types/request":"^2.48.7","@types/node-fetch":"^2.5.12"},"_npmOperationalInternal":{"tmp":"tmp/happy-eyeballs_0.0.3_1637255926589_0.24807727277837177","host":"s3://npm-registry-packages"}},"0.0.4-remove-10-af45038cdeda3eeec8fee1da75b36e0bd2f41bcc":{"name":"@balena/happy-eyeballs","version":"0.0.4-remove-10-af45038cdeda3eeec8fee1da75b36e0bd2f41bcc","keywords":[],"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","_id":"@balena/happy-eyeballs@0.0.4-remove-10-af45038cdeda3eeec8fee1da75b36e0bd2f41bcc","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"}],"contributors":[{"name":"Miguel Casquiera","email":"miguel@balena.io"}],"homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"dist":{"shasum":"58adb755a49f449b2f26d41619850495a8504326","tarball":"https://registry.npmjs.org/@balena/happy-eyeballs/-/happy-eyeballs-0.0.4-remove-10-af45038cdeda3eeec8fee1da75b36e0bd2f41bcc.tgz","fileCount":24,"integrity":"sha512-H2YNLpaFXCGKloEZ3b18ZF57VjmkjLmZ8aeYwSJeF4vOyRtjHbykf/TSpYV2Sk26lSD7+yRzIEVTAzPGr87FSw==","signatures":[{"sig":"MEYCIQCWHefkPnn8pVyD9Y3hqg4WzVgBZyPv1nEGZsGr3RVUPwIhAPjnO9cD05arD/Wf0iK7N/M4sfJFE8JQ19aSdHJl/MXV","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":44423,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhn+R9CRA9TVsSAnZWagAAC20P/0aAIDQna9uwT9tHZC5g\n6LeenE40jkOhRioHd4w+YEXFlODdf3gUzH5DU9+2po0BY387ivf4flYRewnC\nj4t9iy31FVPYc7EZ2BTr7H5a0xh0C8WIcM7DlGixll7sCgfQSaWL5s06eIYd\nYOEI9mBdUG+NGHEwVGg/VWJxrpHFWd4Rw8idVMTKtCpA+7xDgcqDiSi+2AIs\nRt7HP9MmHSGukgYiKhB5etBr/9YSQmYT3TVbUAU8UWQtXYVbcQYudVRA8vn7\nkTNv+Ju+pcojiJnRgZwmssx6lNIDvpUEsKze6xsG9QH6jOpB7bNcZIR6adcr\nHCR87rBq8J8qzGz1gDO8V/NWLC92r+uPolBREKz4/np01PjWKmrgJYdxLMlF\nfVj/veXdJg4CwEu9DmaaQp954ofJh9dquIkPRi4FL2yC6qCh9oAefmo5Am0C\nryqwzw4XHE6Q3JrGZxNb5njn0xdzt5EwnJDgIPIim/ZJ4OX0MKm7Wyi4l9Bw\nQpZTVZkTLi4BksXW+0J/o+NH/bvz0Njz7eBxiBKTutCcTTwT47pUeqSw+3xP\n+rZ2b3VLBvr8Xog07lUpbylWsWCCtnVqGJDmV3occAU5j78dTGMSg6BDRA9x\ndI6TVcbs+aVCmLh1jwUBj+HHnMrjQtW9ouCTC1wnTnVWcWKq9G2eVh+gnIuN\nu+V3\r\n=7x5R\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/src/index.js","readme":"## @balena-io/happy-eyeballs\n\nThis package patches NodeJS's `http(s).Agent` to implement the IETF standard, \"Happy Eyeballs 2\" ([rfc8305](https://datatracker.ietf.org/doc/html/rfc8305)).\n\nIt improves client performance and reliability by trying concurrently trying multiple ip addresses for a given host name. See [Explanation](#explanation) for more detail.\n\n### Installation\n\n```\nnpm i --save-dev @balena/happy-eyeballs\n```\n\n```\nyarn add --dev @balena/happy-eyeballs\n```\n\n\n### Quick Usage\n\nTo use this library, simply import\n\n```ts\nimport '@balena/happy-eyeballs/eye-patch';\n```\n\nor\n\n```js\nrequire('@balena/happy-eyeballs/eye-patch')\n```\n\nto the top of your `.js`/`.ts` entry file.\n\nNote: this will replace `http.Agent.prototype.createConnection` and `https.Agent.prototype.createConnection`, but it tries to preserve existing functionality as much as possible.\n\n### Explicit Usage\n\nIf you want to be more explicit, you can explicitly patch the `http(s).Agent`:\n\n```ts\nimport { patch } from '@balena/eye-patch';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\npatch(HttpAgent, {delay: 300});\npatch(HttpsAgent, {delay: 300});\n```\n\nAlthough, this is exactly what the `import '@balena/happy-eyeballs/eye-patch';` does anyway.\n\nNote that `delay` refers to the delay before attempting the next addresses. This is the delay browsers use.\n\nLater you can unpatch, which will undo the last patch:\n\n```ts\nunpatch([HttpsAgent, HttpAgent])\n```\n\nor reset to the original values of an agent:\n\n```ts\nreset([HttpsAgent, HttpAgent])\n```\n\nAlso, note that the default is `HttpAgent` and `HttpsAgent`, so this has the same effect as\n\n```ts\nreset()\n```\n\nAnd that goes for `patch` and `unpatch` too.\n\nYou could also implement your own agent and replace the `createConnection` method:\n\n```ts\nimport { createConnection } from '@balena/happy-eyeballs';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\nexport class MyHttpAgent extends HttpAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n\nexport class MyHttpsAgent extends HttpsAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n```\n\nThis does basically the same thing as the previous examples though.\n\n### Explanation\n\nEssentially, the algorithm amounts to this:\n\n1. Receive a hostname\n2. Have we connected to this host before?\n  * If yes:\n    * Try the family (Ipv4 or IPv6) of last successful connection if we have connected to this host before\n    * If connection is not successful within 300ms, proceed to next step\n  * If no: proceed to next step.\n3. Did the DNS lookup return both IPv4 and IPv6 addresses?\n  * If yes: try, both addresses concurrently until all have been tried\n  * If no: just try the address of the existent family\n4. Proceed with each address in chain, trying both families concurrently until either:\n  *. A connection is made\n  *. All connection attempts time out\n  *. All connection attempt fail\n5. If no connection was successful, return error of the first connection attempt or a \"time out\" error if all connections timed out\n","gitHead":"af45038cdeda3eeec8fee1da75b36e0bd2f41bcc","scripts":{"lint":"balena-lint --typescript src test","test":"node -r ts-node/register ./test/cli.ts","build":"tsc","debug":"NODE_DEBUG=@balena/happy-eyeballs-debug npm test","verbose":"NODE_DEBUG=@balena/eye-patch,@balena/happy-eyeballs-debug npm test"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"versionist":{"publishedAt":"2021-11-25T19:29:17.153Z"},"_npmVersion":"6.14.15","description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","directories":{},"_nodeVersion":"14.17.1","dependencies":{"tslib":"^2.3.1","expect":"^27.2.2","abort-controller":"^3.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chalk":"^4.1.2","busboy":"^0.3.1","request":"^2.88.2","ts-node":"^10.2.1","node-fetch":"^2.6.5","typescript":"^4.4.3","@types/node":"^16.10.1","@types/chalk":"^2.2.0","@types/busboy":"^0.2.4","@types/expect":"^24.3.0","@types/request":"^2.48.7","@types/node-fetch":"^2.5.12"},"_npmOperationalInternal":{"tmp":"tmp/happy-eyeballs_0.0.4-remove-10-af45038cdeda3eeec8fee1da75b36e0bd2f41bcc_1637868669283_0.780234998888991","host":"s3://npm-registry-packages"}},"0.0.4":{"name":"@balena/happy-eyeballs","version":"0.0.4","keywords":[],"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","_id":"@balena/happy-eyeballs@0.0.4","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"}],"contributors":[{"name":"Miguel Casquiera","email":"miguel@balena.io"}],"homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"dist":{"shasum":"558b78e71e4a856593e4cd9a1cc712b161d18dd7","tarball":"https://registry.npmjs.org/@balena/happy-eyeballs/-/happy-eyeballs-0.0.4.tgz","fileCount":24,"integrity":"sha512-Cg4MxEzUllqkwHHcNHCUD9HzZTGrHebVho7ZGV+Zy1ZkkXHMuBkv20YHUpqTJgi+Q9ELK2Nebe7iKb1rt9GkWg==","signatures":[{"sig":"MEUCIQDU4tgirF9Dc60nDxiF0gsVTV4AylNrFaGgb5pk4AkRPQIgGDGaTWk/wqLR5ZxcxxFpWUCoU6iIMpSc/jWTF+KNLRs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":44372,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhn+WlCRA9TVsSAnZWagAAQ5QP/1hr9A5Shl285bRFhbno\naBsOZs/fsAlTDLn05BF3813j6NzR2BY7sS4hATziDgmDq2nODm/zBhLsTzTg\nkHvzgShfpgfYKlZS5i3Itzq0afTkeOvCwVp2gDRLJ7De/M9ry3ap9GvDehJL\ngEEqDi7ZxrkGLN82sKyyJNAhEnwNqmZizijQL/0nQa5NYEDl7o1egJC+MAT3\nQNEWHndWCHfYNYXn8p5faU32qgpbc6wSsE+f7ohuAvCoEK7pflxpnw2OKIzA\nwzzxk3Fuw30LKHJV4LFWZ2zQfHA7ZbrThGG9/Dc8JNXgsj5/YLNM/pX5P416\nhzI0gjA18MuYgg9g+tNafBICQtuoI1wiTmVeApzmCpm6+B75N8ElTu5tqfwv\nKY5foHvZ0B4pCtGFgmRA/KtkIM4o44n4HU3ZpyVgx9BCYSvO/FU4qfa3bSZ7\nXd9XH+PUtMYxky32QZz0TpitUNa7DfQkrBqREpG5gEzzU5Cj4Dj6IfYpSRE+\nDdoEkFMqH1RqvhddEA1oUGKHtw243YcPlthg6CudyWacieXKTd/3ezCVZoWJ\nUcNdtYGRMauNWr6DSNwyYPFo7rqhy5Lk3htw0jBHQ0M96993vc5JxWnzDqWU\n9jI9tA3UvGWiptpg+i8FXW8zdf07E0cxSHuuoTMdX0I6nIF8fLU9lM1xP4dW\njQ11\r\n=eNdQ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/src/index.js","gitHead":"31965c2adcca29b2c7e919145a2cbd887fc5cc45","scripts":{"lint":"balena-lint --typescript src test","test":"node -r ts-node/register ./test/cli.ts","build":"tsc","debug":"NODE_DEBUG=@balena/happy-eyeballs-debug npm test","verbose":"NODE_DEBUG=@balena/eye-patch,@balena/happy-eyeballs-debug npm test"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"versionist":{"publishedAt":"2021-11-25T19:34:27.159Z"},"_npmVersion":"6.14.15","description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","directories":{},"_nodeVersion":"14.17.1","dependencies":{"tslib":"^2.3.1","expect":"^27.2.2","abort-controller":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"chalk":"^4.1.2","busboy":"^0.3.1","request":"^2.88.2","ts-node":"^10.2.1","node-fetch":"^2.6.5","typescript":"^4.4.3","@types/node":"^16.10.1","@types/chalk":"^2.2.0","@types/busboy":"^0.2.4","@types/expect":"^24.3.0","@types/request":"^2.48.7","@types/node-fetch":"^2.5.12"},"_npmOperationalInternal":{"tmp":"tmp/happy-eyeballs_0.0.4_1637868964913_0.45881279404099184","host":"s3://npm-registry-packages"}},"0.0.5-add-build-baaff909dba17551639f3d40afe37f9f02dac9bd":{"name":"@balena/happy-eyeballs","version":"0.0.5-add-build-baaff909dba17551639f3d40afe37f9f02dac9bd","keywords":[],"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","_id":"@balena/happy-eyeballs@0.0.5-add-build-baaff909dba17551639f3d40afe37f9f02dac9bd","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"}],"contributors":[{"name":"Miguel Casquiera","email":"miguel@balena.io"}],"homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"dist":{"shasum":"3c257d748d30953688e945b1c12f86f4162ccdbe","tarball":"https://registry.npmjs.org/@balena/happy-eyeballs/-/happy-eyeballs-0.0.5-add-build-baaff909dba17551639f3d40afe37f9f02dac9bd.tgz","fileCount":24,"integrity":"sha512-VwSW2rVVvVzEAAT7cRB2hpqfi1O3JW4vfx2gWs91EGRYmBsyPoLOtIHssooHzn5NpeOPrnNGS0q+45ObzpVWUA==","signatures":[{"sig":"MEQCIF/rE4qYu4Ds3qmgwD6CcHGPMjDbXUaSws12XbPMNoG5AiBm4NV8lwi8lZZ2DvcxrFAR/HG0by5IeKFg6e4/F0dA3w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":44541,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhn+mWCRA9TVsSAnZWagAAZdUP/06iyjWDtadrBiwafw0c\nuzWXeXkjnwAnks2aHGEpoqBL+A4+Id/0o96HaQlbWti/KmcTX1c2YgStAaxq\ndTzgT7y/v3M4mIkudZQZ2K0iR6SG0HtnOvsRibaviK3Fn4Ej3mMV3Llc+NM9\n1C3WJZMBISSHx8A14lxepcab7/1UTT3A9k3BzBM6CtgNT1jXY3T9Nleo1P42\ndjoWTiQpeB0hJhhG/HTyYwSvpqwBa9o51Ksh8YrmhhcRO9Is2C4mdeDPTw1w\nhYHoo8PPUWOSUO+T5rLGYgIVxofQ5bl4SHvCcP9r4HySCv6hew5+PYWJU6jQ\nohMMczDrwzSXIqOt1k5UmKkoWeCYeh/qbitdj6BVJV1/2nEvXXjk29G0FtA9\nf0qGXSiFqijVdCYDQA/1spJqnjNmaXEe7WRG7qMjhNvVE4vWJMhrQNOsykS8\nhVwF6QyQbqvKtb9m8Av2Bsa6Jeqil1ylz1ZX9r/YbDuBjbLpDY22u+XFgZ5Z\nYEnS4KLCCPg60tAjrgK5BTJ9QcoaI/BwAMkdYQcxwZ1q4gxFb23zfC2ly8WO\nGiu92aVP3yLdpW8CQH0Av4cn74h23iTDByvtCY22IkgA8A3np+r759YDU+bg\n8Q1drVbzQrAPsY6sQUQohD928PHDGN4tNWfLrj8DfMQS+Hui4fnkoyOUPQVr\nKgCR\r\n=Ikg1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/src/index.js","readme":"## @balena-io/happy-eyeballs\n\nThis package patches NodeJS's `http(s).Agent` to implement the IETF standard, \"Happy Eyeballs 2\" ([rfc8305](https://datatracker.ietf.org/doc/html/rfc8305)).\n\nIt improves client performance and reliability by trying concurrently trying multiple ip addresses for a given host name. See [Explanation](#explanation) for more detail.\n\n### Installation\n\n```\nnpm i --save-dev @balena/happy-eyeballs\n```\n\n```\nyarn add --dev @balena/happy-eyeballs\n```\n\n\n### Quick Usage\n\nTo use this library, simply import\n\n```ts\nimport '@balena/happy-eyeballs/eye-patch';\n```\n\nor\n\n```js\nrequire('@balena/happy-eyeballs/eye-patch')\n```\n\nto the top of your `.js`/`.ts` entry file.\n\nNote: this will replace `http.Agent.prototype.createConnection` and `https.Agent.prototype.createConnection`, but it tries to preserve existing functionality as much as possible.\n\n### Explicit Usage\n\nIf you want to be more explicit, you can explicitly patch the `http(s).Agent`:\n\n```ts\nimport { patch } from '@balena/eye-patch';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\npatch(HttpAgent, {delay: 300});\npatch(HttpsAgent, {delay: 300});\n```\n\nAlthough, this is exactly what the `import '@balena/happy-eyeballs/eye-patch';` does anyway.\n\nNote that `delay` refers to the delay before attempting the next addresses. This is the delay browsers use.\n\nLater you can unpatch, which will undo the last patch:\n\n```ts\nunpatch([HttpsAgent, HttpAgent])\n```\n\nor reset to the original values of an agent:\n\n```ts\nreset([HttpsAgent, HttpAgent])\n```\n\nAlso, note that the default is `HttpAgent` and `HttpsAgent`, so this has the same effect as\n\n```ts\nreset()\n```\n\nAnd that goes for `patch` and `unpatch` too.\n\nYou could also implement your own agent and replace the `createConnection` method:\n\n```ts\nimport { createConnection } from '@balena/happy-eyeballs';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\nexport class MyHttpAgent extends HttpAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n\nexport class MyHttpsAgent extends HttpsAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n```\n\nThis does basically the same thing as the previous examples though.\n\n### Explanation\n\nEssentially, the algorithm amounts to this:\n\n1. Receive a hostname\n2. Have we connected to this host before?\n  * If yes:\n    * Try the family (Ipv4 or IPv6) of last successful connection if we have connected to this host before\n    * If connection is not successful within 300ms, proceed to next step\n  * If no: proceed to next step.\n3. Did the DNS lookup return both IPv4 and IPv6 addresses?\n  * If yes: try, both addresses concurrently until all have been tried\n  * If no: just try the address of the existent family\n4. Proceed with each address in chain, trying both families concurrently until either:\n  *. A connection is made\n  *. All connection attempts time out\n  *. All connection attempt fail\n5. If no connection was successful, return error of the first connection attempt or a \"time out\" error if all connections timed out\n","gitHead":"baaff909dba17551639f3d40afe37f9f02dac9bd","scripts":{"lint":"balena-lint --typescript src test","test":"npm run build && node -r ts-node/register ./test/cli.ts","build":"tsc","debug":"NODE_DEBUG=@balena/happy-eyeballs-debug npm test","verbose":"NODE_DEBUG=@balena/eye-patch,@balena/happy-eyeballs-debug npm test"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"versionist":{"publishedAt":"2021-11-25T19:51:18.574Z"},"_npmVersion":"6.14.15","description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","directories":{},"_nodeVersion":"14.17.1","dependencies":{"tslib":"^2.3.1","expect":"^27.2.2","abort-controller":"^3.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chalk":"^4.1.2","busboy":"^0.3.1","request":"^2.88.2","ts-node":"^10.2.1","node-fetch":"^2.6.5","typescript":"^4.4.3","@types/node":"^16.10.1","@types/chalk":"^2.2.0","@types/busboy":"^0.2.4","@types/expect":"^24.3.0","@types/request":"^2.48.7","@types/node-fetch":"^2.5.12"},"_npmOperationalInternal":{"tmp":"tmp/happy-eyeballs_0.0.5-add-build-baaff909dba17551639f3d40afe37f9f02dac9bd_1637869974030_0.31100034991214365","host":"s3://npm-registry-packages"}},"0.0.5":{"name":"@balena/happy-eyeballs","version":"0.0.5","keywords":[],"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","_id":"@balena/happy-eyeballs@0.0.5","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"}],"contributors":[{"name":"Miguel Casquiera","email":"miguel@balena.io"}],"homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"dist":{"shasum":"7a6057c29a926232d03a4d5bb9e09e7d7d073277","tarball":"https://registry.npmjs.org/@balena/happy-eyeballs/-/happy-eyeballs-0.0.5.tgz","fileCount":24,"integrity":"sha512-wZG2tiN1qDLLJ6GsT0MAQ2rWmX51Aib3x82wE7zHr7cDap9Pv5cnNtRoLKtJhQ4dlNN8YTR7wPR4o11dsN+oFA==","signatures":[{"sig":"MEUCIDj9MnXBDQcPV4++r4+tCXA1uFpZQz2VAUzVpcgiD5+JAiEAutLcZ7+o7n7CKMwomz7/hUdpdh0QF9so9xQxA2lxY7U=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":44490,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhn+pvCRA9TVsSAnZWagAAvv8P/23sIkKQpArswhaF8loX\n+AVuaoBWJZqFNmJG0bakbqkrZSxuBXjqAQSPR1WatThfCpoq8hx0Vogs1i1p\nxymIPDBx8+RJXJ+gElHd37AXL5murGpoou0VIiA3zXcj9VpcNSlKCcWfGmvE\n/U2O3fZUya6tGnfrSstaHoeTieVMT8OUuJoiWL18nNYwvlwyLkmJ1ZxAHzYC\nMLDI7TYYhTIgymyz0bapw/DJyNgvO6R+TgVxF6+5Blv5qLZ/JZ83a2oOnsAj\np3E8czWeLO0PnyY/93uY+V+Lp+xitZ03Ll4Ju9iFMaAeUFE5ShS8lTDl02dd\nVwHEdblTDqT/ohaGoyPNCa0b0kQhphqfNQRWX7pmC4Zj2BHQErgrVpjw47N1\nlMjh49Yj/h6PoXeprmwQsiGr72Z3+5I/Yb1bpjCP7VRHHhtrdyD58N7bNhSS\nUtxA5TYGlRVeQvQFphZqIUIDvJrrlvPMQjLVTsHka5uasMd+sYClG6Xbc8H1\ntUs7OWAFlfS4OwI8mUWDJ4B3VQ74sY/NF7BtO8G0ESk0HjDfSGJ5myzEjY8Y\nl706hodNdrNv2zN68k987fU+TfaSKWCmDi77StaKykD4JB/bckqtOkrfADOD\nurYXawltTTLI8yeCEB0QaN0v19nh2jdBfSO18dOqqAG1ayycAk84CxUnywOe\nS6/k\r\n=XZl6\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/src/index.js","gitHead":"ddad9074131caa3a3f624eb98158b89883e8d5ab","scripts":{"lint":"balena-lint --typescript src test","test":"npm run build && node -r ts-node/register ./test/cli.ts","build":"tsc","debug":"NODE_DEBUG=@balena/happy-eyeballs-debug npm test","verbose":"NODE_DEBUG=@balena/eye-patch,@balena/happy-eyeballs-debug npm test"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"versionist":{"publishedAt":"2021-11-25T19:54:58.635Z"},"_npmVersion":"6.14.15","description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","directories":{},"_nodeVersion":"14.17.1","dependencies":{"tslib":"^2.3.1","expect":"^27.2.2","abort-controller":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"chalk":"^4.1.2","busboy":"^0.3.1","request":"^2.88.2","ts-node":"^10.2.1","node-fetch":"^2.6.5","typescript":"^4.4.3","@types/node":"^16.10.1","@types/chalk":"^2.2.0","@types/busboy":"^0.2.4","@types/expect":"^24.3.0","@types/request":"^2.48.7","@types/node-fetch":"^2.5.12"},"_npmOperationalInternal":{"tmp":"tmp/happy-eyeballs_0.0.5_1637870191834_0.19937306570961355","host":"s3://npm-registry-packages"}},"0.0.6-package-build-74550418be6d7c21ba65150904f645504b4edbe1":{"name":"@balena/happy-eyeballs","version":"0.0.6-package-build-74550418be6d7c21ba65150904f645504b4edbe1","keywords":[],"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","_id":"@balena/happy-eyeballs@0.0.6-package-build-74550418be6d7c21ba65150904f645504b4edbe1","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"}],"contributors":[{"name":"Miguel Casqueira","email":"miguel@balena.io"}],"homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"dist":{"shasum":"ad269d30ced45baee5336d46025a926c604c27a6","tarball":"https://registry.npmjs.org/@balena/happy-eyeballs/-/happy-eyeballs-0.0.6-package-build-74550418be6d7c21ba65150904f645504b4edbe1.tgz","fileCount":25,"integrity":"sha512-v+7GX2kDL8ronW/3SDfIuXEJnapOp++KJybr2EfDPCbUkKh8xcySXTJ3+7GKrhax971reK4zTP0pOIySNCicww==","signatures":[{"sig":"MEUCIQD1W+lix9lBYjAk8w2XJZkmzMTituCdbiiauWpPeS1NZwIgaYMoGOTigOp1VHMY1ioEgUCQEDX6NjnCF33WV+E5hEY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":45114,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhpi+6CRA9TVsSAnZWagAAzuYP/2SF4JqjyDgV92r4mCCt\nd5fWfexbOtXzJFT1DioPTzLPwfQ0OoStZG4zTvbCZ6oI1iO/pTanYCyMQahD\nGZaTjueDN3B9aO798a00v3UqXJg13ZJjNEcxET48Y8IOh1gXNzfoh1w0RDL7\n1Pr9/FdnrZDrx8p7PMIcLJ8YdGXs6yKn9Pc4pM4KzrUTQcdehin04bezL7SP\nZLuE76Rf/4jCwR7v1jADjOlnWBx85yHlRE+2O+XFaQTzmB2lw92vnOXsiqDW\ncmwhGvA6Q92lbvTLJd/k8B475Vx4BvLSMMr//XuitDPVthjAk98bvGRNFklk\nMVs0USnE6eQsEpqZ+c5ZjK1KmGr4b0BOpm1LUfKm7l0oZ9OgPxsX9Z+3SMMd\n5lQ+EI7wK8XHP4szMcodbh5vekhy0EtTXC5xgqkgBAt+vTewhl6U9+dUr2lg\nXUXZCtXiFrntQLAC2UzLPjC6Al24kzjp/Vvj/Zs391+eZt8dljUROEyFWkT/\nH+YnmiOBTOlY4mz9N7Od5GWZrdAqIQ3w2WmIEK3YePVyya0/dLJY4AmvnxaD\nb1RZ4PVoB+jyFglgPamHgfjkNaYDpwkQwksEMGGhC0PLp4/MGL5y0XhaNw5V\n/gqOAXNoplOKeueOlNq/fWHkBHPs/UzYEPDXiuL2c3AcMDiUbH/o97AcSuTi\nigBI\r\n=gLGU\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/index.js","readme":"## @balena-io/happy-eyeballs\n\nThis package patches NodeJS's `http(s).Agent` to implement the IETF standard, \"Happy Eyeballs 2\" ([rfc8305](https://datatracker.ietf.org/doc/html/rfc8305)).\n\nIt improves client performance and reliability by trying concurrently trying multiple ip addresses for a given host name. See [Explanation](#explanation) for more detail.\n\n### Installation\n\n```\nnpm i --save-dev @balena/happy-eyeballs\n```\n\n```\nyarn add --dev @balena/happy-eyeballs\n```\n\n\n### Quick Usage\n\nTo use this library, simply import\n\n```ts\nimport '@balena/happy-eyeballs/eye-patch';\n```\n\nor\n\n```js\nrequire('@balena/happy-eyeballs/eye-patch')\n```\n\nto the top of your `.js`/`.ts` entry file.\n\nNote: this will replace `http.Agent.prototype.createConnection` and `https.Agent.prototype.createConnection`, but it tries to preserve existing functionality as much as possible.\n\n### Explicit Usage\n\nIf you want to be more explicit, you can explicitly patch the `http(s).Agent`:\n\n```ts\nimport { patch } from '@balena/eye-patch';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\npatch(HttpAgent, {delay: 300});\npatch(HttpsAgent, {delay: 300});\n```\n\nAlthough, this is exactly what the `import '@balena/happy-eyeballs/eye-patch';` does anyway.\n\nNote that `delay` refers to the delay before attempting the next addresses. This is the delay browsers use.\n\nLater you can unpatch, which will undo the last patch:\n\n```ts\nunpatch([HttpsAgent, HttpAgent])\n```\n\nor reset to the original values of an agent:\n\n```ts\nreset([HttpsAgent, HttpAgent])\n```\n\nAlso, note that the default is `HttpAgent` and `HttpsAgent`, so this has the same effect as\n\n```ts\nreset()\n```\n\nAnd that goes for `patch` and `unpatch` too.\n\nYou could also implement your own agent and replace the `createConnection` method:\n\n```ts\nimport { createConnection } from '@balena/happy-eyeballs';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\nexport class MyHttpAgent extends HttpAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n\nexport class MyHttpsAgent extends HttpsAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n```\n\nThis does basically the same thing as the previous examples though.\n\n### Explanation\n\nEssentially, the algorithm amounts to this:\n\n1. Receive a hostname\n2. Have we connected to this host before?\n  * If yes:\n    * Try the family (Ipv4 or IPv6) of last successful connection if we have connected to this host before\n    * If connection is not successful within 300ms, proceed to next step\n  * If no: proceed to next step.\n3. Did the DNS lookup return both IPv4 and IPv6 addresses?\n  * If yes: try, both addresses concurrently until all have been tried\n  * If no: just try the address of the existent family\n4. Proceed with each address in chain, trying both families concurrently until either:\n  *. A connection is made\n  *. All connection attempts time out\n  *. All connection attempt fail\n5. If no connection was successful, return error of the first connection attempt or a \"time out\" error if all connections timed out\n","gitHead":"74550418be6d7c21ba65150904f645504b4edbe1","scripts":{"lint":"balena-lint --typescript src test","test":"npm run build && node -r ts-node/register ./test/cli.ts","build":"npm run clean && tsc --project tsconfig.release.json","clean":"rimraf ./build","debug":"NODE_DEBUG=@balena/happy-eyeballs-debug npm test","verbose":"NODE_DEBUG=@balena/eye-patch,@balena/happy-eyeballs-debug npm test","prepackage":"npm run build"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"versionist":{"publishedAt":"2021-11-30T14:02:01.551Z"},"_npmVersion":"6.14.15","description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","directories":{},"_nodeVersion":"14.17.1","dependencies":{"tslib":"^2.3.1","expect":"^27.2.2","abort-controller":"^3.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chalk":"^4.1.2","busboy":"^0.3.1","rimraf":"^3.0.2","request":"^2.88.2","ts-node":"^10.2.1","node-fetch":"^2.6.5","typescript":"^4.4.3","@types/node":"^16.10.1","@types/chalk":"^2.2.0","@types/busboy":"^0.2.4","@types/expect":"^24.3.0","@types/request":"^2.48.7","@types/node-fetch":"^2.5.12"},"_npmOperationalInternal":{"tmp":"tmp/happy-eyeballs_0.0.6-package-build-74550418be6d7c21ba65150904f645504b4edbe1_1638281146705_0.9620470919088391","host":"s3://npm-registry-packages"}},"0.0.6-package-build-cacfde8ffb2b7bbb10cdc25f3b3cda7db07ef5b2":{"name":"@balena/happy-eyeballs","version":"0.0.6-package-build-cacfde8ffb2b7bbb10cdc25f3b3cda7db07ef5b2","keywords":["balena","typescript","ipv6","happy-eyeballs"],"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","_id":"@balena/happy-eyeballs@0.0.6-package-build-cacfde8ffb2b7bbb10cdc25f3b3cda7db07ef5b2","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"}],"contributors":[{"name":"Miguel Casqueira","email":"miguel@balena.io"}],"homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"dist":{"shasum":"2884139d1ab79b34a7936aba920e3bac0a8fc04a","tarball":"https://registry.npmjs.org/@balena/happy-eyeballs/-/happy-eyeballs-0.0.6-package-build-cacfde8ffb2b7bbb10cdc25f3b3cda7db07ef5b2.tgz","fileCount":3,"integrity":"sha512-n5CiEbyrq+KtuBOEs9oIyEDvT+kcf2pp5hSorqF0NBYm0P1pe2FRpGcPcbcGLi/od07vN2akke60nilIaUlJlQ==","signatures":[{"sig":"MEUCIQCyFH/POeHqvXQg/6RWx8zLC0ljjcSS7enWtBpPJX1qWwIgRR/YRFGmtuMNB9Zxwt09qZIa+a7DIescE5FSfAg+qQ8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5598,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhpjHuCRA9TVsSAnZWagAA9VUP/2pmZAKkRlTv/eZPtDAA\nEjnXNCr/WtOSIrzEdj5d+FDW0hcRUxE4PtSt+MBtvoXwgv1IXaKsvI5e+dyf\nFXlzXipkSlurs/Myw/F/FdmUwRs+Vq30QK41cuPTwbpYObWO+P6mwdNfRKpU\nKK8Q+P/n8OdZy3zWFxEEiPLQ8Rg0D9SGShDmzBkNfCAxKWA0yyl0vSsa0X3f\nab4rkoY4szc21B1KSYS0C6/t6oCos3YFtxA7+NuYa+QmEv3Suau2So0JmcaU\nbA1TrsgwkMwBa1jkOAK/LveZyn/IQYkbpxE007JPeR9F3GfGsC1q9kTEyFFe\nSDR/mKX5JQUwYh8+7YU94nAc6jZpASfi5qaHGgHvRHYVy3IrBwEFS1Jt3mYT\ny3mZ/5CAjQTJug1MWQlhIFVpSgYwQpTjbUE5s+uK2A/icCzpDRrl0gu5t/6F\nJ+OsdTDIqhuhgwRIsiNs1AYkNRb2sakWzYgFSbMWzN/cp/hjeuvVM8kwmTyi\n4gX/RiJHwsmUE0v6UlmXwEs/rSX0qE9UQWV7ApsQADC+gv6jdORJr/FQBaWc\nDnOB1CXWTfYeeLkZljEUe+Svy9zEaqElpnSeCJBRC+6mvzBLdmZ8A+OhzLQl\nQm/3NIrrKiTKOXTvbtaYRUERl3wDYDEAjZBZdEt3nCztmTtQxQIOYbspRiZ9\n+PFO\r\n=n3Yn\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/index.js","readme":"## @balena-io/happy-eyeballs\n\nThis package patches NodeJS's `http(s).Agent` to implement the IETF standard, \"Happy Eyeballs 2\" ([rfc8305](https://datatracker.ietf.org/doc/html/rfc8305)).\n\nIt improves client performance and reliability by trying concurrently trying multiple ip addresses for a given host name. See [Explanation](#explanation) for more detail.\n\n### Installation\n\n```\nnpm i --save-dev @balena/happy-eyeballs\n```\n\n```\nyarn add --dev @balena/happy-eyeballs\n```\n\n\n### Quick Usage\n\nTo use this library, simply import\n\n```ts\nimport '@balena/happy-eyeballs/eye-patch';\n```\n\nor\n\n```js\nrequire('@balena/happy-eyeballs/eye-patch')\n```\n\nto the top of your `.js`/`.ts` entry file.\n\nNote: this will replace `http.Agent.prototype.createConnection` and `https.Agent.prototype.createConnection`, but it tries to preserve existing functionality as much as possible.\n\n### Explicit Usage\n\nIf you want to be more explicit, you can explicitly patch the `http(s).Agent`:\n\n```ts\nimport { patch } from '@balena/eye-patch';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\npatch(HttpAgent, {delay: 300});\npatch(HttpsAgent, {delay: 300});\n```\n\nAlthough, this is exactly what the `import '@balena/happy-eyeballs/eye-patch';` does anyway.\n\nNote that `delay` refers to the delay before attempting the next addresses. This is the delay browsers use.\n\nLater you can unpatch, which will undo the last patch:\n\n```ts\nunpatch([HttpsAgent, HttpAgent])\n```\n\nor reset to the original values of an agent:\n\n```ts\nreset([HttpsAgent, HttpAgent])\n```\n\nAlso, note that the default is `HttpAgent` and `HttpsAgent`, so this has the same effect as\n\n```ts\nreset()\n```\n\nAnd that goes for `patch` and `unpatch` too.\n\nYou could also implement your own agent and replace the `createConnection` method:\n\n```ts\nimport { createConnection } from '@balena/happy-eyeballs';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\nexport class MyHttpAgent extends HttpAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n\nexport class MyHttpsAgent extends HttpsAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n```\n\nThis does basically the same thing as the previous examples though.\n\n### Explanation\n\nEssentially, the algorithm amounts to this:\n\n1. Receive a hostname\n2. Have we connected to this host before?\n  * If yes:\n    * Try the family (Ipv4 or IPv6) of last successful connection if we have connected to this host before\n    * If connection is not successful within 300ms, proceed to next step\n  * If no: proceed to next step.\n3. Did the DNS lookup return both IPv4 and IPv6 addresses?\n  * If yes: try, both addresses concurrently until all have been tried\n  * If no: just try the address of the existent family\n4. Proceed with each address in chain, trying both families concurrently until either:\n  *. A connection is made\n  *. All connection attempts time out\n  *. All connection attempt fail\n5. If no connection was successful, return error of the first connection attempt or a \"time out\" error if all connections timed out\n","gitHead":"cacfde8ffb2b7bbb10cdc25f3b3cda7db07ef5b2","scripts":{"lint":"balena-lint --typescript src test","test":"npm run build && node -r ts-node/register ./test/cli.ts","build":"npm run clean && tsc --project tsconfig.release.json","clean":"rimraf ./build","debug":"NODE_DEBUG=@balena/happy-eyeballs-debug npm test","verbose":"NODE_DEBUG=@balena/eye-patch,@balena/happy-eyeballs-debug npm test","prepackage":"npm run build"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"versionist":{"publishedAt":"2021-11-30T14:13:10.506Z"},"_npmVersion":"6.14.15","description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","directories":{},"_nodeVersion":"14.17.1","dependencies":{"tslib":"^2.3.1","expect":"^27.2.2","abort-controller":"^3.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chalk":"^4.1.2","busboy":"^0.3.1","rimraf":"^3.0.2","request":"^2.88.2","ts-node":"^10.2.1","node-fetch":"^2.6.5","typescript":"^4.4.3","@types/node":"^16.10.1","@types/chalk":"^2.2.0","@types/busboy":"^0.2.4","@types/expect":"^24.3.0","@types/request":"^2.48.7","@types/node-fetch":"^2.5.12"},"_npmOperationalInternal":{"tmp":"tmp/happy-eyeballs_0.0.6-package-build-cacfde8ffb2b7bbb10cdc25f3b3cda7db07ef5b2_1638281709913_0.14833819428953632","host":"s3://npm-registry-packages"}},"0.0.6-package-build-0f1f94a5f02402fc8c81564104cad20efe254bbc":{"name":"@balena/happy-eyeballs","version":"0.0.6-package-build-0f1f94a5f02402fc8c81564104cad20efe254bbc","keywords":["balena","typescript","ipv6","happy-eyeballs"],"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","_id":"@balena/happy-eyeballs@0.0.6-package-build-0f1f94a5f02402fc8c81564104cad20efe254bbc","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"}],"contributors":[{"name":"Miguel Casqueira","email":"miguel@balena.io"}],"homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"dist":{"shasum":"35f5c7d12d4d71a4505f71d20033792de22eacf9","tarball":"https://registry.npmjs.org/@balena/happy-eyeballs/-/happy-eyeballs-0.0.6-package-build-0f1f94a5f02402fc8c81564104cad20efe254bbc.tgz","fileCount":3,"integrity":"sha512-P5wO6z+DbT7Cd23+ao0fnL8M5ugsZptS99rNbKSAICdiwuQhfTZjQMd2ez9zwTQWeRjpVP6/leCeH6N4rrMHLg==","signatures":[{"sig":"MEYCIQC4Gnl2TKLFUHs6hePJpDu+ciVCnVL5mqAovNRUjPGO/QIhAIVqYUcvGPYfrq/oyeDxbH/ik8Y8GgBdyN3S8E75e6ZZ","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5563,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhpjgoCRA9TVsSAnZWagAAhZMP/1a+MOUdJXrqwCcIpyvH\nq9MuJ7vKR+EPmvXrrZeIeSOkyQKXmdXu6OknOKOTS1xT2Q7gSBDSPU+hUf/K\nCKbYTf7kcmJDuI8UjtwdOcPFRGr3MhpvgKLBSBhbr0W6PqDvnoCh6DkMfv8i\n1Vh9V98hvOsuPqPwh15WeklSLxxgNr/hz6w71VEaj4hGoBVQFyDhFhM7RP/Y\nIBXQV7SXGb3Ac3+CjjUP2jnBEOoXfAhnUxYTddLoVbKI02EDC1x8ulpmpQ7E\n/h7ZuUbRAvhrjnQhpPNozSAeDrc42Vt56oAFLD7rVrgz5996GVt3Kgv0Lij5\nXHSK/L9slAd6/XE+aoje7V0mo8RDR+B/49EL5qlzj7aXMkJtXx5p3yJCTYqn\nTt/ysP60rCdlxkly3YPv6t0AfE3JamqlOqHmgXvN4Xbj+r7KY0DhYzoFewS8\ngnaHwxR2B4pPykJpqPlvlPr/fDIooWnoTfxgCtf3yCgdI31BueB6hOdF2A3M\n385VzkA+C20o0ryDG7lmlbUAuPivB2MX40N++T6QREBpTkVNSH/SvwLi8i5p\n2Bd26PxgNrVWgDs51h3F3Ew+mLc6sBF4BxZSObbq/avde3Y3XdK2kQDn3an8\nL55QQV6wTPV4dv8RPM8Z4ylBCvhYS3qWFoDqR9es5YngBLX9PlzG87yioe5+\nYYZ9\r\n=8kjj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/index.js","readme":"## @balena-io/happy-eyeballs\n\nThis package patches NodeJS's `http(s).Agent` to implement the IETF standard, \"Happy Eyeballs 2\" ([rfc8305](https://datatracker.ietf.org/doc/html/rfc8305)).\n\nIt improves client performance and reliability by trying concurrently trying multiple ip addresses for a given host name. See [Explanation](#explanation) for more detail.\n\n### Installation\n\n```\nnpm i --save-dev @balena/happy-eyeballs\n```\n\n```\nyarn add --dev @balena/happy-eyeballs\n```\n\n\n### Quick Usage\n\nTo use this library, simply import\n\n```ts\nimport '@balena/happy-eyeballs/eye-patch';\n```\n\nor\n\n```js\nrequire('@balena/happy-eyeballs/eye-patch')\n```\n\nto the top of your `.js`/`.ts` entry file.\n\nNote: this will replace `http.Agent.prototype.createConnection` and `https.Agent.prototype.createConnection`, but it tries to preserve existing functionality as much as possible.\n\n### Explicit Usage\n\nIf you want to be more explicit, you can explicitly patch the `http(s).Agent`:\n\n```ts\nimport { patch } from '@balena/eye-patch';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\npatch(HttpAgent, {delay: 300});\npatch(HttpsAgent, {delay: 300});\n```\n\nAlthough, this is exactly what the `import '@balena/happy-eyeballs/eye-patch';` does anyway.\n\nNote that `delay` refers to the delay before attempting the next addresses. This is the delay browsers use.\n\nLater you can unpatch, which will undo the last patch:\n\n```ts\nunpatch([HttpsAgent, HttpAgent])\n```\n\nor reset to the original values of an agent:\n\n```ts\nreset([HttpsAgent, HttpAgent])\n```\n\nAlso, note that the default is `HttpAgent` and `HttpsAgent`, so this has the same effect as\n\n```ts\nreset()\n```\n\nAnd that goes for `patch` and `unpatch` too.\n\nYou could also implement your own agent and replace the `createConnection` method:\n\n```ts\nimport { createConnection } from '@balena/happy-eyeballs';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\nexport class MyHttpAgent extends HttpAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n\nexport class MyHttpsAgent extends HttpsAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n```\n\nThis does basically the same thing as the previous examples though.\n\n### Explanation\n\nEssentially, the algorithm amounts to this:\n\n1. Receive a hostname\n2. Have we connected to this host before?\n  * If yes:\n    * Try the family (Ipv4 or IPv6) of last successful connection if we have connected to this host before\n    * If connection is not successful within 300ms, proceed to next step\n  * If no: proceed to next step.\n3. Did the DNS lookup return both IPv4 and IPv6 addresses?\n  * If yes: try, both addresses concurrently until all have been tried\n  * If no: just try the address of the existent family\n4. Proceed with each address in chain, trying both families concurrently until either:\n  *. A connection is made\n  *. All connection attempts time out\n  *. All connection attempt fail\n5. If no connection was successful, return error of the first connection attempt or a \"time out\" error if all connections timed out\n","gitHead":"0f1f94a5f02402fc8c81564104cad20efe254bbc","scripts":{"lint":"balena-lint --typescript src test","test":"npm run build && node -r ts-node/register ./test/cli.ts","build":"npm run clean && tsc --project tsconfig.release.json","clean":"rimraf ./build","debug":"NODE_DEBUG=@balena/happy-eyeballs-debug npm test","verbose":"NODE_DEBUG=@balena/eye-patch,@balena/happy-eyeballs-debug npm test"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"versionist":{"publishedAt":"2021-11-30T14:39:28.629Z"},"_npmVersion":"6.14.15","description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","directories":{},"_nodeVersion":"14.17.1","dependencies":{"tslib":"^2.3.1","expect":"^27.2.2","abort-controller":"^3.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chalk":"^4.1.2","busboy":"^0.3.1","rimraf":"^3.0.2","request":"^2.88.2","ts-node":"^10.2.1","node-fetch":"^2.6.5","typescript":"^4.4.3","@types/node":"^16.10.1","@types/chalk":"^2.2.0","@types/busboy":"^0.2.4","@types/expect":"^24.3.0","@types/request":"^2.48.7","@types/node-fetch":"^2.5.12"},"_npmOperationalInternal":{"tmp":"tmp/happy-eyeballs_0.0.6-package-build-0f1f94a5f02402fc8c81564104cad20efe254bbc_1638283304235_0.9964255238802127","host":"s3://npm-registry-packages"}},"0.0.6-package-build-a554def501c1c94944101917c473d7b8e60a2fb6":{"name":"@balena/happy-eyeballs","version":"0.0.6-package-build-a554def501c1c94944101917c473d7b8e60a2fb6","keywords":["balena","typescript","ipv6","happy-eyeballs"],"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","_id":"@balena/happy-eyeballs@0.0.6-package-build-a554def501c1c94944101917c473d7b8e60a2fb6","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"}],"contributors":[{"name":"Miguel Casqueira","email":"miguel@balena.io"}],"homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"dist":{"shasum":"0d5f19ec8014933a5114fe68b6d032ddf2e4f0db","tarball":"https://registry.npmjs.org/@balena/happy-eyeballs/-/happy-eyeballs-0.0.6-package-build-a554def501c1c94944101917c473d7b8e60a2fb6.tgz","fileCount":24,"integrity":"sha512-JdvoEFP0+UFUcitqaYJfSXp7cZxLp6yzgsqrj7gOX8+GqVPwv+2A7hZzLipn8tZie2cT9FiUAEXty0Emlq4hYw==","signatures":[{"sig":"MEYCIQD0tzA+Wtk0hrsnD5Q6kHDWMM81fOed2InFNirVOeLQWAIhALjDYCisoRbdjMDmQv0YwJ1DmDjbo08gC8Ozj0c2EaWm","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":46874,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhpjtZCRA9TVsSAnZWagAABqAP/2TH/wtpK032fVUnEekA\ncTqcnZlPkBB43QATlaYseYeDWwmhg3cNP/Rc5VLJy//LAFo7afKRE4twHMEY\ndXYbkM0shCpUt07bhMTPM+KhcY1dwx9HdyW2LdURYOQaYa5sQn8PmaKhzDTu\nhyQIKXNaE1gKhcQG6Rfy7nqVtM9UrbRNgF3pSViRBVlVf9IUbuOuIA9mycJJ\nvqFciShaQ9Yzju7U1PzH9MHkkIGLKO/OkkPZNbykIS16a5JKFBWtYFfYr2UX\nsm3ZN0xitK9Z0hJw38t+WkxakJ5BxJSY387yMhOjf6iR8awIYLvbFNn7ZLnC\nCzrH8Ar76xSX5bOmCVF6s4Be5gSldTPDoc0oa3aRCaeHD5bTUl1ZTi5hmo3w\nSMQc7EkidmkluymTavSKhp8iIS1zVkkD9Er7p/aHGZcSpWsT3/65TXJ8bHws\nZ2KjdaBqOhW6le/+Vn8bI0WpyhtAv6V3Sns3aTDSjQ58+ZDfCIOhUH3b128N\ndnpXsNlOhl6nQ+Pzsy/7q8kx6eNscCo8bZ4jKbHRlQ2SVuOsto6M4KXcJ4bh\n1qk10YU83Ax/CLApFqsoBJQeG31Rju2ca5QdZ4VLsc/6tcV+L+bCpEzV1Mng\nMKENxhWZjTtKs1zdwrMgBDMKnNTpVIj/cmyOaWfgY7uR/a/+p6GdA3QtlB8Y\nwaYj\r\n=gtXB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/index.js","readme":"## @balena-io/happy-eyeballs\n\nThis package patches NodeJS's `http(s).Agent` to implement the IETF standard, \"Happy Eyeballs 2\" ([rfc8305](https://datatracker.ietf.org/doc/html/rfc8305)).\n\nIt improves client performance and reliability by trying concurrently trying multiple ip addresses for a given host name. See [Explanation](#explanation) for more detail.\n\n### Installation\n\n```\nnpm i --save-dev @balena/happy-eyeballs\n```\n\n```\nyarn add --dev @balena/happy-eyeballs\n```\n\n\n### Quick Usage\n\nTo use this library, simply import\n\n```ts\nimport '@balena/happy-eyeballs/eye-patch';\n```\n\nor\n\n```js\nrequire('@balena/happy-eyeballs/eye-patch')\n```\n\nto the top of your `.js`/`.ts` entry file.\n\nNote: this will replace `http.Agent.prototype.createConnection` and `https.Agent.prototype.createConnection`, but it tries to preserve existing functionality as much as possible.\n\n### Explicit Usage\n\nIf you want to be more explicit, you can explicitly patch the `http(s).Agent`:\n\n```ts\nimport { patch } from '@balena/eye-patch';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\npatch(HttpAgent, {delay: 300});\npatch(HttpsAgent, {delay: 300});\n```\n\nAlthough, this is exactly what the `import '@balena/happy-eyeballs/eye-patch';` does anyway.\n\nNote that `delay` refers to the delay before attempting the next addresses. This is the delay browsers use.\n\nLater you can unpatch, which will undo the last patch:\n\n```ts\nunpatch([HttpsAgent, HttpAgent])\n```\n\nor reset to the original values of an agent:\n\n```ts\nreset([HttpsAgent, HttpAgent])\n```\n\nAlso, note that the default is `HttpAgent` and `HttpsAgent`, so this has the same effect as\n\n```ts\nreset()\n```\n\nAnd that goes for `patch` and `unpatch` too.\n\nYou could also implement your own agent and replace the `createConnection` method:\n\n```ts\nimport { createConnection } from '@balena/happy-eyeballs';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\nexport class MyHttpAgent extends HttpAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n\nexport class MyHttpsAgent extends HttpsAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n```\n\nThis does basically the same thing as the previous examples though.\n\n### Explanation\n\nEssentially, the algorithm amounts to this:\n\n1. Receive a hostname\n2. Have we connected to this host before?\n  * If yes:\n    * Try the family (Ipv4 or IPv6) of last successful connection if we have connected to this host before\n    * If connection is not successful within 300ms, proceed to next step\n  * If no: proceed to next step.\n3. Did the DNS lookup return both IPv4 and IPv6 addresses?\n  * If yes: try, both addresses concurrently until all have been tried\n  * If no: just try the address of the existent family\n4. Proceed with each address in chain, trying both families concurrently until either:\n  *. A connection is made\n  *. All connection attempts time out\n  *. All connection attempt fail\n5. If no connection was successful, return error of the first connection attempt or a \"time out\" error if all connections timed out\n","gitHead":"a554def501c1c94944101917c473d7b8e60a2fb6","scripts":{"lint":"balena-lint --typescript src test","test":"npm run build && node -r ts-node/register ./test/cli.ts","build":"npm run clean && tsc --project tsconfig.release.json","clean":"rimraf ./build","debug":"NODE_DEBUG=@balena/happy-eyeballs-debug npm test","prepack":"npm run build","verbose":"NODE_DEBUG=@balena/eye-patch,@balena/happy-eyeballs-debug npm test"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"versionist":{"publishedAt":"2021-11-30T14:53:08.465Z"},"_npmVersion":"6.14.15","description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","directories":{},"_nodeVersion":"14.17.1","dependencies":{"tslib":"^2.3.1","abort-controller":"^3.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chalk":"^4.1.2","busboy":"^0.3.1","expect":"27.4.2","rimraf":"^3.0.2","request":"^2.88.2","ts-node":"^10.2.1","node-fetch":"^2.6.5","typescript":"^4.4.3","@types/node":"^16.10.1","@types/chalk":"^2.2.0","@types/busboy":"^0.2.4","@types/expect":"^24.3.0","@types/request":"^2.48.7","@types/node-fetch":"^2.5.12"},"_npmOperationalInternal":{"tmp":"tmp/happy-eyeballs_0.0.6-package-build-a554def501c1c94944101917c473d7b8e60a2fb6_1638284121719_0.49200296945102395","host":"s3://npm-registry-packages"}},"0.0.6-package-build-3cc0eb6f13ac1fc755cf10a0fc940ade1b606e32":{"name":"@balena/happy-eyeballs","version":"0.0.6-package-build-3cc0eb6f13ac1fc755cf10a0fc940ade1b606e32","keywords":["balena","typescript","ipv6","happy-eyeballs"],"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","_id":"@balena/happy-eyeballs@0.0.6-package-build-3cc0eb6f13ac1fc755cf10a0fc940ade1b606e32","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"}],"contributors":[{"name":"Miguel Casqueira","email":"miguel@balena.io"}],"homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"dist":{"shasum":"fbc56ab6048d2b4e174b0a091870e36e55cdf36e","tarball":"https://registry.npmjs.org/@balena/happy-eyeballs/-/happy-eyeballs-0.0.6-package-build-3cc0eb6f13ac1fc755cf10a0fc940ade1b606e32.tgz","fileCount":26,"integrity":"sha512-+rIhkEtnDnA4ZyDnqyTa7vlQZ7M6dazeLs3A0O1WVsKY8tbGgmyQBodNU2Opv0ZMTgMx6EmbuoYp1Cz5CO881g==","signatures":[{"sig":"MEYCIQDRCY2FoD5eZlqasHlKIsuDt69Z8jUcay0vq7bIVEAdTAIhAO+2ccxqraCY5123sanzogZi1beTTAKW6THp/LolTvZH","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":47012,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhpj78CRA9TVsSAnZWagAAB9gP/1QX2KA1MU7oPDePu7Qu\n1+sZTr5iaBTg9br1bHW8CEDvEQVGSvCtPwPIsdjikaBWqah2rvMlkFq8Jhnw\n7h29oy42I/HzlxAQvZkFmwv/mbftwCJrIrvjqfXwsI/RFbx6iAabh3FK5uNS\n7fVvYzGRseVJbPQ8m31Npf2NO23lsH6CW+K7MewWkggVTZzXGJNI1jRQjFnY\nvrPlE4NWI9Pv1otz4AoApFyspXsgD6JvdiY3HPuFp39pGAmJNYE19ttIO0KN\nxGobEsZvokwZQFzztysK47ozQgfqbCjAGMBhn1sHyR7l/gNd4yI8l8SV+uQW\nsBL0hODUsdLyIfnqh4Q1bsHNyo4e/e4SfEDW+aL0cNtP+HQgOFULv3y1ST6h\nAJlDu/W1Hr0adD0sUv1DN1JQXEpmBCzYI+gppwGmT8tweWLzIfroCKkYK72F\nnSs5cJVrpFirwi38UsuyY1Z1sZnwwPJw3jffJHpuchlCPCKr1aOoYgfpIXhz\nUIcoolvqeZOiB8jPEgKiEVOnRYZIO+oWoY1qO7EEbnVgs2cw7kG40OLZZ9wP\nAit6G8CdhUnBaJi1HS6Uw/BgVNd5dTxuYzXIpSx3NvmmhNZer2lFATJYdzYv\njd31B0Ly4dBUzXtlvI/+gcda0dCG53idLBuL8RalEj3twBzcjuwIAG1LTfF7\nZJEl\r\n=hKKR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/index.js","readme":"## @balena-io/happy-eyeballs\n\nThis package patches NodeJS's `http(s).Agent` to implement the IETF standard, \"Happy Eyeballs 2\" ([rfc8305](https://datatracker.ietf.org/doc/html/rfc8305)).\n\nIt improves client performance and reliability by trying concurrently trying multiple ip addresses for a given host name. See [Explanation](#explanation) for more detail.\n\n### Installation\n\n```\nnpm i --save-dev @balena/happy-eyeballs\n```\n\n```\nyarn add --dev @balena/happy-eyeballs\n```\n\n\n### Quick Usage\n\nTo use this library, simply import\n\n```ts\nimport '@balena/happy-eyeballs/eye-patch';\n```\n\nor\n\n```js\nrequire('@balena/happy-eyeballs/eye-patch')\n```\n\nto the top of your `.js`/`.ts` entry file.\n\nNote: this will replace `http.Agent.prototype.createConnection` and `https.Agent.prototype.createConnection`, but it tries to preserve existing functionality as much as possible.\n\n### Explicit Usage\n\nIf you want to be more explicit, you can explicitly patch the `http(s).Agent`:\n\n```ts\nimport { patch } from '@balena/eye-patch';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\npatch(HttpAgent, {delay: 300});\npatch(HttpsAgent, {delay: 300});\n```\n\nAlthough, this is exactly what the `import '@balena/happy-eyeballs/eye-patch';` does anyway.\n\nNote that `delay` refers to the delay before attempting the next addresses. This is the delay browsers use.\n\nLater you can unpatch, which will undo the last patch:\n\n```ts\nunpatch([HttpsAgent, HttpAgent])\n```\n\nor reset to the original values of an agent:\n\n```ts\nreset([HttpsAgent, HttpAgent])\n```\n\nAlso, note that the default is `HttpAgent` and `HttpsAgent`, so this has the same effect as\n\n```ts\nreset()\n```\n\nAnd that goes for `patch` and `unpatch` too.\n\nYou could also implement your own agent and replace the `createConnection` method:\n\n```ts\nimport { createConnection } from '@balena/happy-eyeballs';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\nexport class MyHttpAgent extends HttpAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n\nexport class MyHttpsAgent extends HttpsAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n```\n\nThis does basically the same thing as the previous examples though.\n\n### Explanation\n\nEssentially, the algorithm amounts to this:\n\n1. Receive a hostname\n2. Have we connected to this host before?\n  * If yes:\n    * Try the family (Ipv4 or IPv6) of last successful connection if we have connected to this host before\n    * If connection is not successful within 300ms, proceed to next step\n  * If no: proceed to next step.\n3. Did the DNS lookup return both IPv4 and IPv6 addresses?\n  * If yes: try, both addresses concurrently until all have been tried\n  * If no: just try the address of the existent family\n4. Proceed with each address in chain, trying both families concurrently until either:\n  *. A connection is made\n  *. All connection attempts time out\n  *. All connection attempt fail\n5. If no connection was successful, return error of the first connection attempt or a \"time out\" error if all connections timed out\n","gitHead":"3cc0eb6f13ac1fc755cf10a0fc940ade1b606e32","scripts":{"lint":"balena-lint --typescript src test","test":"npm run build && node -r ts-node/register ./test/cli.ts","build":"npm run clean && tsc --project tsconfig.release.json","clean":"rimraf ./build","debug":"NODE_DEBUG=@balena/happy-eyeballs-debug npm test","prepack":"npm run build","verbose":"NODE_DEBUG=@balena/eye-patch,@balena/happy-eyeballs-debug npm test"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"versionist":{"publishedAt":"2021-11-30T15:09:14.295Z"},"_npmVersion":"6.14.15","description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","directories":{},"_nodeVersion":"14.17.1","dependencies":{"tslib":"^2.3.1","abort-controller":"^3.0.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chalk":"^4.1.2","busboy":"^0.3.1","expect":"27.4.2","rimraf":"^3.0.2","request":"^2.88.2","ts-node":"^10.2.1","node-fetch":"^2.6.5","typescript":"^4.4.3","@types/node":"^16.10.1","@types/chalk":"^2.2.0","@types/busboy":"^0.2.4","@types/expect":"^24.3.0","@types/request":"^2.48.7","@types/node-fetch":"^2.5.12"},"_npmOperationalInternal":{"tmp":"tmp/happy-eyeballs_0.0.6-package-build-3cc0eb6f13ac1fc755cf10a0fc940ade1b606e32_1638285052314_0.8254701680218306","host":"s3://npm-registry-packages"}},"0.0.6":{"name":"@balena/happy-eyeballs","version":"0.0.6","keywords":["balena","typescript","ipv6","happy-eyeballs"],"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","_id":"@balena/happy-eyeballs@0.0.6","maintainers":[{"name":"balena.io","email":"accounts+npm@balena.io"}],"contributors":[{"name":"Miguel Casqueira","email":"miguel@balena.io"}],"homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"dist":{"shasum":"81a043bba5c520f8e171b670125301caa04db4f8","tarball":"https://registry.npmjs.org/@balena/happy-eyeballs/-/happy-eyeballs-0.0.6.tgz","fileCount":26,"integrity":"sha512-aT/m3q5fB+EwpqaFgbO42E4JTIAETvO4judob4UHUivq+xdB5KIXkG+NfG6LpFh/SWzxqqpiDNnmi6zF4lPO+g==","signatures":[{"sig":"MEUCIQCUQFbslrFcT7KWKtYVX9c/04yxpFe6WyH+VJAT4AhRMQIgPK8ekTnLpyEDTpWt6Z/LKu11+DnsMXRDLtdxj6vwiLA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":46957,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhpl/iCRA9TVsSAnZWagAAP70P/ibZ7Dmfo8vi7cu2KC0l\ntwmQjx33YAySrdbLOeVkJLQvJCIGe6Nl5cAdDSyPqgJr63Ej+Kq/fRDF4IvC\nPBFYrarQzo0lbhIprWW6piD1Ycyfb/Y/rAG6k7ElSUW4rdtNHY8YVbJBuymA\nIW8xZfmzGDVX8HMqaC6WHR03gdIXmnzrfzEx9uH43RcsNemk47lPZQraIl28\nd/31hr2QCsPP2lS1vzMWBCaY8EYMr6jO+oIseznuBpycOOh+/BZCZ1GfnhaL\nbXtQlbMVDzgMA/0yWpoHaPneS0XHwrQdiedAi2G+nt3KP4HVRdme9Ufg52ap\nmOroBjxafBLOyrnbeDRYB2fEjguENdTLt8dTsqOIsPc83DaU2HuPP+KtKT8t\nlXnYd0CeY4AVjyLWpVzfCAkXVeHpucqPpZgWRPHZdCAo1OQ8/eERcjjCTaxo\nT+fiNkTFRSBHLG7jexWNik2c0yeb6f75EgImBBPdclII5N/sFbgSdJzKQowZ\n9Oz8HamKxwIe7etkhbRNpwJAt/OJ23AYIKVjXjI+0pPoEW63vhoIehwFVd17\nyx4G/sfEbuc5WetfEmYCw20YZf2j8lUrbF/sa42P2HaEvZpDjaqJwppNx7MX\n5wllGf6U9qA2HsuiWkAiNMq9ofFWV0zz422tR0yjgyBQ7Pyu6qUwRTbgtaba\naTMH\r\n=0XVM\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/index.js","gitHead":"bb52d71c9d04a4f46c8d48cbdd82ddfdf0aaf43b","scripts":{"lint":"balena-lint --typescript src test","test":"npm run build && node -r ts-node/register ./test/cli.ts","build":"npm run clean && tsc --project tsconfig.release.json","clean":"rimraf ./build","debug":"NODE_DEBUG=@balena/happy-eyeballs-debug npm test","prepack":"npm run build","verbose":"NODE_DEBUG=@balena/eye-patch,@balena/happy-eyeballs-debug npm test"},"_npmUser":{"name":"balena.io","email":"accounts+npm@balena.io"},"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"versionist":{"publishedAt":"2021-11-30T17:29:36.513Z"},"_npmVersion":"6.14.15","description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","directories":{},"_nodeVersion":"14.17.1","dependencies":{"tslib":"^2.3.1","abort-controller":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"chalk":"^4.1.2","busboy":"^0.3.1","expect":"27.4.2","rimraf":"^3.0.2","request":"^2.88.2","ts-node":"^10.2.1","node-fetch":"^2.6.5","typescript":"^4.4.3","@types/node":"^16.10.1","@types/chalk":"^2.2.0","@types/busboy":"^0.2.4","@types/expect":"^24.3.0","@types/request":"^2.48.7","@types/node-fetch":"^2.5.12"},"_npmOperationalInternal":{"tmp":"tmp/happy-eyeballs_0.0.6_1638293474018_0.6230275748200973","host":"s3://npm-registry-packages"}}},"time":{"created":"2021-11-18T14:14:14.445Z","modified":"2026-01-20T12:07:41.326Z","0.0.2-publish-branch-b39fcca26175a6cae085e11c0ec8f4e1a06b7ac8":"2021-11-18T14:14:14.674Z","0.0.2":"2021-11-18T14:25:43.327Z","0.0.2-publish-branch-8c4d939d95e89e44f3e047e1e3422da64debefaa":"2021-11-18T14:32:49.236Z","0.0.3-publish-branch-64714e661bd5f264b748d29b7260ba1249112e50":"2021-11-18T16:54:32.548Z","0.0.3-publish-branch-35111c93f010c1452cfe1d29dcba92392a28c704":"2021-11-18T16:58:16.147Z","0.0.3-publish-branch-d49c505fc5cbf426489d1386033198a6c692d26a":"2021-11-18T17:04:24.567Z","0.0.3-publish-branch-003c1a3a8065aa4c2230d8b11336c8808cf0a2e3":"2021-11-18T17:07:58.062Z","0.0.3-publish-branch-2f8369f60c344ff9203ffa2f6a749f338eb010ce":"2021-11-18T17:11:55.853Z","0.0.3":"2021-11-18T17:18:46.764Z","0.0.4-remove-10-af45038cdeda3eeec8fee1da75b36e0bd2f41bcc":"2021-11-25T19:31:09.698Z","0.0.4":"2021-11-25T19:36:05.084Z","0.0.5-add-build-baaff909dba17551639f3d40afe37f9f02dac9bd":"2021-11-25T19:52:54.182Z","0.0.5":"2021-11-25T19:56:31.984Z","0.0.6-package-build-74550418be6d7c21ba65150904f645504b4edbe1":"2021-11-30T14:05:46.882Z","0.0.6-package-build-cacfde8ffb2b7bbb10cdc25f3b3cda7db07ef5b2":"2021-11-30T14:15:10.059Z","0.0.6-package-build-0f1f94a5f02402fc8c81564104cad20efe254bbc":"2021-11-30T14:41:44.420Z","0.0.6-package-build-a554def501c1c94944101917c473d7b8e60a2fb6":"2021-11-30T14:55:21.851Z","0.0.6-package-build-3cc0eb6f13ac1fc755cf10a0fc940ade1b606e32":"2021-11-30T15:10:52.512Z","0.0.6":"2021-11-30T17:31:14.387Z"},"bugs":{"url":"https://github.com/balena-io-modules/happy-eyeballs/issues"},"author":{"name":"Zane Hitchcox","email":"zane@balena.io"},"license":"ISC","homepage":"https://github.com/balena-io-modules/happy-eyeballs#readme","keywords":["balena","typescript","ipv6","happy-eyeballs"],"repository":{"url":"git+https://github.com/balena-io-modules/happy-eyeballs.git","type":"git"},"description":"patches http(s).Agent to implement happy eyeballs 2 (rfc8305), a standard published by the IETF","contributors":[{"name":"Miguel Casqueira","email":"miguel@balena.io"}],"maintainers":[{"email":"accounts+npm@balena.io","name":"balena.io"},{"email":"page@balena.io","name":"page"}],"readme":"## @balena-io/happy-eyeballs\n\nThis package patches NodeJS's `http(s).Agent` to implement the IETF standard, \"Happy Eyeballs 2\" ([rfc8305](https://datatracker.ietf.org/doc/html/rfc8305)).\n\nIt improves client performance and reliability by trying concurrently trying multiple ip addresses for a given host name. See [Explanation](#explanation) for more detail.\n\n### Installation\n\n```\nnpm i --save-dev @balena/happy-eyeballs\n```\n\n```\nyarn add --dev @balena/happy-eyeballs\n```\n\n\n### Quick Usage\n\nTo use this library, simply import\n\n```ts\nimport '@balena/happy-eyeballs/eye-patch';\n```\n\nor\n\n```js\nrequire('@balena/happy-eyeballs/eye-patch')\n```\n\nto the top of your `.js`/`.ts` entry file.\n\nNote: this will replace `http.Agent.prototype.createConnection` and `https.Agent.prototype.createConnection`, but it tries to preserve existing functionality as much as possible.\n\n### Explicit Usage\n\nIf you want to be more explicit, you can explicitly patch the `http(s).Agent`:\n\n```ts\nimport { patch } from '@balena/eye-patch';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\npatch(HttpAgent, {delay: 300});\npatch(HttpsAgent, {delay: 300});\n```\n\nAlthough, this is exactly what the `import '@balena/happy-eyeballs/eye-patch';` does anyway.\n\nNote that `delay` refers to the delay before attempting the next addresses. This is the delay browsers use.\n\nLater you can unpatch, which will undo the last patch:\n\n```ts\nunpatch([HttpsAgent, HttpAgent])\n```\n\nor reset to the original values of an agent:\n\n```ts\nreset([HttpsAgent, HttpAgent])\n```\n\nAlso, note that the default is `HttpAgent` and `HttpsAgent`, so this has the same effect as\n\n```ts\nreset()\n```\n\nAnd that goes for `patch` and `unpatch` too.\n\nYou could also implement your own agent and replace the `createConnection` method:\n\n```ts\nimport { createConnection } from '@balena/happy-eyeballs';\nimport { Agent as HttpAgent } from 'http';\nimport { Agent as HttpsAgent } from 'https';\n\nexport class MyHttpAgent extends HttpAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n\nexport class MyHttpsAgent extends HttpsAgent {\n  createConnection = createConnection;\n  delay = 250;\n}\n```\n\nThis does basically the same thing as the previous examples though.\n\n### Explanation\n\nEssentially, the algorithm amounts to this:\n\n1. Receive a hostname\n2. Have we connected to this host before?\n  * If yes:\n    * Try the family (Ipv4 or IPv6) of last successful connection if we have connected to this host before\n    * If connection is not successful within 300ms, proceed to next step\n  * If no: proceed to next step.\n3. Did the DNS lookup return both IPv4 and IPv6 addresses?\n  * If yes: try, both addresses concurrently until all have been tried\n  * If no: just try the address of the existent family\n4. Proceed with each address in chain, trying both families concurrently until either:\n  *. A connection is made\n  *. All connection attempts time out\n  *. All connection attempt fail\n5. If no connection was successful, return error of the first connection attempt or a \"time out\" error if all connections timed out\n","readmeFilename":"README.md"}