{"_id":"lookup-dns-cache","_rev":"6-df9d91a4089057ea0ef812d432db63f8","name":"lookup-dns-cache","description":"An implementation to speed up the nodejs `dns.lookup` method by avoiding thread pool and using resolve4/resolve6 with DNS TTL values","dist-tags":{"latest":"2.1.0"},"versions":{"1.0.0":{"name":"lookup-dns-cache","version":"1.0.0","description":"An implementation to speed up the nodejs `dns.lookup` method by avoiding thread pool and using resolve4/resolve6 with DNS TTL values","main":"index.js","scripts":{"test":"./node_modules/mocha/bin/mocha --recursive tests"},"dependencies":{"async":"^2.6.0","global":"^4.3.2","lodash":"^4.17.4","rr":"^0.1.0"},"devDependencies":{"chai":"^4.1.2","mocha":"^4.1.0","prettier":"^1.9.2","proxyquire":"^1.8.0","sinon":"^4.1.4"},"author":{"name":"Eduard","email":"eduardbcom@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/eduardbcom/lookup-dns-cache.git"},"keywords":["dns","lookup","resolve4","resolve6","cache","ipv4","ipv6"],"homepage":"https://github.com/eduardbcom/lookup-dns-cache","license":"MIT","gitHead":"9bdae0428e8cf558c90799df877e4ad9121f0286","bugs":{"url":"https://github.com/eduardbcom/lookup-dns-cache/issues"},"_id":"lookup-dns-cache@1.0.0","_npmVersion":"5.5.1","_nodeVersion":"9.3.0","_npmUser":{"name":"eduardbcom","email":"eduardbcom@gmail.com"},"dist":{"integrity":"sha512-dmHsGJBIG1tmvB3+5VCnycmJeXbJ1ZOLb9EEyrRJYWfft/Sy6g3mBbXezdeIpfAZliuKXMvuatkBw9Sz/qkarA==","shasum":"67e57fa503d438fafa3cafe9005fc5ae47c5179f","tarball":"https://registry.npmjs.org/lookup-dns-cache/-/lookup-dns-cache-1.0.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC0h3Az6dyWZ+eOHSEnlJQkLAT7IJO6OvTCaDrFB3yCYwIhANWkxzk8KyjqfpgQCgw/OJDaKNXoU6K0OVEmm7JSUfcW"}]},"maintainers":[{"name":"eduardbcom","email":"eduardbcom@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lookup-dns-cache-1.0.0.tgz_1515567507084_0.13188072782941163"},"directories":{}},"1.0.1":{"name":"lookup-dns-cache","version":"1.0.1","description":"An implementation to speed up the nodejs `dns.lookup` method by avoiding thread pool and using resolve4/resolve6 with DNS TTL values","main":"index.js","engines":{"node":">=6.0"},"scripts":{"prettier":"prettier --single-quote --tab-width 4 --write \"**/*.js\"","lint":"eslint ./","test":"NODE_ENV=test ./node_modules/.bin/mocha --opts tests/mocha.opts -R spec ./tests","test:coverage":"NODE_ENV=test ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --print both -- --opts tests/mocha.opts -R spec ./tests"},"dependencies":{"async":"2.6.0","lodash":"4.17.4","rr":"0.1.0"},"devDependencies":{"chai":"4.1.2","eslint":"4.15.0","istanbul":"0.4.5","mocha":"4.1.0","prettier":"1.9.2","proxyquire":"1.8.0","sinon":"4.1.4"},"author":{"name":"Eduard","email":"eduardbcom@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/eduardbcom/lookup-dns-cache.git"},"keywords":["dns","lookup","resolve4","resolve6","cache","ipv4","ipv6"],"homepage":"https://github.com/eduardbcom/lookup-dns-cache","license":"MIT","gitHead":"ecf29a994c1b27fcb0441c475ba8e457e910317c","bugs":{"url":"https://github.com/eduardbcom/lookup-dns-cache/issues"},"_id":"lookup-dns-cache@1.0.1","_npmVersion":"5.5.1","_nodeVersion":"9.3.0","_npmUser":{"name":"eduardbcom","email":"eduardbcom@gmail.com"},"dist":{"integrity":"sha512-RuVcdnuhawn0fLWOhNaOpaKAdco35gkM81WmRysL2wO74ChercK1oVOC84MsCKg910FM1qSTMOTplEPn3iQ+IA==","shasum":"02aba1be8718cf52488e8f2e0cce642c5d5633be","tarball":"https://registry.npmjs.org/lookup-dns-cache/-/lookup-dns-cache-1.0.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDfZUcZ2cqLzkAOb5FxRWHDdCJN0VFM0Kve6e3i5QFiMQIgUv1AV3XBaJzrbRQDh91FCpqpNEH/Dhgn5k4f2RJ79EA="}]},"maintainers":[{"name":"eduardbcom","email":"eduardbcom@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lookup-dns-cache-1.0.1.tgz_1515658359643_0.9248066095169634"},"directories":{}},"1.1.0":{"name":"lookup-dns-cache","version":"1.1.0","description":"An implementation to speed up the nodejs `dns.lookup` method by avoiding thread pool and using resolve4/resolve6 with DNS TTL values","main":"index.js","engines":{"node":">=6.0"},"scripts":{"prettier":"prettier --single-quote --tab-width 4 --write \"**/*.js\"","lint":"eslint ./","test":"NODE_ENV=test ./node_modules/.bin/mocha --opts tests/mocha.opts -R spec ./tests/**","test:coverage":"NODE_ENV=test ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --print both -- --opts tests/mocha.opts -R spec ./tests"},"dependencies":{"async":"2.6.0","lodash":"4.17.4","rr":"0.1.0"},"devDependencies":{"chai":"4.1.2","eslint":"4.15.0","istanbul":"0.4.5","mocha":"4.1.0","prettier":"1.9.2","proxyquire":"1.8.0","sinon":"4.1.4"},"author":{"name":"Eduard","email":"eduardbcom@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/eduardbcom/lookup-dns-cache.git"},"keywords":["dns","lookup","resolve4","resolve6","cache","ipv4","ipv6"],"homepage":"https://github.com/eduardbcom/lookup-dns-cache","license":"MIT","gitHead":"17ca6e43bf0c6c784ece5779ea71f83eb94d48e4","bugs":{"url":"https://github.com/eduardbcom/lookup-dns-cache/issues"},"_id":"lookup-dns-cache@1.1.0","_npmVersion":"5.5.1","_nodeVersion":"9.3.0","_npmUser":{"name":"eduardbcom","email":"eduardbcom@gmail.com"},"dist":{"integrity":"sha512-KCgOoZZIkSIuphYJzKHbpo1NnFlnpHG86sphZ1Hp+uuaGP5bGIYuSV0b2yKDZ9KaPq5yeQgw0tIN1+PrTqWOaQ==","shasum":"747eb113972169f0a1611e45ea8f0ab42f3536ad","tarball":"https://registry.npmjs.org/lookup-dns-cache/-/lookup-dns-cache-1.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC+4dY98s0At7YTYEmvN0KCUUtVi7Jkm4ASa+Uft4hOxAiASb9v6VUhkMe1+ESplvPatMi1PI+lBD+WpOMzjHRgMPQ=="}]},"maintainers":[{"name":"eduardbcom","email":"eduardbcom@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lookup-dns-cache-1.1.0.tgz_1515682295204_0.2123629618436098"},"directories":{}},"2.0.0":{"name":"lookup-dns-cache","version":"2.0.0","description":"An implementation to speed up the nodejs `dns.lookup` method by avoiding thread pool and using resolve4/resolve6 with DNS TTL values","main":"index.js","engines":{"node":">=6.0"},"scripts":{"prettier":"prettier --single-quote --tab-width 4 --write \"**/*.js\"","lint":"eslint ./","test":"yarn run unit-test && yarn run func-test","unit-test":"NODE_ENV=test ./node_modules/.bin/mocha --opts tests/mocha.opts -R spec ./tests/Unit/**","func-test":"NODE_ENV=test ./node_modules/.bin/mocha --opts tests/mocha.opts --timeout 15000 -R spec ./tests/Functional/**","test:coverage":"NODE_ENV=test ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --print both -- --opts tests/mocha.opts -R spec ./tests"},"dependencies":{"async":"2.6.0","lodash":"4.17.4","rr":"0.1.0"},"devDependencies":{"chai":"4.1.2","eslint":"4.15.0","istanbul":"0.4.5","mocha":"4.1.0","prettier":"1.9.2","proxyquire":"1.8.0","sinon":"4.1.4"},"author":{"name":"Eduard","email":"eduardbcom@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/eduardbcom/lookup-dns-cache.git"},"keywords":["dns","lookup","resolve4","resolve6","cache","ipv4","ipv6"],"homepage":"https://github.com/eduardbcom/lookup-dns-cache","license":"MIT","gitHead":"35ad4c8953ea5b5ec3139fb3e303431a92f7d691","bugs":{"url":"https://github.com/eduardbcom/lookup-dns-cache/issues"},"_id":"lookup-dns-cache@2.0.0","_npmVersion":"5.5.1","_nodeVersion":"9.3.0","_npmUser":{"name":"eduardbcom","email":"eduardbcom@gmail.com"},"dist":{"integrity":"sha512-O/Kz1J1iCdDXQetbqoDmAgXlfwXfgCV/g40V9fGoQC7X4MXRETYqzv2n1HNgpHvdHewxIbIpkHTk2PRum4LBcA==","shasum":"5acbcdbcb87f2a43bde1f282c8e665cb1f8223f2","tarball":"https://registry.npmjs.org/lookup-dns-cache/-/lookup-dns-cache-2.0.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDgyCNK6tQiOp3wJJVXsqtJ/5U+C3Al+31bAqXBgfvePAiBZxFeENy3Q3ZhEAG43MmMNhp5Zotr5YPjAkzJY94cVKg=="}]},"maintainers":[{"name":"eduardbcom","email":"eduardbcom@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lookup-dns-cache-2.0.0.tgz_1516117700185_0.0569389380980283"},"directories":{}},"2.0.1":{"name":"lookup-dns-cache","version":"2.0.1","description":"An implementation to speed up the nodejs `dns.lookup` method by avoiding thread pool and using resolve4/resolve6 with DNS TTL values","main":"index.js","engines":{"node":">=6.0"},"scripts":{"prettier":"prettier --single-quote --tab-width 4 --write \"**/*.js\"","lint":"eslint ./","test":"yarn run unit-test && yarn run func-test","unit-test":"NODE_ENV=test ./node_modules/.bin/mocha --opts tests/mocha.opts -R spec ./tests/Unit/**","func-test":"NODE_ENV=test ./node_modules/.bin/mocha --opts tests/mocha.opts --timeout 15000 -R spec ./tests/Functional/**","test:coverage":"NODE_ENV=test ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --print both -- --opts tests/mocha.opts -R spec ./tests"},"dependencies":{"async":"2.6.0","lodash":"^4.17.10","rr":"0.1.0"},"devDependencies":{"chai":"4.1.2","eslint":"4.15.0","istanbul":"0.4.5","mocha":"4.1.0","prettier":"1.9.2","proxyquire":"1.8.0","sinon":"4.1.4"},"author":{"name":"Eduard","email":"eduardbcom@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/eduardbcom/lookup-dns-cache.git"},"keywords":["dns","lookup","resolve4","resolve6","cache","ipv4","ipv6"],"homepage":"https://github.com/eduardbcom/lookup-dns-cache","license":"MIT","gitHead":"640baf0d5d38e3b409ecdddbc88fffa8cc3381c0","bugs":{"url":"https://github.com/eduardbcom/lookup-dns-cache/issues"},"_id":"lookup-dns-cache@2.0.1","_npmVersion":"6.1.0","_nodeVersion":"9.10.1","_npmUser":{"name":"eduardbcom","email":"eduardbcom@gmail.com"},"dist":{"integrity":"sha512-9HsfLYnnMp8NyCEJ0OHj3WIkcL/QFuxK1qimNWtnPcQG6aeGqi470hBGg4kGRF4HRk0e5GraWoGsEpHEDX6ing==","shasum":"611961360dacd83a27c2d1678f98052c3067d37c","tarball":"https://registry.npmjs.org/lookup-dns-cache/-/lookup-dns-cache-2.0.1.tgz","fileCount":31,"unpackedSize":126166,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbPModCRA9TVsSAnZWagAA5/YP/AnRqi8TBMnAJ0rCiCs8\nBSq1VW936qvLCgbobnqODnD51zFg9H5ir9+qFOv84ijTTGKTDSKCoPxLH+48\nQ2mENVig9dKHQa7L8wnd3cL31Gpz/kn5PnshhLJ3ub3dgXDrqMC7caG68bH1\nErVEShaApRrSLk2gJdLDL4wn8Ny8qZ7W4W/es3dlIrtBH/sXZF4A9GKROrVR\npoaga5nfVJUXpSH1ow+OYDs8z91KTfGoNocRlpkt3R0KYGByqFIN+KzUUIW5\n0GPvFnqZSlwVTKgiF2afpiHKB7EjmT5amn3XfP+9XKCFQxKzbaSXAoH/Ufse\nDZ/Is93nbCS9YBECmjZj0+VLXNQKKGsXXI+CDzeKsO3aMy25xBbW8f91TV+2\n9pRckaNVK8lVv1hUnpYI7SzDfuiG6LAphCjXh2cu+8Qr/SF8S6VI243Jjo+F\n1VlAXAcqx72vGT8ZcAhqd3LyPQwCMVL3832xpXVLfrybDMvAhQc1PoGnGhnm\n9nrfrXeQTT63PrEFMXQ5D9MDHztnlM4kz5F3z5osK7WyVon1kg0aYK8pmZFf\nfMdJezbTZRsGvkXP/nn0Q+T/MNv92LrPpWLhOVqqAKnK2z8i1z2AaF5Er3c7\nWXW+Xfa+CD8CHaRM3pwT3P/XVlsdN7OdDfvMYqNU+Z5jgdpHvCEIwjm2CPBk\nx5xs\r\n=i/lW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGwpyqI5EYwJ0ZghOFaEhHVatLsfIbA1yGJDzxuYTG1MAiEAv0XglF8ECTd9Ws/prJPABkI2kOxFHJv899RcRAkFnqI="}]},"maintainers":[{"name":"eduardbcom","email":"eduardbcom@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lookup-dns-cache_2.0.1_1530710556924_0.21078472850220287"},"_hasShrinkwrap":false},"2.1.0":{"name":"lookup-dns-cache","version":"2.1.0","description":"An implementation to speed up the nodejs `dns.lookup` method by avoiding thread pool and using resolve4/resolve6 with DNS TTL values","main":"index.js","engines":{"node":">=6.0"},"scripts":{"prettier":"prettier --single-quote --tab-width 4 --write \"**/*.js\"","lint":"eslint ./","test":"yarn run unit-test && yarn run func-test","unit-test":"NODE_ENV=test ./node_modules/.bin/mocha --opts tests/mocha.opts -R spec ./tests/Unit/**","func-test":"NODE_ENV=test ./node_modules/.bin/mocha --opts tests/mocha.opts --timeout 15000 -R spec ./tests/Functional/**","test:coverage":"NODE_ENV=test ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --print both -- --opts tests/mocha.opts -R spec ./tests"},"dependencies":{"async":"2.6.0","lodash":"^4.17.10","rr":"0.1.0"},"devDependencies":{"chai":"4.1.2","eslint":"4.15.0","istanbul":"0.4.5","mocha":"4.1.0","prettier":"1.9.2","proxyquire":"1.8.0","sinon":"4.1.4"},"author":{"name":"Eduard","email":"eduardbcom@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/eduardbcom/lookup-dns-cache.git"},"keywords":["dns","lookup","resolve4","resolve6","cache","ipv4","ipv6"],"homepage":"https://github.com/eduardbcom/lookup-dns-cache","license":"MIT","gitHead":"e0cb1f07c163329243bb246eba8ef52ea861a832","bugs":{"url":"https://github.com/eduardbcom/lookup-dns-cache/issues"},"_id":"lookup-dns-cache@2.1.0","_npmVersion":"6.1.0","_nodeVersion":"9.10.1","_npmUser":{"name":"eduardbcom","email":"eduardbcom@gmail.com"},"dist":{"integrity":"sha512-tLcJ7rkqWzZ77D7pN5R2ceWKZsIJ5/6HaLQdmhw3M9fBQQmqS4LZqvBcstKzQ6kuZet5LY4TWTiShx7QmO+Q8w==","shasum":"6362340e269071e20b6f0bcf51da98873411e051","tarball":"https://registry.npmjs.org/lookup-dns-cache/-/lookup-dns-cache-2.1.0.tgz","fileCount":31,"unpackedSize":136251,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbSQ7hCRA9TVsSAnZWagAAlfAP/2mC7nvLM7LAUe4qe/Qx\nB8sXRhmxOXXG8B0KqwIpcnwUo/1NpM7CLf4YmBIqKJg2uKD2TANl4cwxNcCY\nEDFhxyB/hEl6VXIZOIhN6gNLzlMydCncWgackfJ3J/HyE1fIuvGgVR4RFToH\nGu65jqqQmSzjDnafPs65IP5A8X1jQsC4DcLTGhJ3Ab7cmjqGnpjmbUeRBfP6\nFN10lgj5xtbslsdWhuX0gi/5Ij1zRd1btshqIm/g2dKg6wmqkFpK8pCjDNNT\nT5uwkwUH7UlONomPpjVzuVS2IdoZGOlW3M8sdorjg4fHPYlaDH6oZ6v/EpL+\nvYZfYpIWTg36DDz7DA48Jq+eKWQCcWO8ajfcGsSO/ajeHT5d+JmZotUfkKcz\nN4JELu9t84XIaJUIV03tUpRrKwMZGXspBpqRpGGfKiPPitqybDtCxNkG+UX7\nd2L5AN1WED8PQTMTCtsZttPs67ptWM8HN+7AUWXsjJ+E/pc1Zme7L0x0zEjr\n1BKiQUToJBZe+W/5GOvoGjeIIr7Y1o+4qBYcKSBl+ofAsS+1/zkfHYTaGfbn\nUo677sctzYYUWk9qERwIXhqVKmfLapPnzkwEDKMjtk/gan33upcnzQ+rVj0S\nO1xvpMBaViRE/34YQIHZUl6mE1MpOqqy5bHx/IGOISyAEYpKpVp4aQnfQjK7\na/kn\r\n=Fu77\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDiyOSH4IYgZLN/V9iXpg2AtmdiBa9t0jHx4EzxG9UC4AiEAjfHSBsr2+r4cUvRlQ/bb9LgjNz3WmMn9csGWDQbepPU="}]},"maintainers":[{"name":"eduardbcom","email":"eduardbcom@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/lookup-dns-cache_2.1.0_1531514593828_0.38353408477505235"},"_hasShrinkwrap":false}},"readme":"\n# lookup-dns-cache - DNS cache to replace NodeJS `dns.lookup` standard method\n\n## Super simple to use\n\n```js\nconst request = require('request');\nconst {lookup} = require('lookup-dns-cache');\n\n// With \"request\" module\n\nrequest({\n    url: 'http://google.com',\n    method: 'GET',\n    lookup: lookup\n}, (error, response, body) => {\n    // ...\n});\n\n// Direct usage\n\nlookup('google.com', {}, (error, address, family) => {\n    // ...\n});\n```\n\n## Table of contents\n\n- [Motivation](#motivation)\n- [How to use](#howtouse)\n- [Inner implementation](#implementation)\n- [Examples](#examples)\n\n---\n\n## Motivation\n\nThe main idea behind this package is eliminate NodeJS event loop usage when you do network request.\nSee [NodeJS DNS implementation](https://nodejs.org/api/dns.html#dns_implementation_considerations) to understand the problem with `dns.lookup`.\n\n\n[back to top](#table-of-contents)\n\n---\n\n## How to use\n\nThis module supports almost the same params as `dns.lookup` does. Concretely, you can pass `options` object as a second param, and\nset:\n- `family` to `4` or `6`\n- `all` flag to `true`/`false` if you want/don't want get all IP addresses at once.\n\nBecause this implementation does not use `getaddrinfo` method, the `hints` param is not supported.\n\nThe `verbatim` param is not supported for now. If you will not specify any family you will get IPv4 addresses first and IPv6 addresses second.\n \nThe `callback` function works the same way as a standard method.\n\nThe `error` object would have all fields the standard implementation's error object has.\n\nNodeJS `dns.lookup`:\n```javascript\n> const dns = require('dns');\n> dns.lookup('host-doesnot-support-ipv6', {family: 6}, console.log)\n\n> { Error: getaddrinfo ENOTFOUND vss-cc-ha.hwtool.net\n    at errnoException (dns.js:55:10)\n    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:97:26)\n  code: 'ENOTFOUND',\n  errno: 'ENOTFOUND',\n  syscall: 'getaddrinfo',\n  hostname: 'vss-cc-ha.hwtool.net' }\n\n```\n\n`lookup-dns-cache`\n```javascript\n> const {lookup} = require('lookup-dns-cache');\n> lookup('host-doesnot-support-ipv6', {family: 6}, console.log)\n\n> { Error: queryAaaa ENOTFOUND vss-cc-ha.hwtool.net\n      at makeNotFoundError (/path/lookup-dns-cache/src/Lookup.js:182:19)\n      at ipv6AddressesTable.resolve (/path/lookup-dns-cache/src/Lookup.js:147:37)\n      at Immediate.setImmediate [as _onImmediate] (/path/lookup-dns-cache/src/IpAddressesTable.js:70:48)\n      at runCallback (timers.js:773:18)\n      at tryOnImmediate (timers.js:734:5)\n      at processImmediate [as _immediateCallback] (timers.js:711:5)\n    hostname: 'vss-cc-ha.hwtool.net',\n    syscall: 'queryAaaa',\n    code: 'ENOTFOUND',\n    errno: 'ENOTFOUND' }\n```\n\nIf you are looking for `IPv4` addresses only, explicitly specify param `{family: 4}`. In that case, you will avoid \nspending time on useless searching for `IPv6`. Apply the same technique if you are looking for `IPv6` addresses only. \n\nUnder the hood, `lookup` method has Round-robin algorithm. It means that if particular hostname resolves to several addresses\nit will return new address every time you call that function. For example:\n```javascript\n// hostname: example.com\n// resolves to: [1.2.3.4, 5.6.7.8, 9.10.11.12]\n\nlookup('example.com', {family: 4}, (error, address, family) => {\n   // address === \"1.2.3.4\"\n   // family === 4\n});\n\nlookup('example.com', {family: 4}, (error, address, family) => {\n   // address === \"5.6.7.8\"\n   // family === 4\n});\n\nlookup('example.com', {family: 4}, (error, address, family) => {\n   // address === \"9.10.11.12\"\n   // family === 4\n});\n\nlookup('example.com', {family: 4}, (error, address, family) => {\n   // address === \"1.2.3.4\"\n   // family === 4\n});\n```\n\n[back to top](#table-of-contents)\n\n---\n## Implementation\n\nUnder the hood, this package uses `dns.resolve4` and `dns.resolve6` methods with `{ttl: true}` param.\nIt caches addresses for that particular hostname for DNS TTL time and returns one address if you specified `{all: false}` (default value)\nand array of addresses if `{all: true}`.\n\nIf you didn't specify family type (`{family: 4}` or `{family: 6}`) the method searches for addresses of `{family: 4}` and `{family: 6}` in parallel.\nAfter that, if you specified `{all: true}` it returns an array in form `[[...IPv4],[...IPv6]]`, in other case it returns `IPv4` or `IPv6` address.\n(`IPv4` has more priority).\n\n[back to top](#table-of-contents)\n\n---\n## Examples\n\n```javascript\nlookup('hostname', {all: true}, (error, results) => {\n   // results is an array that contains both IPv4 and IPv6 addresses (Ipv4 first).\n   //\n   // error - null\n   // results - [ \n   //   { address: '1.2.3.4', family: 4 },\n   //   { address: '5.6.7.8', family: 4 } \n   // ]\n});\n```\n\n```javascript\nlookup('hostname', {all: false}, (error, address, family) => {\n   // address and family of the first resolved IP (IPv4 or IPv6 if supported).\n   // error - null\n   // address - '1.2.3.4'\n   // family - 4\n});\n```\n\n```javascript\nlookup('hostname', {all: false, family: 4}, (error, address, family) => {\n   // address and family of the first resolved IP (IPv4 only). \n});\n```\n\n```javascript\nlookup('hostname', {all: false, family: 6}, (error, address, family) => {\n   // address and family of the first resolved IP (IPv6 only).\n   // will return an error if IPv6 is not supported. See NodeJS dns.lookup doc.\n});\n```\n\n[back to top](#table-of-contents)\n\n---\n## Similar packages\n\nYahoo tried to solve this problem in own way https://github.com/yahoo/dnscache.\n\nThe big disadvantages if this package are:\n- monkey patching dns module\n- does not support DNS TTL\n- cache just one IP address and use it for every request (no advantage of round-robin if you have dns resolver that returns several addresses)\n\n[back to top](#table-of-contents)\n","maintainers":[{"name":"eduardbcom","email":"eduardbcom@gmail.com"}],"time":{"modified":"2022-05-08T10:19:58.874Z","created":"2018-01-10T06:58:28.020Z","1.0.0":"2018-01-10T06:58:28.020Z","1.0.1":"2018-01-11T08:12:40.676Z","1.1.0":"2018-01-11T14:51:36.272Z","2.0.0":"2018-01-16T15:48:21.796Z","2.0.1":"2018-07-04T13:22:37.171Z","2.1.0":"2018-07-13T20:43:13.939Z"},"homepage":"https://github.com/eduardbcom/lookup-dns-cache","keywords":["dns","lookup","resolve4","resolve6","cache","ipv4","ipv6"],"repository":{"type":"git","url":"git+https://github.com/eduardbcom/lookup-dns-cache.git"},"author":{"name":"Eduard","email":"eduardbcom@gmail.com"},"bugs":{"url":"https://github.com/eduardbcom/lookup-dns-cache/issues"},"license":"MIT","readmeFilename":"README.md"}