1 /*
  2  * isUpper.js - Character type is upper-case letter
  3  *
  4  * Copyright © 2012-2015, 2018, JEDLSoft
  5  *
  6  * Licensed under the Apache License, Version 2.0 (the "License");
  7  * you may not use this file except in compliance with the License.
  8  * You may obtain a copy of the License at
  9  *
 10  *     http://www.apache.org/licenses/LICENSE-2.0
 11  *
 12  * Unless required by applicable law or agreed to in writing, software
 13  * distributed under the License is distributed on an "AS IS" BASIS,
 14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  *
 16  * See the License for the specific language governing permissions and
 17  * limitations under the License.
 18  */
 19 
 20 // !data ctype_l
 21 
 22 var ilib = require("../index.js");
 23 
 24 var CType = require("./CType.js");
 25 var IString = require("./IString.js");
 26 
 27 /**
 28  * Return whether or not the first character is upper-case. For alphabetic
 29  * characters in scripts that do not make a distinction between upper- and
 30  * lower-case, this function always returns true.<p>
 31  *
 32  * @static
 33  * @param {string|IString|number} ch character or code point to examine
 34  * @return {boolean} true if the first character is upper-case.
 35  */
 36 var isUpper = function (ch) {
 37     var num;
 38     switch (typeof(ch)) {
 39         case 'number':
 40             num = ch;
 41             break;
 42         case 'string':
 43             num = IString.toCodePoint(ch, 0);
 44             break;
 45         case 'undefined':
 46             return false;
 47         default:
 48             num = ch._toCodePoint(0);
 49             break;
 50     }
 51 
 52     return ilib.data.ctype_l ? CType._inRange(num, 'Lu', ilib.data.ctype_l) : (num >= 0x41 && num <= 0x5A);
 53 };
 54 
 55 /**
 56  * @protected
 57  * @param {boolean} sync
 58  * @param {Object|undefined} loadParams
 59  * @param {function(*)|undefined} onLoad
 60  */
 61 isUpper._init = function (sync, loadParams, onLoad) {
 62     CType._load("ctype_l", sync, loadParams, onLoad);
 63 };
 64 
 65 module.exports = isUpper;