Sha256: 52643a74e103c6b1a668246ddb79dd5603372ea9378cbe9ccaa23aa2ac0b2cd3

Contents?: true

Size: 1.05 KB

Versions: 153

Compression:

Stored size: 1.05 KB

Contents

var baseToString = require('../internal/baseToString');

/* Native method references for those with the same name as other `lodash` methods. */
var nativeMin = Math.min;

/**
 * Checks if `string` ends with the given target string.
 *
 * @static
 * @memberOf _
 * @category String
 * @param {string} [string=''] The string to search.
 * @param {string} [target] The string to search for.
 * @param {number} [position=string.length] The position to search from.
 * @returns {boolean} Returns `true` if `string` ends with `target`, else `false`.
 * @example
 *
 * _.endsWith('abc', 'c');
 * // => true
 *
 * _.endsWith('abc', 'b');
 * // => false
 *
 * _.endsWith('abc', 'b', 2);
 * // => true
 */
function endsWith(string, target, position) {
  string = baseToString(string);
  target = (target + '');

  var length = string.length;
  position = position === undefined
    ? length
    : nativeMin(position < 0 ? 0 : (+position || 0), length);

  position -= target.length;
  return position >= 0 && string.indexOf(target, position) == position;
}

module.exports = endsWith;

Version data entries

153 entries across 80 versions & 8 rubygems

Version Path
trusty-festivity-extension-2.3.12 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/string/endsWith.js
trusty-festivity-extension-2.3.12 node_modules/bower/node_modules/inquirer/node_modules/lodash/string/endsWith.js
trusty-festivity-extension-2.3.11g node_modules/bower/node_modules/inquirer/node_modules/lodash/string/endsWith.js
trusty-festivity-extension-2.3.11g node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/string/endsWith.js
trusty-festivity-extension-2.3.10 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/string/endsWith.js
trusty-festivity-extension-2.3.10 node_modules/bower/node_modules/inquirer/node_modules/lodash/string/endsWith.js
trusty-festivity-extension-2.3.9 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/string/endsWith.js
trusty-festivity-extension-2.3.9 node_modules/bower/node_modules/inquirer/node_modules/lodash/string/endsWith.js
trusty-festivity-extension-2.3.8 node_modules/bower/node_modules/inquirer/node_modules/lodash/string/endsWith.js
trusty-festivity-extension-2.3.8 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/string/endsWith.js
trusty-festivity-extension-2.3.7 node_modules/bower/node_modules/inquirer/node_modules/lodash/string/endsWith.js
trusty-festivity-extension-2.3.7 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/string/endsWith.js
trusty-festivity-extension-2.3.6 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/string/endsWith.js
trusty-festivity-extension-2.3.6 node_modules/bower/node_modules/inquirer/node_modules/lodash/string/endsWith.js
trusty-festivity-extension-2.3.5 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/string/endsWith.js
trusty-festivity-extension-2.3.5 node_modules/bower/node_modules/inquirer/node_modules/lodash/string/endsWith.js
trusty-festivity-extension-2.3.4 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/string/endsWith.js
trusty-festivity-extension-2.3.4 node_modules/bower/node_modules/inquirer/node_modules/lodash/string/endsWith.js
trusty-festivity-extension-2.3.3 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/string/endsWith.js
trusty-festivity-extension-2.3.3 node_modules/bower/node_modules/inquirer/node_modules/lodash/string/endsWith.js