UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

39 lines (38 loc) 1.1 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.lowerCase = void 0; const words_1 = __importDefault(require("./words")); const toString_1 = __importDefault(require("./toString")); /** * @ignore */ const reQuotes = /['\u2019]/g; /** * Converts `string`, as space separated words, to lower case. * * @since 5.6.0 * @category String * @param str The string to convert. * @returns Returns the lower cased string. * @see camelCase, kebabCase, snakeCase, startCase, upperCase, upperFirst * @example * * ```js * lowerCase('--Foo-Bar--') * // => 'foo bar' * * lowerCase('fooBar') * // => 'foo bar' * * lowerCase('__FOO_BAR__') * // => 'foo bar' * ``` */ function lowerCase(str) { return (0, words_1.default)((0, toString_1.default)(str).replace(reQuotes, "")).reduce((result, word, index) => (result + (index ? " " : "") + word.toLowerCase()), ""); } exports.lowerCase = lowerCase; exports.default = lowerCase;