UNPKG

es-toolkit

Version:

A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.

24 lines (23 loc) 1.02 kB
const require_deburr = require("./deburr.js"); const require_words = require("./words.js"); const require_normalizeForCase = require("../_internal/normalizeForCase.js"); //#region src/compat/string/lowerCase.ts /** * Converts a string to lower case. * * Lower case is the naming convention in which each word is written in lowercase and separated by an space ( ) character. * * @param str - The string that is to be changed to lower case. * @returns The converted string to lower case. * * @example * const convertedStr1 = lowerCase('camelCase') // returns 'camel case' * const convertedStr2 = lowerCase('some whitespace') // returns 'some whitespace' * const convertedStr3 = lowerCase('hyphen-text') // returns 'hyphen text' * const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request' */ function lowerCase(str) { return require_words.words(require_normalizeForCase.normalizeForCase(require_deburr.deburr(str))).map((word) => word.toLowerCase()).join(" "); } //#endregion exports.lowerCase = lowerCase;