/**
Copyright: 2024 Contrast Security, Inc
  Contact: support@contrastsecurity.com
  License: Commercial

  NOTICE: This Software and the patented inventions embodied within may only be
  used as part of Contrast Security’s commercial offerings. Even though it is
  made available through public repositories, use of this Software is subject to
  the applicable End User Licensing Agreement found at
  https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
  between Contrast Security and the End User. The Software may not be reverse
  engineered, modified, repackaged, sold, redistributed or otherwise used in a
  way not consistent with the End User License Agreement.
*/
'use strict';

/**
 * Implements a small subset of the String API.
 */
class CleanStringBase {
  constructor(string) {
    this._value = string;
  }

  /**
   * Returns the instance's value as a String.
   */
  toString() {
    return this._value;
  }

  /**
   * Returns the instance's value as a String.
   */
  valueOf() {
    return this._value;
  }

  /**
   * Calls indexOf on <code>_value</code> property.
   * @param   {String} sub     The substring
   * @param   {Number} fromIdx Starting index for search
   * @returns {Number}
   */
  indexOf(sub, fromIdx) {
    return this._value.indexOf(sub, fromIdx);
  }

  /**
   * Calls lastIndexOf on <code>_value</code> property.
   * @param   {String} sub     The substring
   * @param   {Number} fromIdx Starting index for search
   * @returns {Number}
   */
  lastIndexOf(sub, fromIdx) {
    return this._value.lastIndexOf(sub, fromIdx);
  }
}

module.exports = CleanStringBase;
