@newdash/newdash
Version:
javascript/typescript utility library
35 lines (34 loc) • 1.09 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.upperCase = void 0;
const words_1 = __importDefault(require("./words"));
const toString_1 = __importDefault(require("./toString"));
/**
* Converts `string`, as space separated words, to upper case.
*
* @since 5.13.0
* @category String
* @param str The string to convert.
* @returns {string} Returns the upper cased string.
* @see [[camelCase]], [[kebabCase]], [[lowerCase]], [[snakeCase]], [[startCase]], [[upperFirst]]
* @example
*
* ```js
* upperCase('--foo-bar')
* // => 'FOO BAR'
*
* upperCase('fooBar')
* // => 'FOO BAR'
*
* upperCase('__foo_bar__')
* // => 'FOO BAR'
* ```
*/
function upperCase(str) {
return (0, words_1.default)((0, toString_1.default)(str).replace(/['\u2019]/g, "")).reduce((result, word, index) => (result + (index ? " " : "") + word.toUpperCase()), "");
}
exports.upperCase = upperCase;
exports.default = upperCase;