<commit_before>var mongoose = require('mongoose'),
  Schema = mongoose.Schema,
  slug = require('slug'),
  _ = require('lodash')

/**
* Default global options
**/
SlugHero.config = {
  counter: '_slug_ctrs',
  slugFieldName: 'slug',
  slugsFieldName: 'slugs',
  slugOptions: { lower: true }
}

/**
* Build slug counters schema & model
* This will add new collection [collectionName] in your db
**/
SlugHero.createCounterModel = function (collectionName) {
  var counterSchema = new Schema({
    '_id': { type: String },
    'seq': { type: Number }
  })

  return mongoose.model(collectionName, counterSchema)
}

/**
 * Global variable to store counter collection names
 **/
SlugHero.Counters = []

function SlugHero (schema, options) {
  var
  // --------- options --------- //

    // target doc/collection name (required)
    doc = options.doc,

    // scope keys for slug (optional)
    scope = options.scope,

    // the field to be slugged (required)
    slugField = options.field,

    // field name for storing slug (optional / global)
    slugFieldName = options.slugField || options.slugFieldName || SlugHero.config.slugFieldName,

    // field name for storing slugs (optional / global)
    slugsFieldName = options.slugsField || options.slugsFieldName || SlugHero.config.slugsFieldName,

    // node-slug options, refer to https://github.com/dodo/node-slug#options (optional / global)
    slugOptions = options.slugOptions || SlugHero.config.slugOptions,

    // collection name to save sequences (optional / global)
    counterCollectionName = options.counter || SlugHero.config.counter,

    // --------- not options --------- //

    // slug fields to be added to the schema 
    slugAttrs = {}

  // Prepare the Counters to use
  if (!SlugHero.Counters[counterCollectionName]) {
    SlugHero.Counters[counterCollectionName] = SlugHero.createCounterModel(counterCollectionName)<commit_msg>fix global options<commit_after>var mongoose = require('mongoose'),
  Schema = mongoose.Schema,
  slug = require('slug'),
  _ = require('lodash')

/**
* Default global options
**/
SlugHero.config = {
  counter: '_slug_ctrs',
  slugFieldName: 'slug',
  slugsFieldName: 'slugs',
  slugOptions: { lower: true }
}

/**
* Build slug counters schema & model
* This will add new collection [collectionName] in your db
**/
SlugHero.createCounterModel = function (collectionName) {
  var counterSchema = new Schema({
    '_id': { type: String },
    'seq': { type: Number }
  })

  return mongoose.model(collectionName, counterSchema)
}

/**
 * Global variable to store counter collection names
 **/
SlugHero.Counters = []

function SlugHero (schema, options) {
  var
  // --------- options --------- //

    // target doc/collection name (required)
    doc = options.doc,

    // scope keys for slug (optional)
    scope = options.scope,

    // the field to be slugged (required)
    slugField = options.field,

    // field name for storing slug (optional / global)
    slugFieldName = options.slugField || options.slugFieldName || SlugHero.config.slugField || SlugHero.config.slugFieldName,

    // field name for storing slugs (optional / global)
    slugsFieldName = options.slugsField || options.slugsFieldName || SlugHero.config.slugsField || SlugHero.config.slugsFieldName,

    // node-slug options, refer to https://github.com/dodo/node-slug#options (optional / global)
    slugOptions = options.slugOptions || SlugHero.config.slugOptions,

    // collection name to save sequences (optional / global)
    counterCollectionName = options.counter || SlugHero.config.counter,

    // --------- not options --------- //

    // slug fields to be added to the schema 
    slugAttrs = {}

  // Prepare the Counters to use
  if (!SlugHero.Counters[counterCollectionName]) {
    SlugHero.Counters[counterCollectionName] = SlugHero.createCounterModel(counterCollectionName)
{'fraction_non_alphanumeric': 0.1338501291989664, 'fraction_numerical': 0.0, 'mean_word_length': 3.2585258525852585, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '6168638', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1169, 'n_words': 299}