UNPKG

661 BJavaScriptView Raw
1/**
2 * Convert string into upper case.
3 * @memberof module:stringcase/lib
4 * @function uppercase
5 * @param {string} str - String to convert.
6 * @returns {string} Upper case string.
7 */
8
9'use strict'
10
11/** @lends uppercase */
12function uppercase (str) {
13 str = String(str)
14 if (!str) {
15 return str
16 }
17 return str.toUpperCase()
18}
19
20/**
21 * Checks whether the string are uppercase.
22 * @memberof module:stringcase/lib
23 * @function uppercase.isUppercase
24 * @param {string} str - String to check
25 * @returns {boolean} - True if the string are uppercase.
26 */
27uppercase.isUppercase = function (str) {
28 return str && !/[a-z]+/.test(str)
29}
30
31module.exports = uppercase
\No newline at end of file