An async DNS lookup function for Node.js that implements atomic cache operations using throttling to ensure only one write-procedure occurs for concurrent requests. Current stable version is 1.4.1, with regular updates. Unlike alternatives like cacheable-lookup or dns-lookup-cache, it guarantees atomicity and supports /etc/hosts file on both Unix and Windows. Ships TypeScript types and requires Node.js >=14.
npm install better-lookupNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates using the lookup function with Node.js https module to resolve IPv4 addresses.
Use ES module imports (import ... from 'better-lookup') or switch to dynamic import().
Use the async/await or Promise-based overloads of lookup().
Be aware that cached results may be refreshed at most every 10 seconds.
Explicitly set family: 0 to get both, or use options.all to get all addresses.
Use import syntax in your project or enable ESM in package.json.
Change to: import { lookup } from 'better-lookup'Ensure network connectivity or check if the hostname exists. The package uses dns.resolve4/6, which may fail on some systems.
No dependency data recorded yet.