<commit_before>/**
 * Eco API
 *
 * @property {function} [onChange] called whenever an entity has a component
 *  added, removed or changed. Called with: entity, componentName, newValue,
 *  oldValue
 */
export default class Eco {
  /**
   * @param {function} Entity class to use to create entities
   * @param {function} Entity.defineComponent function that takes a component
   *  name
   */
  constructor(Entity, createFilter) {
    this.Entity = Entity;
    this.createFilterInstance = createFilter;

    this.entities = [];
    this.onChange = () => {};
  }

  /**
   * Defines one or more component identifiers. This sets up components so they
   * can be accessed on the entities using standard dot notation
   *
   * @param {Array.<string>} names the component identifiers
   */
  defineComponents(names) {
    names.forEach(name => {
      this.Entity.defineComponent(name);
    });
  }

  /**
   * Return s a new component instance
   *
   * @param {string} name the component identifier
   * @param {...*} args arguments to pass to the component factory
   * @returns {mixed} the component
   */
  createComponent(name, ...args) {
    const factory = this.components[name];
    return factory ? factory(...args) : undefined;
  }

  /**
   * Returns a new entity instance
   *
   * @returns {Entity} the entity
   */
  entity() {
    const entity = new this.Entity();
    this.entities.push(entity);
    return entity;
  }

  /**
   * Returns a new entity filter instance
   *
   * @param {Array<string>|function} criteria an array of component
   *  identifiers, or a function that returns true if a given entity should be
   *  included
   *
   * @returns {Filter}  filter instance
   */
  createFilter(criteria) {
    return this.createFilterInstance(this.entities, criteria);
  }
<commit_msg>Remove eco.createComponent() dead code<commit_after>/**
 * Eco API
 *
 * @property {function} [onChange] called whenever an entity has a component
 *  added, removed or changed. Called with: entity, componentName, newValue,
 *  oldValue
 */
export default class Eco {
  /**
   * @param {function} Entity class to use to create entities
   * @param {function} Entity.defineComponent function that takes a component
   *  name
   */
  constructor(Entity, createFilter) {
    this.Entity = Entity;
    this.createFilterInstance = createFilter;

    this.entities = [];
    this.onChange = () => {};
  }

  /**
   * Defines one or more component identifiers. This sets up components so they
   * can be accessed on the entities using standard dot notation
   *
   * @param {Array.<string>} names the component identifiers
   */
  defineComponents(names) {
    names.forEach(name => {
      this.Entity.defineComponent(name);
    });
  }

  /**
   * Returns a new entity instance
   *
   * @returns {Entity} the entity
   */
  entity() {
    const entity = new this.Entity();
    this.entities.push(entity);
    return entity;
  }

  /**
   * Returns a new entity filter instance
   *
   * @param {Array<string>|function} criteria an array of component
   *  identifiers, or a function that returns true if a given entity should be
   *  included
   *
   * @returns {Filter}  filter instance
   */
  createFilter(criteria) {
    return this.createFilterInstance(this.entities, criteria);
  }

{'fraction_non_alphanumeric': 0.1090191314910416, 'fraction_numerical': 0.0, 'mean_word_length': 3.0024301336573513, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '6454061', 'n_tokens_mistral': 939, 'n_tokens_neox': 923, 'n_words': 309}