Sha256: b35e41e442395a9a98d4aa79e3105c54494bc3ad667d84ea46007dbe65c41f7d

Contents?: true

Size: 1.19 KB

Versions: 104

Compression:

Stored size: 1.19 KB

Contents

var baseToString = require('./_baseToString'),
    castSlice = require('./_castSlice'),
    charsEndIndex = require('./_charsEndIndex'),
    stringToArray = require('./_stringToArray'),
    toString = require('./toString'),
    trimmedEndIndex = require('./_trimmedEndIndex');

/**
 * Removes trailing whitespace or specified characters from `string`.
 *
 * @static
 * @memberOf _
 * @since 4.0.0
 * @category String
 * @param {string} [string=''] The string to trim.
 * @param {string} [chars=whitespace] The characters to trim.
 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
 * @returns {string} Returns the trimmed string.
 * @example
 *
 * _.trimEnd('  abc  ');
 * // => '  abc'
 *
 * _.trimEnd('-_-abc-_-', '_-');
 * // => '-_-abc'
 */
function trimEnd(string, chars, guard) {
  string = toString(string);
  if (string && (guard || chars === undefined)) {
    return string.slice(0, trimmedEndIndex(string) + 1);
  }
  if (!string || !(chars = baseToString(chars))) {
    return string;
  }
  var strSymbols = stringToArray(string),
      end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;

  return castSlice(strSymbols, 0, end).join('');
}

module.exports = trimEnd;

Version data entries

104 entries across 103 versions & 9 rubygems

Version Path
appmap-0.67.1 ./node_modules/lodash/trimEnd.js
trusty-cms-5.0.3 node_modules/lodash/trimEnd.js
trusty-cms-5.0.2 node_modules/lodash/trimEnd.js
appmap-0.67.0 ./node_modules/lodash/trimEnd.js
appmap-0.66.2 ./node_modules/lodash/trimEnd.js
trusty-cms-5.0.1 node_modules/lodash/trimEnd.js
trusty-cms-4.3.5 node_modules/lodash/trimEnd.js
trusty-cms-5.0.0 node_modules/lodash/trimEnd.js
appmap-0.66.1 ./node_modules/lodash/trimEnd.js
appmap-0.66.0 ./node_modules/lodash/trimEnd.js
appmap-0.65.1 ./node_modules/lodash/trimEnd.js
appmap-0.65.0 ./node_modules/lodash/trimEnd.js
trusty-cms-4.3.4 node_modules/lodash/trimEnd.js
appmap-0.64.0 ./node_modules/lodash/trimEnd.js
appmap-0.63.0 ./node_modules/lodash/trimEnd.js
jekyll-esm-0.0.3 node_modules/lodash/trimEnd.js
trusty-cms-4.3.3 node_modules/lodash/trimEnd.js
trusty-cms-4.3.2 node_modules/lodash/trimEnd.js
trusty-cms-4.3.1 node_modules/lodash/trimEnd.js
trusty-cms-4.2.3 node_modules/lodash/trimEnd.js