es.string.includes.js 722 B

123456789101112131415
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var notARegExp = require('../internals/not-a-regexp');
  4. var requireObjectCoercible = require('../internals/require-object-coercible');
  5. var toString = require('../internals/to-string');
  6. var correctIsRegExpLogic = require('../internals/correct-is-regexp-logic');
  7. // `String.prototype.includes` method
  8. // https://tc39.es/ecma262/#sec-string.prototype.includes
  9. $({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
  10. includes: function includes(searchString /* , position = 0 */) {
  11. return !!~toString(requireObjectCoercible(this))
  12. .indexOf(toString(notARegExp(searchString)), arguments.length > 1 ? arguments[1] : undefined);
  13. }
  14. });