@use 'sass:string';

/**
 * Removes whitespaces from both ends of a given string.
 *
 * @param    {string}    $string    The string to trim.
 *
 * @return   {string}    The string without whitespaces on both ends of it.
 */
@function str-trim($string) {
	$string: #{$string};

	@while (string.index($string, ' ') == 1) {
		$string: string.slice($string, 2);
	}

	@while (string.slice($string, -1) == ' ') {
		$string: string.slice($string, 0, -2);
	}

	@return $string;
}
