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
immosquare-cleaner-0.1.25 node_modules/lodash/trimEnd.js
immosquare-cleaner-0.1.24 node_modules/lodash/trimEnd.js
immosquare-cleaner-0.1.23 node_modules/lodash/trimEnd.js
reed_sdk-1.0.1 node_modules/lodash/trimEnd.js
reed_sdk-1.0.0 node_modules/lodash/trimEnd.js
trusty-cms-5.0.7 node_modules/lodash/trimEnd.js
appmap-0.72.2 ./node_modules/lodash/trimEnd.js
trusty-cms-5.0.6 node_modules/lodash/trimEnd.js
appmap-0.72.1 ./node_modules/lodash/trimEnd.js
appmap-0.72.0 ./node_modules/lodash/trimEnd.js
trusty-cms-5.0.5 node_modules/lodash/trimEnd.js
trusty-cms-5.0.4 node_modules/lodash/trimEnd.js
appmap-0.71.0 ./node_modules/lodash/trimEnd.js
appmap-0.70.2 ./node_modules/lodash/trimEnd.js
appmap-0.70.1 ./node_modules/lodash/trimEnd.js
appmap-0.70.0 ./node_modules/lodash/trimEnd.js
appmap-0.69.0 ./node_modules/lodash/trimEnd.js
appmap-0.68.2 ./node_modules/lodash/trimEnd.js
appmap-0.68.1 ./node_modules/lodash/trimEnd.js
appmap-0.68.0 ./node_modules/lodash/trimEnd.js