/** * * @authors your name (you@example.org) * @date 2020-12-16 15:26:52 * @version $id$ */ if (!string.prototype.startswith) { (function() { 'use strict'; // needed to support `apply`/`call` with `undefined`/`null` var defineproperty = (function() { // ie 8 only supports `object.defineproperty` on dom elements try { var object = {}; var $defineproperty = object.defineproperty; var result = $defineproperty(object, object, object) && $defineproperty; } catch(error) {} return result; }()); var tostring = {}.tostring; var startswith = function(search) { if (this == null) { throw typeerror(); } var string = string(this); if (search && tostring.call(search) == '[object regexp]') { throw typeerror(); } var stringlength = string.length; var searchstring = string(search); var searchlength = searchstring.length; var position = arguments.length > 1 ? arguments[1] : undefined; // `tointeger` var pos = position ? number(position) : 0; if (pos != pos) { // better `isnan` pos = 0; } var start = math.min(math.max(pos, 0), stringlength); // avoid the `indexof` call if no match is possible if (searchlength + start > stringlength) { return false; } var index = -1; while (++index < searchlength) { if (string.charcodeat(start + index) != searchstring.charcodeat(index)) { return false; } } return true; }; if (defineproperty) { defineproperty(string.prototype, 'startswith', { 'value': startswith, 'configurable': true, 'writable': true }); } else { string.prototype.startswith = startswith; } }()); }