<commit_before>import { Html } from './html';
import { Nominatim } from './nominatim';
import U from './utils';
import * as C from './constants';

/**
 * @class Base
 * @extends {ol.control.Control}
 */
export default class Base extends ol.control.Control {
  /**
   * @constructor
   * @param {string} type nominatim|reverse.
   * @param {object} options Options.
   */
  constructor(type = C.controlType.NOMINATIM, options = {}) {

    if (!(this instanceof Base)) return new Base();

    U.assert(typeof type === 'string', '@param `type` should be string!');
    U.assert(typeof options === 'object',
        '@param `options` should be object!');

    this.options = U.mergeOptions(C.defaultOptions, options);
    this.container = undefined;

    let $nominatim;
    const $html = new Html(this);

    if (type === C.controlType.NOMINATIM) {
      this.container = $html.els.container;
      $nominatim = new Nominatim(this, $html.els);
      this.layer = $nominatim.layer;
    } else if (type === C.controlType.REVERSE) {
      // TODO
    }

    super({ element: this.container });
  }

  /**
   * @return {ol.layer.Vector} Returns the layer created by this control
   */
  getLayer() {
    return this.layer;
  }

  /**
   * @return {ol.source.Vector} Returns the source created by this control
   */
  getSource() {
    return this.getLayer().getSource();
  }
}
<commit_msg>Add new assert to control type<commit_after>import { Html } from './html';
import { Nominatim } from './nominatim';
import U from './utils';
import * as C from './constants';

/**
 * @class Base
 * @extends {ol.control.Control}
 */
export default class Base extends ol.control.Control {
  /**
   * @constructor
   * @param {string} type nominatim|reverse.
   * @param {object} options Options.
   */
  constructor(type = C.controlType.NOMINATIM, options = {}) {

    if (!(this instanceof Base)) return new Base();

    U.assert(typeof type === 'string', '@param `type` should be string!');
    U.assert(type === C.controlType.NOMINATIM || type === C.controlType.REVERSE,
        `@param 'type' should be '${C.controlType.NOMINATIM}' or 
        '${C.controlType.REVERSE}'!`);
    U.assert(typeof options === 'object',
        '@param `options` should be object!');

    this.options = U.mergeOptions(C.defaultOptions, options);
    this.container = undefined;

    let $nominatim;
    const $html = new Html(this);

    console.log(type, C.controlType.NOMINATIM);
    if (type === C.controlType.NOMINATIM) {
      this.container = $html.els.container;
      $nominatim = new Nominatim(this, $html.els);
      this.layer = $nominatim.layer;
    } else if (type === C.controlType.REVERSE) {
      // TODO
    }

    console.log($html.els.container);
    super({ element: $html.els.container });
  }

  /**
   * @return {ol.layer.Vector} Returns the layer created by this control
   */
  getLayer() {
    return this.layer;
  }

  /**
   * @return {ol.source.Vector} Returns the source created by this control
   */
  getSource() {
    return this.getLayer().getSource();
  }
}

{'fraction_non_alphanumeric': 0.1592544146500981, 'fraction_numerical': 0.0, 'mean_word_length': 2.9727272727272727, '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': '6293164', 'n_tokens_mistral': 995, 'n_tokens_neox': 991, 'n_words': 251}