source: trip-planner-front/node_modules/core-js/modules/es.string.ends-with.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.6 KB
Line 
1'use strict';
2var $ = require('../internals/export');
3var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;
4var toLength = require('../internals/to-length');
5var toString = require('../internals/to-string');
6var notARegExp = require('../internals/not-a-regexp');
7var requireObjectCoercible = require('../internals/require-object-coercible');
8var correctIsRegExpLogic = require('../internals/correct-is-regexp-logic');
9var IS_PURE = require('../internals/is-pure');
10
11// eslint-disable-next-line es/no-string-prototype-endswith -- safe
12var $endsWith = ''.endsWith;
13var min = Math.min;
14
15var CORRECT_IS_REGEXP_LOGIC = correctIsRegExpLogic('endsWith');
16// https://github.com/zloirock/core-js/pull/702
17var MDN_POLYFILL_BUG = !IS_PURE && !CORRECT_IS_REGEXP_LOGIC && !!function () {
18 var descriptor = getOwnPropertyDescriptor(String.prototype, 'endsWith');
19 return descriptor && !descriptor.writable;
20}();
21
22// `String.prototype.endsWith` method
23// https://tc39.es/ecma262/#sec-string.prototype.endswith
24$({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_REGEXP_LOGIC }, {
25 endsWith: function endsWith(searchString /* , endPosition = @length */) {
26 var that = toString(requireObjectCoercible(this));
27 notARegExp(searchString);
28 var endPosition = arguments.length > 1 ? arguments[1] : undefined;
29 var len = toLength(that.length);
30 var end = endPosition === undefined ? len : min(toLength(endPosition), len);
31 var search = toString(searchString);
32 return $endsWith
33 ? $endsWith.call(that, search, end)
34 : that.slice(end - search.length, end) === search;
35 }
36});
Note: See TracBrowser for help on using the repository browser.