Sha256: cfe1dc216d09b4d8610d72b1b1fc9e333c723d63a76a94fece98ec1b5fcc5900

Contents?: true

Size: 1.08 KB

Versions: 167

Compression:

Stored size: 1.08 KB

Contents

var baseToString = require('../internal/baseToString'),
    charsRightIndex = require('../internal/charsRightIndex'),
    isIterateeCall = require('../internal/isIterateeCall'),
    trimmedRightIndex = require('../internal/trimmedRightIndex');

/**
 * Removes trailing whitespace or specified characters from `string`.
 *
 * @static
 * @memberOf _
 * @category String
 * @param {string} [string=''] The string to trim.
 * @param {string} [chars=whitespace] The characters to trim.
 * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
 * @returns {string} Returns the trimmed string.
 * @example
 *
 * _.trimRight('  abc  ');
 * // => '  abc'
 *
 * _.trimRight('-_-abc-_-', '_-');
 * // => '-_-abc'
 */
function trimRight(string, chars, guard) {
  var value = string;
  string = baseToString(string);
  if (!string) {
    return string;
  }
  if (guard ? isIterateeCall(value, chars, guard) : chars == null) {
    return string.slice(0, trimmedRightIndex(string) + 1);
  }
  return string.slice(0, charsRightIndex(string, (chars + '')) + 1);
}

module.exports = trimRight;

Version data entries

167 entries across 87 versions & 9 rubygems

Version Path
ilog-0.4.1 node_modules/babel-plugin-proto-to-assign/node_modules/lodash/string/trimRight.js
ilog-0.4.1 node_modules/contents/node_modules/lodash/string/trimRight.js
ilog-0.4.1 node_modules/babel/node_modules/lodash/string/trimRight.js
ilog-0.4.0 node_modules/babel-plugin-proto-to-assign/node_modules/lodash/string/trimRight.js
ilog-0.4.0 node_modules/contents/node_modules/lodash/string/trimRight.js
ilog-0.4.0 node_modules/babel/node_modules/lodash/string/trimRight.js
ilog-0.3.3 node_modules/babel/node_modules/lodash/string/trimRight.js
ilog-0.3.3 node_modules/babel-plugin-proto-to-assign/node_modules/lodash/string/trimRight.js
ilog-0.3.3 node_modules/contents/node_modules/lodash/string/trimRight.js
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/string/trimRight.js
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/inquirer/node_modules/lodash/string/trimRight.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/inquirer/node_modules/lodash/string/trimRight.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/string/trimRight.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/inquirer/node_modules/lodash/string/trimRight.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/string/trimRight.js
xcodebuild-helper-1.2.5 externals/ios-sim-master/node_modules/lodash/string/trimRight.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/string/trimRight.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/inquirer/node_modules/lodash/string/trimRight.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/string/trimRight.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/inquirer/node_modules/lodash/string/trimRight.js