Sha256: fea31bef645bd4e15e4e604d4836f4a3bb986750a48a971d1ca041d4559d55f5

Contents?: true

Size: 1.05 KB

Versions: 12

Compression:

Stored size: 1.05 KB

Contents

'use strict';
var $ = require('../internals/export');
var toLength = require('../internals/to-length');
var notARegExp = require('../internals/not-a-regexp');
var requireObjectCoercible = require('../internals/require-object-coercible');
var correctIsRegExpLogic = require('../internals/correct-is-regexp-logic');

var nativeEndsWith = ''.endsWith;
var min = Math.min;

// `String.prototype.endsWith` method
// https://tc39.github.io/ecma262/#sec-string.prototype.endswith
$({ target: 'String', proto: true, forced: !correctIsRegExpLogic('endsWith') }, {
  endsWith: function endsWith(searchString /* , endPosition = @length */) {
    var that = String(requireObjectCoercible(this));
    notARegExp(searchString);
    var endPosition = arguments.length > 1 ? arguments[1] : undefined;
    var len = toLength(that.length);
    var end = endPosition === undefined ? len : min(toLength(endPosition), len);
    var search = String(searchString);
    return nativeEndsWith
      ? nativeEndsWith.call(that, search, end)
      : that.slice(end - search.length, end) === search;
  }
});

Version data entries

12 entries across 12 versions & 4 rubygems

Version Path
disco_app-0.18.0 test/dummy/node_modules/core-js/modules/es.string.ends-with.js
disco_app-0.18.2 test/dummy/node_modules/core-js/modules/es.string.ends-with.js
condenser-0.0.8 lib/condenser/processors/node_modules/core-js-pure/modules/es.string.ends-with.js
jester-data-8.0.0 node_modules/core-js/modules/es.string.ends-with.js
ezii-os-5.2.1 node_modules/core-js/modules/es.string.ends-with.js
ezii-os-2.0.1 node_modules/core-js/modules/es.string.ends-with.js
ezii-os-1.1.0 node_modules/core-js/modules/es.string.ends-with.js
ezii-os-1.0.0 node_modules/core-js/modules/es.string.ends-with.js
condenser-0.0.7 lib/condenser/processors/node_modules/core-js-pure/modules/es.string.ends-with.js
ezii-os-0.0.0.1.0 node_modules/core-js/modules/es.string.ends-with.js
ezii-os-0.0.0.0.1 node_modules/core-js/modules/es.string.ends-with.js
condenser-0.0.5 lib/condenser/processors/node_modules/core-js-pure/modules/es.string.ends-with.js