isResolvable.js 561 B

1234567891011121314151617181920212223
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const util_1 = require("./util");
  4. /**
  5. * Tries to resolve the hostname. Returns true if succeeds.
  6. *
  7. * @param {String} host is the hostname from the URL.
  8. * @return {Boolean}
  9. */
  10. async function isResolvable(host) {
  11. const family = 4;
  12. try {
  13. if (await (0, util_1.dnsLookup)(host, { family })) {
  14. return true;
  15. }
  16. }
  17. catch (err) {
  18. // ignore
  19. }
  20. return false;
  21. }
  22. exports.default = isResolvable;
  23. //# sourceMappingURL=isResolvable.js.map