Nodejs String Include includeString(search, start, caseSensitive, eachOther)

Here you can find the source of includeString(search, start, caseSensitive, eachOther)

Method Source Code

/**//from  w ww  .  j a  v  a 2  s. c  o m
 * Created by ray7551@gmail.com on 12.06 006.
 */
/**
 * case insensitive version of String.prototype.includes
 * @param {String} search
 * @param {Number} [start=0]
 * @param {Boolean} [caseSensitive=false]
 * */
String.prototype.includeString = function (search, start, caseSensitive, eachOther) {
  'use strict';
  caseSensitive = caseSensitive === void 0 ? false : !!caseSensitive;
  eachOther = eachOther === void 0 ? false : !!eachOther;
  if (caseSensitive) {
    return this.includes(search, start);
  }
  if (typeof start !== 'number') {
    start = 0;
  }
  if (start + search.length > this.length) return false;

  var include = this.toLowerCase().indexOf(search.toLowerCase(), start) !== -1;
  return !eachOther ? include : (include || search.toLowerCase().indexOf(this.toLowerCase()) !== -1);
};

export default String.prototype.includeString;

Related

  1. include(pattern)
    String.prototype.include = function(pattern) {
      return this.indexOf(pattern) > -1;
    };
    
  2. include(pattern)
    String.prototype.include = function(pattern) {
      return this.indexOf(pattern) !== -1;
    
  3. include(pattern)
    String.prototype.include = function (pattern) {
      return this.indexOf(pattern) > -1;
    
  4. include(pattern)
    String.prototype.include = function (pattern) {
        return this.indexOf(pattern) > -1;
    enyo.singleton({
        name: "preware.Globals",
        published: {
            appVersion: "0.2"
    });
    ...
    
  5. include(x)
    String.prototype.include = function(x){
      return this.indexOf(x) > -1
    
  6. includes( other )
    String.prototype.includes = function( other ){
      return !!other && this.indexOf( other) != -1
    function str_includes( that, other ){
      return !!other && that.indexOf( other) != -1
    
  7. includes()
    String.prototype.includes = function () {
        'use strict';
        return String.prototype.indexOf.apply(this, arguments) !== -1;
    };
    
  8. includes(matcher)
    String.prototype.includes = function(matcher) {
      var includes = false;
      if( this.indexOf( matcher ) > 0 ) {
        includes = true;
      return includes;
    
  9. includes(string, index)
    String.prototype.includes = function (string, index) {
      if (typeof string === 'object' && string instanceof RegExp) 
         throw new TypeError("First argument to String.prototype.includes must not be a regular expression");
      return this.indexOf(string, index) !== -1;
    };