UNPKG

@resk/core

Version:

An innovative TypeScript framework that empowers developers to build applications with a fully decorator-based architecture for efficient resource management. By combining the power of decorators with a resource-oriented design, DecorRes enhances code cla

1 lines 1.71 kB
'use strict';var u=require('../i18n'),C=require('../utils/defaultStr'),c=require('../utils/isNonNullString'),object=require('../utils/object'),n=require('./countries'),types=require('./types');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var u__default=/*#__PURE__*/_interopDefault(u);var C__default=/*#__PURE__*/_interopDefault(C);var c__default=/*#__PURE__*/_interopDefault(c);var n__default=/*#__PURE__*/_interopDefault(n);const y={};Object.keys(n__default.default).map(i=>{const t=n__default.default[i];y[t.dialCode]=t.code;});class a{static isValid(t){return object.isObj(t)&&c__default.default(t.code)}static getPhoneNumberExample(t){var r;return C__default.default((r=this.getCountry(t))==null?void 0:r.phoneNumberExample)}static getFlag(t){var r;return C__default.default((r=this.getCountry(t))==null?void 0:r.flag)}static getCurrency(t){var r;return (r=this.getCountry(t))==null?void 0:r.currency}static setCountry(t){this.isValid(t)&&(this.countries[t.code]=t);}static getCountry(t){if(c__default.default(t))return object.extendObj({},u__default.default.t(`countries.${t}`),this.countries[t])}static getCountries(){const t=u__default.default.t("countries");return object.isObj(t)?object.extendObj({},t,this.countries):this.countries}static setCountries(t){if(!object.isObj(t))return this.countries;for(const r in t){const s=t[r];this.isValid(s)&&(this.countries[r]=object.extendObj({},this.countries[r],s));}return this.countries}}a.countries=n__default.default;exports.CountriesManager=a;Object.keys(types).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return types[k]}})});