<commit_before>import randexp = require('randexp');

type Dependency = any;

/**
 * string => extension map object
 */
type Registry = {
  [s: string]: Dependency;
};

/**
 * Container is used to wrap external libraries (faker, chance, randexp) that are used among the whole codebase. These
 * libraries might be configured, customized, etc. and each internal JSF module needs to access those instances instead
 * of pure npm module instances. This class supports consistent access to these instances.
 */
class Container {
  private registry: Registry;

  constructor() {
    // static requires - handle both initial dependency load (deps will be available
    // among other modules) as well as they will be included by browserify AST
    this.registry = {
      faker: null,
      chance: null,
      // randexp is required for "pattern" values
      randexp: randexp
    };
  }

  /**
   * Override dependency given by name
   * @param name
   * @param callback
   */
  public extend(name: string, callback: Function): void {
    if (typeof this.registry[name] === 'undefined') {
      throw new ReferenceError('"' + name + '" dependency is not allowed.');
    }
    this.registry[name] = callback(this.registry[name]);
  }

  /**
   * Returns dependency given by name
   * @param name
   * @returns {Dependency}
   */
  public get(name: string): Dependency {
    if (typeof this.registry[name] === 'undefined') {
      throw new ReferenceError('"' + name + '" dependency doesn\'t exist.');
    } else if (name === 'randexp') {
      return this.registry['randexp'].randexp;
    }
    return this.registry[name];
  }

  /**
   * Returns all dependencies
   *
   * @returns {Registry}
   */
  public getAll(): Registry {
    return {
      faker: this.get('faker'),
      chance: this.get('chance'),
      randexp: this.get('randexp')
    };
  }
}

// TODO move instantiation somewhere else (out from class file)

// instantiate
var container = new Container();

export = container;
<commit_msg>Fix: set default RandExp.max value, closes #193<commit_after>import RandExp = require('randexp');

// set maximum default, see #193
RandExp.prototype.max = 10;

type Dependency = any;

/**
 * string => extension map object
 */
type Registry = {
  [s: string]: Dependency;
};

/**
 * Container is used to wrap external libraries (faker, chance, randexp) that are used among the whole codebase. These
 * libraries might be configured, customized, etc. and each internal JSF module needs to access those instances instead
 * of pure npm module instances. This class supports consistent access to these instances.
 */
class Container {
  private registry: Registry;

  constructor() {
    // static requires - handle both initial dependency load (deps will be available
    // among other modules) as well as they will be included by browserify AST
    this.registry = {
      faker: null,
      chance: null,
      // randexp is required for "pattern" values
      randexp: RandExp
    };
  }

  /**
   * Override dependency given by name
   * @param name
   * @param callback
   */
  public extend(name: string, callback: Function): void {
    if (typeof this.registry[name] === 'undefined') {
      throw new ReferenceError('"' + name + '" dependency is not allowed.');
    }
    this.registry[name] = callback(this.registry[name]);
  }

  /**
   * Returns dependency given by name
   * @param name
   * @returns {Dependency}
   */
  public get(name: string): Dependency {
    if (typeof this.registry[name] === 'undefined') {
      throw new ReferenceError('"' + name + '" dependency doesn\'t exist.');
    } else if (name === 'randexp') {
      return this.registry['randexp'].randexp;
    }
    return this.registry[name];
  }

  /**
   * Returns all dependencies
   *
   * @returns {Registry}
   */
  public getAll(): Registry {
    return {
      faker: this.get('faker'),
      chance: this.get('chance'),
      randexp: this.get('randexp')
    };
  }
}

// TODO move instantiation somewhere else (out from class file)

// instantiate
var container = new Container();

export = container;

{'fraction_non_alphanumeric': 0.12121212121212122, 'fraction_numerical': 0.0019550342130987292, 'mean_word_length': 3.044466403162055, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3910879', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1136, 'n_words': 409}