<commit_before>var dgram  = require('dgram')
  , Buffer = require('buffer').Buffer
  ;

exports.createMagicPacket = function(mac) {
  var num_mac_octets = 6;
  if (mac.length == 2 * num_mac_octets + (num_mac_octets - 1)) {
    var sep = mac[2];
    mac = mac.replace(new RegExp(sep, 'g'), '');
  } else if (mac.length != 2 * num_mac_octets) {
    throw new Error("malformed MAC address '" + mac + "'");
  }

  var mac_buffer = new Buffer(num_mac_octets);
  for (var i = 0; i < num_mac_octets; ++i) {
    mac_buffer[i] = parseInt(mac.substr(2 * i, 2), 16);
  }

  var num_macs = 16;
  var buffer = new Buffer((1 + num_macs) * num_mac_octets);
  for (var i = 0; i < num_mac_octets; ++i) {
    buffer[i] = 0xff;
  }
  for (var i = 0; i < num_macs; ++i) {
    mac_buffer.copy(buffer, (i + 1) * num_mac_octets, 0, mac_buffer.length)
  }
  return buffer;
};

exports.wake = function(mac, opts, callback) {<commit_msg>validate that the MAC is really hexadecimal<commit_after>var dgram  = require('dgram')
  , Buffer = require('buffer').Buffer
  ;

exports.createMagicPacket = function(mac) {
  var num_mac_octets = 6;
  if (mac.length == 2 * num_mac_octets + (num_mac_octets - 1)) {
    var sep = mac[2];
    mac = mac.replace(new RegExp(sep, 'g'), '');
  }
  if (mac.length != 2 * num_mac_octets || mac.match(/[^a-fA-F0-9]/)) {
    throw new Error("malformed MAC address '" + mac + "'");
  }

  var mac_buffer = new Buffer(num_mac_octets);
  for (var i = 0; i < num_mac_octets; ++i) {
    mac_buffer[i] = parseInt(mac.substr(2 * i, 2), 16);
  }

  var num_macs = 16;
  var buffer = new Buffer((1 + num_macs) * num_mac_octets);
  for (var i = 0; i < num_mac_octets; ++i) {
    buffer[i] = 0xff;
  }
  for (var i = 0; i < num_macs; ++i) {
    mac_buffer.copy(buffer, (i + 1) * num_mac_octets, 0, mac_buffer.length)
  }
  return buffer;
};

exports.wake = function(mac, opts, callback) {
{'fraction_non_alphanumeric': 0.16879659211927583, 'fraction_numerical': 0.02023429179978701, 'mean_word_length': 3.3901869158878504, 'pattern_counts': {'":': 0, '<': 9, '<?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': '4176173', 'n_tokens_mistral': 784, 'n_tokens_neox': 750, 'n_words': 180}