.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / modules / es.string.ends-with.js
1 'use strict';
2 var $ = require('../internals/export');
3 var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;
4 var toLength = require('../internals/to-length');
5 var notARegExp = require('../internals/not-a-regexp');
6 var requireObjectCoercible = require('../internals/require-object-coercible');
7 var correctIsRegExpLogic = require('../internals/correct-is-regexp-logic');
8 var IS_PURE = require('../internals/is-pure');
9
10 var nativeEndsWith = ''.endsWith;
11 var min = Math.min;
12
13 var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('endsWith');
14 // https://github.com/zloirock/core-js/pull/702
15 var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {
16   var descriptor = getOwnPropertyDescriptor(String.prototype, 'endsWith');
17   return descriptor && !descriptor.writable;
18 }();
19
20 // `String.prototype.endsWith` method
21 // https://tc39.es/ecma262/#sec-string.prototype.endswith
22 $({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {
23   endsWith: function endsWith(searchString /* , endPosition = @length */) {
24     var that = String(requireObjectCoercible(this));
25     notARegExp(searchString);
26     var endPosition = arguments.length > 1 ? arguments[1] : undefined;
27     var len = toLength(that.length);
28     var end = endPosition === undefined ? len : min(toLength(endPosition), len);
29     var search = String(searchString);
30     return nativeEndsWith
31       ? nativeEndsWith.call(that, search, end)
32       : that.slice(end - search.length, end) === search;
33   }
34 });