Sha256: d058c6b8703bf03818a7c4573b4271aae57ae628ebe1cb5c76137845945a8766

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

/*! https://mths.be/includes v2.0.0 by @mathias */

'use strict';

var callBound = require('es-abstract/helpers/callBound')
var RequireObjectCoercible = require('es-abstract/2019/RequireObjectCoercible');
var ToString = require('es-abstract/2019/ToString');
var ToInteger = require('es-abstract/2019/ToInteger');
var IsRegExp = require('es-abstract/2019/IsRegExp');

var min = Math.min;
var max = Math.max;
var indexOf = callBound('String.prototype.indexOf');

module.exports = function includes(searchString) {
	var O = RequireObjectCoercible(this);
	var S = ToString(O);
	if (IsRegExp(searchString)) {
		throw TypeError('Argument to String.prototype.includes cannot be a RegExp');
	}
	var searchStr = String(searchString);
	var searchLength = searchStr.length;
	var position = arguments.length > 1 ? arguments[1] : undefined;
	var pos = ToInteger(position);
	var len = S.length;
	var start = min(max(pos, 0), len);
	// Avoid the `indexOf` call if no match is possible
	if (searchLength + start > len) {
		return false;
	}
	return indexOf(S, searchStr, pos) != -1;
};

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
immosquare-cleaner-0.1.51 node_modules/string.prototype.includes/implementation.js
immosquare-cleaner-0.1.50 node_modules/string.prototype.includes/implementation.js
immosquare-cleaner-0.1.49 node_modules/string.prototype.includes/implementation.js
immosquare-cleaner-0.1.48 node_modules/string.prototype.includes/implementation.js
immosquare-cleaner-0.1.47 node_modules/string.prototype.includes/implementation.js
immosquare-cleaner-0.1.46 node_modules/string.prototype.includes/implementation.js
immosquare-cleaner-0.1.45 node_modules/string.prototype.includes/implementation.js