<commit_before>import Type from '../core/type';

const EmailType = new Type({ name: 'email' });

export default EmailType;<commit_msg>fix email field defn<commit_after>import Type from '../core/type';

const EmailType = new Type({
  name: 'email',
  compare(field, a, b) {
    return a.localeCompare(b, undefined, { sensitivity: 'base' });
  },

  query(namePath, where, query) {
    if (where) {
      query[namePath.name] = _.isArray(where) ? { $in: where } : where;
    }
  },

  matches(namePath, where, doc) {
    if (where) {
      let value = namePath.get(doc);
      if (value) {
        if (!_.isString(value)) {
          value = '' + value;
        }

        if (_.isArray(where)) {
          return where.indexOf(value) >= 0;
        } else if (where instanceof RegExp) {
          return value.match(where);
        } else {
          return value === where;
        }
      }
    }

    return true;
  }
});

export default EmailType;
{'fraction_non_alphanumeric': 0.1517386722866175, 'fraction_numerical': 0.001053740779768177, 'mean_word_length': 2.28719723183391, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '5812119', 'n_tokens_mistral': 304, 'n_tokens_neox': 299, 'n_words': 78}