ilib-locale
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -18,3 +18,3 @@ /* | ||
root["Locale"] = factory(root["ilibEnv"]); | ||
})(self, function(__WEBPACK_EXTERNAL_MODULE_ilib_env__) { | ||
})(self, (__WEBPACK_EXTERNAL_MODULE_ilib_env__) => { | ||
return /******/ (() => { // webpackBootstrap | ||
@@ -30,3 +30,3 @@ /******/ "use strict"; | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _locale_a2toa3regmap_json__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../locale/a2toa3regmap.json */ \"./locale/a2toa3regmap.json\");\n/* harmony import */ var _locale_a1toa3langmap_json__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../locale/a1toa3langmap.json */ \"./locale/a1toa3langmap.json\");\n/* harmony import */ var _locale_scripts_json__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../locale/scripts.json */ \"./locale/scripts.json\");\n/* harmony import */ var ilib_env__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ilib-env */ \"ilib-env\");\n/* harmony import */ var ilib_env__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(ilib_env__WEBPACK_IMPORTED_MODULE_3__);\nfunction _typeof(obj){\"@babel/helpers - typeof\";if(typeof Symbol===\"function\"&&typeof Symbol.iterator===\"symbol\"){_typeof=function _typeof(obj){return typeof obj}}else{_typeof=function _typeof(obj){return obj&&typeof Symbol===\"function\"&&obj.constructor===Symbol&&obj!==Symbol.prototype?\"symbol\":typeof obj}}return _typeof(obj)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError(\"Cannot call a class as a function\")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if(\"value\"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}function indexOf(array,obj){if(!array||!obj){return-1}if(typeof array.indexOf===\"function\"){return array.indexOf(obj)}else{for(var i=0;i<array.length;i++){if(array[i]===obj){return i}}return-1}};var Locale=function(){function Locale(language,region,variant,script){_classCallCheck(this,Locale);if(typeof region===\"undefined\"&&typeof variant===\"undefined\"&&typeof script===\"undefined\"){var spec=language||ilib_env__WEBPACK_IMPORTED_MODULE_3__.getLocale();if(typeof spec===\"string\"){var parts=spec.split(/[-_]/g);for(var i=0;i<parts.length;i++){if(Locale._isLanguageCode(parts[i])){this.language=parts[i]}else if(Locale._isRegionCode(parts[i])){this.region=parts[i]}else if(Locale._isScriptCode(parts[i])){this.script=parts[i]}else{this.variant=parts[i]}}this.language=this.language||undefined;this.region=this.region||undefined;this.script=this.script||undefined;this.variant=this.variant||undefined}else if(_typeof(spec)===\"object\"){this.language=spec.language||undefined;this.region=spec.region||undefined;this.script=spec.script||undefined;this.variant=spec.variant||undefined}}else{if(language&&typeof language===\"string\"){language=language.trim();this.language=language.length>0?language.toLowerCase():undefined}else{this.language=undefined}if(region&&typeof region===\"string\"){region=region.trim();this.region=region.length>0?region.toUpperCase():undefined}else{this.region=undefined}if(variant&&typeof variant===\"string\"){variant=variant.trim();this.variant=variant.length>0?variant:undefined}else{this.variant=undefined}if(script&&typeof script===\"string\"){script=script.trim();this.script=script.length>0?script:undefined}else{this.script=undefined}}this._genSpec()}_createClass(Locale,[{key:\"_genSpec\",value:function _genSpec(){this.spec=[this.language,this.script,this.region,this.variant].filter(function(part){return part}).join(\"-\")}},{key:\"getLanguage\",value:function getLanguage(){return this.language}},{key:\"getLanguageAlpha3\",value:function getLanguageAlpha3(){return Locale.languageAlpha1ToAlpha3(this.language)}},{key:\"getRegion\",value:function getRegion(){return this.region}},{key:\"getRegionAlpha3\",value:function getRegionAlpha3(){return Locale.regionAlpha2ToAlpha3(this.region)}},{key:\"getScript\",value:function getScript(){return this.script}},{key:\"getVariant\",value:function getVariant(){return this.variant}},{key:\"getSpec\",value:function getSpec(){if(!this.spec)this._genSpec();return this.spec}},{key:\"getLangSpec\",value:function getLangSpec(){var spec=this.language;if(spec&&this.script){spec+=\"-\"+this.script}return spec||\"\"}},{key:\"toString\",value:function toString(){return this.getSpec()}},{key:\"equals\",value:function equals(other){return this.language===other.language&&this.region===other.region&&this.script===other.script&&this.variant===other.variant}},{key:\"isValid\",value:function isValid(){if(!this.language&&!this.script&&!this.region)return false;return!!((!this.language||Locale._isLanguageCode(this.language)&&Locale.a1toa3langmap[this.language])&&(!this.script||Locale._isScriptCode(this.script)&&Locale.iso15924.indexOf(this.script)>-1)&&(!this.region||Locale._isRegionCode(this.region)&&Locale.a2toa3regmap[this.region]))}}]);return Locale}();;Locale.a2toa3regmap=_locale_a2toa3regmap_json__WEBPACK_IMPORTED_MODULE_0__;Locale.a1toa3langmap=_locale_a1toa3langmap_json__WEBPACK_IMPORTED_MODULE_1__;Locale.iso15924=_locale_scripts_json__WEBPACK_IMPORTED_MODULE_2__.scripts;Locale._notLower=function(str){var ch=str.charCodeAt(0);return ch<97||ch>122};Locale._notUpper=function(str){var ch=str.charCodeAt(0);return ch<65||ch>90};Locale._notDigit=function(str){var ch=str.charCodeAt(0);return ch<48||ch>57};Locale._isLanguageCode=function(str){if(typeof str===\"undefined\"||str.length<2||str.length>3){return false}for(var i=0;i<str.length;i++){if(Locale._notLower(str.charAt(i))){return false}}return true};Locale._isRegionCode=function(str){var i;if(typeof str===\"undefined\"||str.length<2||str.length>3){return false}if(str.length===2){for(i=0;i<str.length;i++){if(Locale._notUpper(str.charAt(i))){return false}}}else{for(i=0;i<str.length;i++){if(Locale._notDigit(str.charAt(i))){return false}}}return true};Locale._isScriptCode=function(str){if(typeof str===\"undefined\"||str.length!==4||Locale._notUpper(str.charAt(0))){return false}for(var i=1;i<4;i++){if(Locale._notLower(str.charAt(i))){return false}}return true};Locale.regionAlpha2ToAlpha3=function(alpha2){return Locale.a2toa3regmap[alpha2]||alpha2};Locale.languageAlpha1ToAlpha3=function(alpha1){return Locale.a1toa3langmap[alpha1]||alpha1};/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Locale);\n\n//# sourceURL=webpack://Locale/./src/Locale.js?"); | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _locale_a2toa3regmap_json__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../locale/a2toa3regmap.json */ \"./locale/a2toa3regmap.json\");\n/* harmony import */ var _locale_a1toa3langmap_json__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../locale/a1toa3langmap.json */ \"./locale/a1toa3langmap.json\");\n/* harmony import */ var _locale_scripts_json__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../locale/scripts.json */ \"./locale/scripts.json\");\n/* harmony import */ var ilib_env__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ilib-env */ \"ilib-env\");\n/* harmony import */ var ilib_env__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(ilib_env__WEBPACK_IMPORTED_MODULE_3__);\nfunction _typeof(obj){\"@babel/helpers - typeof\";return _typeof=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&\"function\"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?\"symbol\":typeof obj},_typeof(obj)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError(\"Cannot call a class as a function\")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if(\"value\"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,\"prototype\",{writable:false});return Constructor}function indexOf(array,obj){if(!array||!obj){return-1}if(typeof array.indexOf===\"function\"){return array.indexOf(obj)}else{for(var i=0;i<array.length;i++){if(array[i]===obj){return i}}return-1}};var Locale=function(){function Locale(language,region,variant,script){_classCallCheck(this,Locale);if(typeof region===\"undefined\"&&typeof variant===\"undefined\"&&typeof script===\"undefined\"){var spec=language||ilib_env__WEBPACK_IMPORTED_MODULE_3__.getLocale();if(typeof spec===\"string\"){var parts=spec.split(/[-_]/g);for(var i=0;i<parts.length;i++){if(Locale._isLanguageCode(parts[i])){this.language=parts[i]}else if(Locale._isRegionCode(parts[i])){this.region=parts[i]}else if(Locale._isScriptCode(parts[i])){this.script=parts[i]}else{this.variant=parts[i]}}this.language=this.language||undefined;this.region=this.region||undefined;this.script=this.script||undefined;this.variant=this.variant||undefined}else if(_typeof(spec)===\"object\"){this.language=spec.language||undefined;this.region=spec.region||undefined;this.script=spec.script||undefined;this.variant=spec.variant||undefined}}else{if(language&&typeof language===\"string\"){language=language.trim();this.language=language.length>0?language.toLowerCase():undefined}else{this.language=undefined}if(region&&typeof region===\"string\"){region=region.trim();this.region=region.length>0?region.toUpperCase():undefined}else{this.region=undefined}if(variant&&typeof variant===\"string\"){variant=variant.trim();this.variant=variant.length>0?variant:undefined}else{this.variant=undefined}if(script&&typeof script===\"string\"){script=script.trim();this.script=script.length>0?script:undefined}else{this.script=undefined}}this._genSpec()}_createClass(Locale,[{key:\"_genSpec\",value:function _genSpec(){this.spec=[this.language,this.script,this.region,this.variant].filter(function(part){return part}).join(\"-\")}},{key:\"getLanguage\",value:function getLanguage(){return this.language}},{key:\"getLanguageAlpha3\",value:function getLanguageAlpha3(){return Locale.languageAlpha1ToAlpha3(this.language)}},{key:\"getRegion\",value:function getRegion(){return this.region}},{key:\"getRegionAlpha3\",value:function getRegionAlpha3(){return Locale.regionAlpha2ToAlpha3(this.region)}},{key:\"getScript\",value:function getScript(){return this.script}},{key:\"getVariant\",value:function getVariant(){return this.variant}},{key:\"getSpec\",value:function getSpec(){if(!this.spec)this._genSpec();return this.spec}},{key:\"getLangSpec\",value:function getLangSpec(){var spec=this.language;if(spec&&this.script){spec+=\"-\"+this.script}return spec||\"\"}},{key:\"toString\",value:function toString(){return this.getSpec()}},{key:\"equals\",value:function equals(other){return this.language===other.language&&this.region===other.region&&this.script===other.script&&this.variant===other.variant}},{key:\"isValid\",value:function isValid(){if(!this.language&&!this.script&&!this.region)return false;return!!((!this.language||Locale._isLanguageCode(this.language)&&Locale.a1toa3langmap[this.language])&&(!this.script||Locale._isScriptCode(this.script)&&Locale.iso15924.indexOf(this.script)>-1)&&(!this.region||Locale._isRegionCode(this.region)&&Locale.a2toa3regmap[this.region]))}}]);return Locale}();;Locale.a2toa3regmap=_locale_a2toa3regmap_json__WEBPACK_IMPORTED_MODULE_0__;Locale.a1toa3langmap=_locale_a1toa3langmap_json__WEBPACK_IMPORTED_MODULE_1__;Locale.iso15924=_locale_scripts_json__WEBPACK_IMPORTED_MODULE_2__.scripts;Locale._notLower=function(str){var ch=str.charCodeAt(0);return ch<97||ch>122};Locale._notUpper=function(str){var ch=str.charCodeAt(0);return ch<65||ch>90};Locale._notDigit=function(str){var ch=str.charCodeAt(0);return ch<48||ch>57};Locale._isLanguageCode=function(str){if(typeof str===\"undefined\"||str.length<2||str.length>3){return false}for(var i=0;i<str.length;i++){if(Locale._notLower(str.charAt(i))){return false}}return true};Locale._isRegionCode=function(str){var i;if(typeof str===\"undefined\"||str.length<2||str.length>3){return false}if(str.length===2){for(i=0;i<str.length;i++){if(Locale._notUpper(str.charAt(i))){return false}}}else{for(i=0;i<str.length;i++){if(Locale._notDigit(str.charAt(i))){return false}}}return true};Locale._isScriptCode=function(str){if(typeof str===\"undefined\"||str.length!==4||Locale._notUpper(str.charAt(0))){return false}for(var i=1;i<4;i++){if(Locale._notLower(str.charAt(i))){return false}}return true};Locale.regionAlpha2ToAlpha3=function(alpha2){return Locale.a2toa3regmap[alpha2]||alpha2};Locale.languageAlpha1ToAlpha3=function(alpha1){return Locale.a1toa3langmap[alpha1]||alpha1};/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Locale);\n\n//# sourceURL=webpack://Locale/./src/Locale.js?"); | ||
@@ -33,0 +33,0 @@ /***/ }), |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _a2toa3regmap=_interopRequireDefault(require("../locale/a2toa3regmap.json"));var _a1toa3langmap=_interopRequireDefault(require("../locale/a1toa3langmap.json"));var _scripts=_interopRequireDefault(require("../locale/scripts.json"));var ilibEnv=_interopRequireWildcard(require("ilib-env"));function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap;var cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj}if(obj===null||_typeof(obj)!=="object"&&typeof obj!=="function"){return{"default":obj}}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj)}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc)}else{newObj[key]=obj[key]}}}newObj["default"]=obj;if(cache){cache.set(obj,newObj)}return newObj}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _typeof(obj){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj}}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj}}return _typeof(obj)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}function indexOf(array,obj){if(!array||!obj){return-1}if(typeof array.indexOf==="function"){return array.indexOf(obj)}else{for(var i=0;i<array.length;i++){if(array[i]===obj){return i}}return-1}};var Locale=function(){function Locale(language,region,variant,script){_classCallCheck(this,Locale);if(typeof region==="undefined"&&typeof variant==="undefined"&&typeof script==="undefined"){var spec=language||ilibEnv.getLocale();if(typeof spec==="string"){var parts=spec.split(/[-_]/g);for(var i=0;i<parts.length;i++){if(Locale._isLanguageCode(parts[i])){this.language=parts[i]}else if(Locale._isRegionCode(parts[i])){this.region=parts[i]}else if(Locale._isScriptCode(parts[i])){this.script=parts[i]}else{this.variant=parts[i]}}this.language=this.language||undefined;this.region=this.region||undefined;this.script=this.script||undefined;this.variant=this.variant||undefined}else if(_typeof(spec)==="object"){this.language=spec.language||undefined;this.region=spec.region||undefined;this.script=spec.script||undefined;this.variant=spec.variant||undefined}}else{if(language&&typeof language==="string"){language=language.trim();this.language=language.length>0?language.toLowerCase():undefined}else{this.language=undefined}if(region&&typeof region==="string"){region=region.trim();this.region=region.length>0?region.toUpperCase():undefined}else{this.region=undefined}if(variant&&typeof variant==="string"){variant=variant.trim();this.variant=variant.length>0?variant:undefined}else{this.variant=undefined}if(script&&typeof script==="string"){script=script.trim();this.script=script.length>0?script:undefined}else{this.script=undefined}}this._genSpec()}_createClass(Locale,[{key:"_genSpec",value:function _genSpec(){this.spec=[this.language,this.script,this.region,this.variant].filter(function(part){return part}).join("-")}},{key:"getLanguage",value:function getLanguage(){return this.language}},{key:"getLanguageAlpha3",value:function getLanguageAlpha3(){return Locale.languageAlpha1ToAlpha3(this.language)}},{key:"getRegion",value:function getRegion(){return this.region}},{key:"getRegionAlpha3",value:function getRegionAlpha3(){return Locale.regionAlpha2ToAlpha3(this.region)}},{key:"getScript",value:function getScript(){return this.script}},{key:"getVariant",value:function getVariant(){return this.variant}},{key:"getSpec",value:function getSpec(){if(!this.spec)this._genSpec();return this.spec}},{key:"getLangSpec",value:function getLangSpec(){var spec=this.language;if(spec&&this.script){spec+="-"+this.script}return spec||""}},{key:"toString",value:function toString(){return this.getSpec()}},{key:"equals",value:function equals(other){return this.language===other.language&&this.region===other.region&&this.script===other.script&&this.variant===other.variant}},{key:"isValid",value:function isValid(){if(!this.language&&!this.script&&!this.region)return false;return!!((!this.language||Locale._isLanguageCode(this.language)&&Locale.a1toa3langmap[this.language])&&(!this.script||Locale._isScriptCode(this.script)&&Locale.iso15924.indexOf(this.script)>-1)&&(!this.region||Locale._isRegionCode(this.region)&&Locale.a2toa3regmap[this.region]))}}]);return Locale}();;Locale.a2toa3regmap=_a2toa3regmap["default"];Locale.a1toa3langmap=_a1toa3langmap["default"];Locale.iso15924=_scripts["default"].scripts;Locale._notLower=function(str){var ch=str.charCodeAt(0);return ch<97||ch>122};Locale._notUpper=function(str){var ch=str.charCodeAt(0);return ch<65||ch>90};Locale._notDigit=function(str){var ch=str.charCodeAt(0);return ch<48||ch>57};Locale._isLanguageCode=function(str){if(typeof str==="undefined"||str.length<2||str.length>3){return false}for(var i=0;i<str.length;i++){if(Locale._notLower(str.charAt(i))){return false}}return true};Locale._isRegionCode=function(str){var i;if(typeof str==="undefined"||str.length<2||str.length>3){return false}if(str.length===2){for(i=0;i<str.length;i++){if(Locale._notUpper(str.charAt(i))){return false}}}else{for(i=0;i<str.length;i++){if(Locale._notDigit(str.charAt(i))){return false}}}return true};Locale._isScriptCode=function(str){if(typeof str==="undefined"||str.length!==4||Locale._notUpper(str.charAt(0))){return false}for(var i=1;i<4;i++){if(Locale._notLower(str.charAt(i))){return false}}return true};Locale.regionAlpha2ToAlpha3=function(alpha2){return Locale.a2toa3regmap[alpha2]||alpha2};Locale.languageAlpha1ToAlpha3=function(alpha1){return Locale.a1toa3langmap[alpha1]||alpha1};var _default=Locale;exports["default"]=_default;module.exports=exports.default; | ||
"use strict";require("core-js/modules/es.object.define-property.js");require("core-js/modules/es.symbol.js");require("core-js/modules/es.symbol.description.js");require("core-js/modules/es.symbol.iterator.js");require("core-js/modules/es.array.iterator.js");require("core-js/modules/es.string.iterator.js");require("core-js/modules/web.dom-collections.iterator.js");require("core-js/modules/es.weak-map.js");require("core-js/modules/esnext.weak-map.delete-all.js");require("core-js/modules/es.object.get-own-property-descriptor.js");Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;require("core-js/modules/es.array.index-of.js");require("core-js/modules/es.regexp.exec.js");require("core-js/modules/es.string.split.js");require("core-js/modules/es.string.trim.js");require("core-js/modules/es.array.join.js");require("core-js/modules/es.array.filter.js");require("core-js/modules/es.object.to-string.js");var _a2toa3regmap=_interopRequireDefault(require("../locale/a2toa3regmap.json"));var _a1toa3langmap=_interopRequireDefault(require("../locale/a1toa3langmap.json"));var _scripts=_interopRequireDefault(require("../locale/scripts.json"));var ilibEnv=_interopRequireWildcard(require("ilib-env"));function _getRequireWildcardCache(nodeInterop){if(typeof WeakMap!=="function")return null;var cacheBabelInterop=new WeakMap;var cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function _getRequireWildcardCache(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireWildcard(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule){return obj}if(obj===null||_typeof(obj)!=="object"&&typeof obj!=="function"){return{"default":obj}}var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj)){return cache.get(obj)}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(key!=="default"&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc)}else{newObj[key]=obj[key]}}}newObj["default"]=obj;if(cache){cache.set(obj,newObj)}return newObj}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_typeof(obj)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor}function indexOf(array,obj){if(!array||!obj){return-1}if(typeof array.indexOf==="function"){return array.indexOf(obj)}else{for(var i=0;i<array.length;i++){if(array[i]===obj){return i}}return-1}};var Locale=function(){function Locale(language,region,variant,script){_classCallCheck(this,Locale);if(typeof region==="undefined"&&typeof variant==="undefined"&&typeof script==="undefined"){var spec=language||ilibEnv.getLocale();if(typeof spec==="string"){var parts=spec.split(/[-_]/g);for(var i=0;i<parts.length;i++){if(Locale._isLanguageCode(parts[i])){this.language=parts[i]}else if(Locale._isRegionCode(parts[i])){this.region=parts[i]}else if(Locale._isScriptCode(parts[i])){this.script=parts[i]}else{this.variant=parts[i]}}this.language=this.language||undefined;this.region=this.region||undefined;this.script=this.script||undefined;this.variant=this.variant||undefined}else if(_typeof(spec)==="object"){this.language=spec.language||undefined;this.region=spec.region||undefined;this.script=spec.script||undefined;this.variant=spec.variant||undefined}}else{if(language&&typeof language==="string"){language=language.trim();this.language=language.length>0?language.toLowerCase():undefined}else{this.language=undefined}if(region&&typeof region==="string"){region=region.trim();this.region=region.length>0?region.toUpperCase():undefined}else{this.region=undefined}if(variant&&typeof variant==="string"){variant=variant.trim();this.variant=variant.length>0?variant:undefined}else{this.variant=undefined}if(script&&typeof script==="string"){script=script.trim();this.script=script.length>0?script:undefined}else{this.script=undefined}}this._genSpec()}_createClass(Locale,[{key:"_genSpec",value:function _genSpec(){this.spec=[this.language,this.script,this.region,this.variant].filter(function(part){return part}).join("-")}},{key:"getLanguage",value:function getLanguage(){return this.language}},{key:"getLanguageAlpha3",value:function getLanguageAlpha3(){return Locale.languageAlpha1ToAlpha3(this.language)}},{key:"getRegion",value:function getRegion(){return this.region}},{key:"getRegionAlpha3",value:function getRegionAlpha3(){return Locale.regionAlpha2ToAlpha3(this.region)}},{key:"getScript",value:function getScript(){return this.script}},{key:"getVariant",value:function getVariant(){return this.variant}},{key:"getSpec",value:function getSpec(){if(!this.spec)this._genSpec();return this.spec}},{key:"getLangSpec",value:function getLangSpec(){var spec=this.language;if(spec&&this.script){spec+="-"+this.script}return spec||""}},{key:"toString",value:function toString(){return this.getSpec()}},{key:"equals",value:function equals(other){return this.language===other.language&&this.region===other.region&&this.script===other.script&&this.variant===other.variant}},{key:"isValid",value:function isValid(){if(!this.language&&!this.script&&!this.region)return false;return!!((!this.language||Locale._isLanguageCode(this.language)&&Locale.a1toa3langmap[this.language])&&(!this.script||Locale._isScriptCode(this.script)&&Locale.iso15924.indexOf(this.script)>-1)&&(!this.region||Locale._isRegionCode(this.region)&&Locale.a2toa3regmap[this.region]))}}]);return Locale}();;Locale.a2toa3regmap=_a2toa3regmap["default"];Locale.a1toa3langmap=_a1toa3langmap["default"];Locale.iso15924=_scripts["default"].scripts;Locale._notLower=function(str){var ch=str.charCodeAt(0);return ch<97||ch>122};Locale._notUpper=function(str){var ch=str.charCodeAt(0);return ch<65||ch>90};Locale._notDigit=function(str){var ch=str.charCodeAt(0);return ch<48||ch>57};Locale._isLanguageCode=function(str){if(typeof str==="undefined"||str.length<2||str.length>3){return false}for(var i=0;i<str.length;i++){if(Locale._notLower(str.charAt(i))){return false}}return true};Locale._isRegionCode=function(str){var i;if(typeof str==="undefined"||str.length<2||str.length>3){return false}if(str.length===2){for(i=0;i<str.length;i++){if(Locale._notUpper(str.charAt(i))){return false}}}else{for(i=0;i<str.length;i++){if(Locale._notDigit(str.charAt(i))){return false}}}return true};Locale._isScriptCode=function(str){if(typeof str==="undefined"||str.length!==4||Locale._notUpper(str.charAt(0))){return false}for(var i=1;i<4;i++){if(Locale._notLower(str.charAt(i))){return false}}return true};Locale.regionAlpha2ToAlpha3=function(alpha2){return Locale.a2toa3regmap[alpha2]||alpha2};Locale.languageAlpha1ToAlpha3=function(alpha1){return Locale.a1toa3langmap[alpha1]||alpha1};var _default=Locale;exports["default"]=_default;module.exports=exports.default; | ||
//# sourceMappingURL=Locale.js.map |
{ | ||
"name": "ilib-locale", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"main": "./lib/Locale.js", | ||
@@ -69,30 +69,29 @@ "description": "A BCP-47/IETF locale specifier parser/validator", | ||
"devDependencies": { | ||
"@babel/core": "^7.15.5", | ||
"@babel/preset-env": "^7.15.6", | ||
"@babel/register": "^7.15.3", | ||
"@babel/runtime": "^7.15.4", | ||
"acorn": "^6.4.1", | ||
"acorn-jsx": "^5.3.2", | ||
"@babel/core": "^7.17.10", | ||
"@babel/preset-env": "^7.17.10", | ||
"@babel/register": "^7.17.7", | ||
"@babel/runtime": "^7.17.9", | ||
"assertextras": "^1.1.0", | ||
"babel-loader": "^8.2.2", | ||
"babel-loader": "^8.2.5", | ||
"babel-plugin-add-module-exports": "^1.0.4", | ||
"docdash": "^1.2.0", | ||
"grunt": "^1.4.1", | ||
"grunt": "^1.5.3", | ||
"grunt-babel": "^8.0.0", | ||
"grunt-cli": "^1.4.3", | ||
"grunt-contrib-clean": "^2.0.0", | ||
"grunt-contrib-jshint": "^2.1.0", | ||
"grunt-contrib-nodeunit": "^2.1.0", | ||
"grunt-contrib-uglify": "^4.0.1", | ||
"jsdoc": "^3.6.6", | ||
"jsdoc-to-markdown": "^7.0.1", | ||
"grunt-contrib-clean": "^2.0.1", | ||
"grunt-contrib-jshint": "^3.2.0", | ||
"grunt-contrib-nodeunit": "^4.0.0", | ||
"grunt-contrib-uglify": "^5.2.1", | ||
"jsdoc": "^3.6.10", | ||
"jsdoc-to-markdown": "^7.1.1", | ||
"load-grunt-tasks": "^5.1.0", | ||
"nodeunit": "^0.11.3", | ||
"open-cli": "^6.0.1", | ||
"webpack": "^5.53.0", | ||
"webpack-cli": "^4.8.0" | ||
"open-cli": "^7.0.1", | ||
"webpack": "^5.72.1", | ||
"webpack-cli": "^4.9.2" | ||
}, | ||
"dependencies": { | ||
"ilib-env": "^1.0.1" | ||
"core-js": "^3.22.5", | ||
"ilib-env": "^1.2.1" | ||
} | ||
} |
@@ -120,4 +120,8 @@ # ilib-locale | ||
## v1.1.0 | ||
### v1.1.1 | ||
* Update dependencies and target the right node & browser versions with babel | ||
### v1.1.0 | ||
- added the ability to parse locale specs that contain underscores | ||
@@ -129,7 +133,7 @@ instead of dashes. Some locale specs for Java properties file names | ||
## v1.0.2 | ||
### v1.0.2 | ||
- fixed some incorrect unit tests | ||
## v1.0.1 | ||
### v1.0.1 | ||
@@ -141,3 +145,3 @@ - do not put the module name into the package.json, because it screws | ||
## v1.0.0 | ||
### v1.0.0 | ||
@@ -144,0 +148,0 @@ - Code taken from ilib 14.7.0 and converts to an ES6 module. |
Sorry, the diff of this file is not supported yet
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
106634
22
1270
148
2
1
80
+ Addedcore-js@^3.22.5
+ Addedcore-js@3.40.0(transitive)
Updatedilib-env@^1.2.1