<commit_before><commit_msg>resolves a domain into ipv6 address<commit_after>'use strict';

var dns = require('dns');
var inherits = require('util').inherits;

var EventEmitter = require('events').EventEmitter;

function Resolver(host, options, callback) {
  if (typeof options === 'function') {
    callback = options;
    options = {};
  }

  EventEmitter.call(this);

  this.once('address', function (addr) {
    callback(null, addr);
  });

  this.once('error', function (err) {
    callback(err, null);
  });

  this._lookup(host, 6);
}

inherits(Resolver, EventEmitter);

Resolver.prototype._lookup = function (host, family) {
  var that = this;

  dns.lookup(host, family, function (err, addr) {
    if (err) {
      that.emit('error', err);
    } else {
      that.emit('address', addr);
    }
  });
};

/**
 * @param  {String}   host
 * @param  {Object}   options
 * @param  {Function} callback
 * @return {Resolver}
 */
module.exports = function (host, options, callback) {
  return new Resolver(host, options, callback);
};
{'fraction_non_alphanumeric': 0.16456921587608905, 'fraction_numerical': 0.001936108422071636, 'mean_word_length': 3.7649769585253456, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '578331', 'n_tokens_mistral': 336, 'n_tokens_neox': 333, 'n_words': 82}