@simongrasinovski/str-utils
Version:
A lightweight utility library for effortless string manipulation. Simplify common tasks like case validation, conversion and formatting with easy-to-use functions that enhance your JavaScript applications
21 lines (19 loc) • 502 B
JavaScript
;
var _require = require('./utils'),
ensureString = _require.ensureString;
/**
* Reverses the given string.
*
* @function
* @param {string} input - The string to reverse.
* @returns {string} Reversed string.
*
* @throws {TypeError} Throws an error if the input is not a string.
*
* @example
* const result = reverse('hello');
* console.log(result); // 'olleh'
*/
module.exports = ensureString(function (input) {
return Array.from(input).reverse().join('');
});