<commit_before>var _ = require('lodash-node/modern');
// Simplistic Latin hashtag format
var defaultOptions = {
  fieldPath: undefined,
  path: 'tags',
  match: /[#＃][a-z_0-9]+/g,
  map: removeHash
};

module.exports = function tagsPlugin(schema, options) {
  options = _.merge({}, defaultOptions, options || {});

  if (!schema.path(options.fieldPath)) {
    return;
  }

  if (!schema.path(options.path)) {
    schema.path(options.path, [{
      type: String,
      select: false
    }]);
  }

  schema.pre('save', function setTags(next) {
    if (this.isModified(options.fieldPath)) {
      this.set(options.path,
        ((this.get(options.fieldPath) || '')
        .toLowerCase()
        .match(options.match) || [])
        .map(options.map)
        .filter(uniq)
      );
    }

    return next();
  });<commit_msg>style: simplify options config<commit_after>var _ = require('lodash-node/modern');
// Simplistic Latin hashtag format

module.exports = function tagsPlugin(schema, options) {
  options = _.merge({
    fieldPath: undefined,
    path: 'tags',
    match: /[#＃][a-z_0-9]+/g,
    map: removeHash
  }, options || {});

  if (!schema.path(options.fieldPath)) {
    return;
  }

  if (!schema.path(options.path)) {
    schema.path(options.path, [{
      type: String,
      select: false
    }]);
  }

  schema.pre('save', function setTags(next) {
    if (this.isModified(options.fieldPath)) {
      this.set(options.path,
        ((this.get(options.fieldPath) || '')
        .toLowerCase()
        .match(options.match) || [])
        .map(options.map)
        .filter(uniq)
      );
    }

    return next();
  });
{'fraction_non_alphanumeric': 0.17668711656441718, 'fraction_numerical': 0.00245398773006135, 'mean_word_length': 2.6984126984126986, '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': '2661712', 'n_tokens_mistral': 559, 'n_tokens_neox': 545, 'n_words': 94}