shim.js 596 B

123456789101112131415161718
  1. "use strict";
  2. var toInteger = require("../../../number/to-integer")
  3. , value = require("../../../object/valid-value")
  4. , isValue = require("../../../object/is-value")
  5. , min = Math.min
  6. , max = Math.max;
  7. module.exports = function (searchString /*, endPosition*/) {
  8. var self, start, endPos;
  9. self = String(value(this));
  10. searchString = String(searchString);
  11. endPos = arguments[1];
  12. start =
  13. (isValue(endPos) ? min(max(toInteger(endPos), 0), self.length) : self.length) -
  14. searchString.length;
  15. return start < 0 ? false : self.indexOf(searchString, start) === start;
  16. };