Removes trailing whitespace or specified characters from string
npx @tessl/cli install tessl/npm-lodash--trimend@4.5.0A modular lodash utility function that removes trailing whitespace or specified characters from string. This package provides precise string manipulation for trailing character removal with full Unicode support and performance optimization for common use cases.
npm install lodash.trimendconst trimEnd = require("lodash.trimend");For ES modules:
import trimEnd from "lodash.trimend";import trimEnd from "lodash.trimend";
// Remove trailing whitespace
const text = trimEnd(" hello world ");
console.log(text); // " hello world"
// Remove specific trailing characters
const path = trimEnd("/path/to/resource///", "/");
console.log(path); // "/path/to/resource"
// Works with Unicode characters
const unicode = trimEnd("héllo wörld ");
console.log(unicode); // "héllo wörld"Removes trailing whitespace or specified characters from strings with full Unicode support.
/**
* 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 an iteratee for functions like `_.map`.
* @returns {string} Returns the trimmed string.
* @example
*
* _.trimEnd(' abc ');
* // => ' abc'
*
* _.trimEnd('-_-abc-_-', '_-');
* // => '-_-abc'
*/
function trimEnd(string, chars, guard);Parameters:
_.map.Returns:
Usage Examples:
// Basic whitespace trimming (default behavior)
trimEnd(" abc ");
// => " abc"
// Custom character trimming
trimEnd("-_-abc-_-", "_-");
// => "-_-abc"
// Works with Unicode characters
trimEnd("héllo wörld ");
// => "héllo wörld"