massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / modules / es.string.starts-with.js
1 'use strict';
2 var $ = require('../internals/export');
3 var uncurryThis = require('../internals/function-uncurry-this');
4 var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;
5 var toLength = require('../internals/to-length');
6 var toString = require('../internals/to-string');
7 var notARegExp = require('../internals/not-a-regexp');
8 var requireObjectCoercible = require('../internals/require-object-coercible');
9 var correctIsRegExpLogic = require('../internals/correct-is-regexp-logic');
10 var IS_PURE = require('../internals/is-pure');
11
12 // eslint-disable-next-line es/no-string-prototype-startswith -- safe
13 var un$StartsWith = uncurryThis(''.startsWith);
14 var stringSlice = uncurryThis(''.slice);
15 var min = Math.min;
16
17 var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('startsWith');
18 // https://github.com/zloirock/core-js/pull/702
19 var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {
20   var descriptor = getOwnPropertyDescriptor(String.prototype, 'startsWith');
21   return descriptor && !descriptor.writable;
22 }();
23
24 // `String.prototype.startsWith` method
25 // https://tc39.es/ecma262/#sec-string.prototype.startswith
26 $({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {
27   startsWith: function startsWith(searchString /* , position = 0 */) {
28     var that = toString(requireObjectCoercible(this));
29     notARegExp(searchString);
30     var index = toLength(min(arguments.length > 1 ? arguments[1] : undefined, that.length));
31     var search = toString(searchString);
32     return un$StartsWith
33       ? un$StartsWith(that, search, index)
34       : stringSlice(that, index, index + search.length) === search;
35   }
36 });