MCPcopy Create free account
hub / github.com/TruthHun/BookStack / startsWith

Function startsWith

static/bootstrap-select-1.13.18/js/bootstrap-select.js:260–289  ·  view source on GitHub ↗
(search)

Source from the content-addressed store, hash-verified

258 }());
259 var toString = {}.toString;
260 var startsWith = function (search) {
261 if (this == null) {
262 throw new TypeError();
263 }
264 var string = String(this);
265 if (search && toString.call(search) == '[object RegExp]') {
266 throw new TypeError();
267 }
268 var stringLength = string.length;
269 var searchString = String(search);
270 var searchLength = searchString.length;
271 var position = arguments.length > 1 ? arguments[1] : undefined;
272 // `ToInteger`
273 var pos = position ? Number(position) : 0;
274 if (pos != pos) { // better `isNaN`
275 pos = 0;
276 }
277 var start = Math.min(Math.max(pos, 0), stringLength);
278 // Avoid the `indexOf` call if no match is possible
279 if (searchLength + start > stringLength) {
280 return false;
281 }
282 var index = -1;
283 while (++index < searchLength) {
284 if (string.charCodeAt(start + index) != searchString.charCodeAt(index)) {
285 return false;
286 }
287 }
288 return true;
289 };
290 if (defineProperty) {
291 defineProperty(String.prototype, 'startsWith', {
292 'value': startsWith,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected