Sha256: b35e41e442395a9a98d4aa79e3105c54494bc3ad667d84ea46007dbe65c41f7d

Contents?: true

Size: 1.19 KB

Versions: 101

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

101 entries across 100 versions & 8 rubygems

Version Path
immosquare-cleaner-0.1.60 node_modules/lodash/trimEnd.js
immosquare-cleaner-0.1.59 node_modules/lodash/trimEnd.js
immosquare-cleaner-0.1.58 node_modules/lodash/trimEnd.js
immosquare-cleaner-0.1.57 node_modules/lodash/trimEnd.js
immosquare-cleaner-0.1.56 node_modules/lodash/trimEnd.js
immosquare-cleaner-0.1.55 node_modules/lodash/trimEnd.js
immosquare-cleaner-0.1.54 node_modules/lodash/trimEnd.js
immosquare-cleaner-0.1.53 node_modules/lodash/trimEnd.js
immosquare-cleaner-0.1.52 node_modules/lodash/trimEnd.js
trusty-cms-6.3.1 node_modules/lodash/trimEnd.js
immosquare-cleaner-0.1.51 node_modules/lodash/trimEnd.js
clapton-0.0.26 lib/clapton/javascripts/node_modules/lodash/trimEnd.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/lodash/trimEnd.js
immosquare-cleaner-0.1.50 node_modules/lodash/trimEnd.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/lodash/trimEnd.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/lodash/trimEnd.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/lodash/trimEnd.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/lodash/trimEnd.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/lodash/trimEnd.js
clapton-0.0.19 lib/clapton/javascripts/node_modules/lodash/trimEnd.js