File size: 597 Bytes
e1d589b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* */ 
'use strict';
var $def = require('./$.def'),
    toLength = require('./$.to-length'),
    context = require('./$.string-context');
$def($def.P + $def.F * !require('./$.fails')(function() {
  'q'.endsWith(/./);
}), 'String', {endsWith: function endsWith(searchString) {
    var that = context(this, searchString, 'endsWith'),
        endPosition = arguments[1],
        len = toLength(that.length),
        end = endPosition === undefined ? len : Math.min(toLength(endPosition), len),
        search = String(searchString);
    return that.slice(end - search.length, end) === search;
  }});