@arkyn/shared 3.0.1-beta.7 → 3.0.1-beta.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +452 -67
- package/dist/bundle.js +2451 -0
- package/dist/bundle.umd.cjs +6 -0
- package/dist/formats/formatToCapitalizeFirstWordLetter.d.ts +35 -0
- package/dist/formats/formatToCapitalizeFirstWordLetter.d.ts.map +1 -0
- package/dist/formats/formatToCapitalizeFirstWordLetter.js +42 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/services/isHtml.d.ts +22 -0
- package/dist/services/isHtml.d.ts.map +1 -0
- package/dist/services/isHtml.js +24 -0
- package/package.json +25 -6
- package/src/formats/formatDate.ts +0 -92
- package/src/formats/formatJsonObject.ts +0 -90
- package/src/formats/formatJsonString.ts +0 -50
- package/src/formats/formatToCep.ts +0 -39
- package/src/formats/formatToCnpj.ts +0 -40
- package/src/formats/formatToCpf.ts +0 -40
- package/src/formats/formatToCpfCnpj.ts +0 -38
- package/src/formats/formatToCurrency.ts +0 -63
- package/src/formats/formatToDate.ts +0 -70
- package/src/formats/formatToEllipsis.ts +0 -25
- package/src/formats/formatToHiddenDigits.ts +0 -92
- package/src/formats/formatToPhone.ts +0 -170
- package/src/generators/generateColorByString.ts +0 -33
- package/src/generators/generateId.ts +0 -61
- package/src/generators/generateSlug.ts +0 -31
- package/src/index.ts +0 -36
- package/src/services/calculateCardInstallment.ts +0 -73
- package/src/services/ensureQuotes.ts +0 -25
- package/src/services/maskSensitiveData.ts +0 -68
- package/src/services/removeCurrencySymbols.ts +0 -29
- package/src/services/removeNonNumeric.ts +0 -20
- package/src/services/stripHtmlTags.ts +0 -20
- package/src/services/truncateLargeFields.ts +0 -69
- package/src/validations/validateCep.ts +0 -41
- package/src/validations/validateCnpj.ts +0 -65
- package/src/validations/validateCpf.ts +0 -62
- package/src/validations/validateDate.ts +0 -86
- package/src/validations/validatePassword.ts +0 -41
- package/src/validations/validatePhone.ts +0 -50
- package/src/validations/validateRg.ts +0 -37
- package/tsconfig.json +0 -20
- package/vitest.config.ts +0 -5
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
(function(o,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(o=typeof globalThis<"u"?globalThis:o||self,f(o["@arkyn/shared"]={}))})(this,function(o){"use strict";function f(n,a){const s=_=>_.toString().padStart(2,"0"),e={YYYY:n.getFullYear().toString(),YY:n.getFullYear().toString().slice(-2),MM:s(n.getMonth()+1),DD:s(n.getDate()),hh:s(n.getHours()),mm:s(n.getMinutes()),ss:s(n.getSeconds())};return a.replace(/YYYY|YY|MM|DD|hh|mm|ss/g,_=>e[_])}const Y=([n,a="00:00:00"],s,e,_=0)=>{const t=n.split(/[-/]/).map(Number),r=a.split(".")[0].split(":").map(Number);let i,c,l;const[d=0,y=0,h=0]=r;switch(s){case"brazilianDate":[i,c,l]=t;break;case"isoDate":[l,c,i]=t;break;case"timestamp":[l,c,i]=t.map(Number);break;default:throw new Error("Invalid input format")}const g=new Date(l,c-1,i,d,y,h);if(isNaN(g.getTime()))throw new Error("Invalid date");return g.setUTCHours(g.getUTCHours()+_),f(g,e)},p=(n,a)=>{const s=" ".repeat(a);let e="";if(typeof n=="object"&&n!==null)if(Array.isArray(n))n.length===0?e+="[]":(e+=`[
|
|
2
|
+
`,n.forEach((_,t)=>{e+=s+" "+p(_,a+1),t<n.length-1&&(e+=","),e+=`
|
|
3
|
+
`}),e+=s+"]");else{const _=Object.keys(n);_.length===0?e+="{}":(e+=`{
|
|
4
|
+
`,_.forEach((t,r)=>{e+=s+' "'+t+'": '+p(n[t],a+1),r<_.length-1&&(e+=","),e+=`
|
|
5
|
+
`}),e+=s+"}")}else if(typeof n=="string")try{const _=JSON.parse(n);e+=p(_,a)}catch{e+='"'+n+'"'}else e+=n;return e},U=n=>{try{const a=JSON.parse(n);return p(a,0)}catch(a){throw new Error(`Invalid JSON string
|
|
6
|
+
${a}`)}};function H(n){return n.split(" ").map(e=>{const _=e.charAt(0).toUpperCase(),t=e.slice(1).toLowerCase();return _+t}).join(" ")}const k=n=>n.replace(/[^0-9]/g,""),$=n=>{const s=k(n).match(/^(\d{5})(\d{3})$/);if(s)return`${s[1]}-${s[2]}`;throw new Error("Invalid CEP format")},F=n=>{const s=k(n).match(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/);if(s)return`${s[1]}.${s[2]}.${s[3]}/${s[4]}-${s[5]}`;throw new Error("Invalid CNPJ length")},S=n=>{const s=k(n).match(/^(\d{3})(\d{3})(\d{3})(\d{2})$/);if(s)return`${s[1]}.${s[2]}.${s[3]}-${s[4]}`;throw new Error("Invalid CPF format")},K=n=>{const a=n.replace(/\D/g,"");if(a.length===11)return S(a);if(a.length===14)return F(a);throw new Error("Invalid CPF or CNPJ length")},v=[{name:"Afghanistan",code:"+93",prefix:null,iso:"AF",flag:"https://cdn.kcak11.com/CountryFlags/countries/af.svg",mask:"__-___-____"},{name:"Aland Islands",code:"+358",prefix:null,iso:"AX",flag:"https://cdn.kcak11.com/CountryFlags/countries/ax.svg",mask:"(___) ___-__-__"},{name:"Albania",code:"+355",prefix:null,iso:"AL",flag:"https://cdn.kcak11.com/CountryFlags/countries/al.svg",mask:"(___) ___-___"},{name:"Algeria",code:"+213",prefix:null,iso:"DZ",flag:"https://cdn.kcak11.com/CountryFlags/countries/dz.svg",mask:"__-___-____"},{name:"American Samoa",code:"+1",prefix:"684",iso:"AS",flag:"https://cdn.kcak11.com/CountryFlags/countries/as.svg",mask:"(684) ___-____"},{name:"Andorra",code:"+376",prefix:null,iso:"AD",flag:"https://cdn.kcak11.com/CountryFlags/countries/ad.svg",mask:"___-___"},{name:"Angola",code:"+244",prefix:null,iso:"AO",flag:"https://cdn.kcak11.com/CountryFlags/countries/ao.svg",mask:"(___) ___-___"},{name:"Anguilla",code:"+1",prefix:"264",iso:"AI",flag:"https://cdn.kcak11.com/CountryFlags/countries/ai.svg",mask:"(264) ___-____"},{name:"Antarctica",code:"+672",prefix:"1",iso:"AQ",flag:"https://cdn.kcak11.com/CountryFlags/countries/aq.svg",mask:"1__-___"},{name:"Antigua and Barbuda",code:"+1",prefix:"268",iso:"AG",flag:"https://cdn.kcak11.com/CountryFlags/countries/ag.svg",mask:"(268) ___-____"},{name:"Argentina",code:"+54",prefix:null,iso:"AR",flag:"https://cdn.kcak11.com/CountryFlags/countries/ar.svg",mask:"(___) ___-____"},{name:"Armenia",code:"+374",prefix:null,iso:"AM",flag:"https://cdn.kcak11.com/CountryFlags/countries/am.svg",mask:"__-___-___"},{name:"Aruba",code:"+297",prefix:null,iso:"AW",flag:"https://cdn.kcak11.com/CountryFlags/countries/aw.svg",mask:"___-____"},{name:"Ascension Island",code:"+247",prefix:null,iso:"AC",flag:"https://cdn.kcak11.com/CountryFlags/countries/sh.svg",mask:"____"},{name:"Australia",code:"+61",prefix:null,iso:"AU",flag:"https://cdn.kcak11.com/CountryFlags/countries/au.svg",mask:"_-____-____"},{name:"Austria",code:"+43",prefix:null,iso:"AT",flag:"https://cdn.kcak11.com/CountryFlags/countries/at.svg",mask:"(___) ___-____"},{name:"Azerbaijan",code:"+994",prefix:null,iso:"AZ",flag:"https://cdn.kcak11.com/CountryFlags/countries/az.svg",mask:"__-___-__-__"},{name:"Bahamas",code:"+1",prefix:"242",iso:"BS",flag:"https://cdn.kcak11.com/CountryFlags/countries/bs.svg",mask:"(242) ___-____"},{name:"Bahrain",code:"+973",prefix:null,iso:"BH",flag:"https://cdn.kcak11.com/CountryFlags/countries/bh.svg",mask:"____-____"},{name:"Bangladesh",code:"+880",prefix:"1",iso:"BD",flag:"https://cdn.kcak11.com/CountryFlags/countries/bd.svg",mask:"1___-______"},{name:"Barbados",code:"+1",prefix:"246",iso:"BB",flag:"https://cdn.kcak11.com/CountryFlags/countries/bb.svg",mask:"(246) ___-____"},{name:"Belarus",code:"+375",prefix:null,iso:"BY",flag:"https://cdn.kcak11.com/CountryFlags/countries/by.svg",mask:"(__) ___-__-__"},{name:"Belgium",code:"+32",prefix:null,iso:"BE",flag:"https://cdn.kcak11.com/CountryFlags/countries/be.svg",mask:"(___) ___-___"},{name:"Belize",code:"+501",prefix:null,iso:"BZ",flag:"https://cdn.kcak11.com/CountryFlags/countries/bz.svg",mask:"___-____"},{name:"Benin",code:"+229",prefix:null,iso:"BJ",flag:"https://cdn.kcak11.com/CountryFlags/countries/bj.svg",mask:"__-__-____"},{name:"Bermuda",code:"+1",prefix:"441",iso:"BM",flag:"https://cdn.kcak11.com/CountryFlags/countries/bm.svg",mask:"(441) ___-____"},{name:"Bhutan",code:"+975",prefix:null,iso:"BT",flag:"https://cdn.kcak11.com/CountryFlags/countries/bt.svg",mask:"_-___-___"},{name:"Bolivia",code:"+591",prefix:null,iso:"BO",flag:"https://cdn.kcak11.com/CountryFlags/countries/bo.svg",mask:"_-___-____"},{name:"Bosnia and Herzegovina",code:"+387",prefix:null,iso:"BA",flag:"https://cdn.kcak11.com/CountryFlags/countries/ba.svg",mask:"__-_____"},{name:"Botswana",code:"+267",prefix:null,iso:"BW",flag:"https://cdn.kcak11.com/CountryFlags/countries/bw.svg",mask:"__-___-___"},{name:"Brasil",code:"+55",prefix:null,iso:"BR",flag:"https://cdn.kcak11.com/CountryFlags/countries/br.svg",mask:"(__) _____-____"},{name:"British Indian Ocean Territory",code:"+246",prefix:null,iso:"IO",flag:"https://cdn.kcak11.com/CountryFlags/countries/io.svg",mask:"___-____"},{name:"Brunei Darussalam",code:"+673",prefix:null,iso:"BN",flag:"https://cdn.kcak11.com/CountryFlags/countries/bn.svg",mask:"___-____"},{name:"Bulgaria",code:"+359",prefix:null,iso:"BG",flag:"https://cdn.kcak11.com/CountryFlags/countries/bg.svg",mask:"(___) ___-___"},{name:"Burkina Faso",code:"+226",prefix:null,iso:"BF",flag:"https://cdn.kcak11.com/CountryFlags/countries/bf.svg",mask:"__-__-____"},{name:"Burundi",code:"+257",prefix:null,iso:"BI",flag:"https://cdn.kcak11.com/CountryFlags/countries/bi.svg",mask:"__-__-____"},{name:"Cambodia",code:"+855",prefix:null,iso:"KH",flag:"https://cdn.kcak11.com/CountryFlags/countries/kh.svg",mask:"__-___-___"},{name:"Cameroon",code:"+237",prefix:null,iso:"CM",flag:"https://cdn.kcak11.com/CountryFlags/countries/cm.svg",mask:"____-____"},{name:"Canada",code:"+1",prefix:null,iso:"CA",flag:"https://cdn.kcak11.com/CountryFlags/countries/ca.svg",mask:"(___) ___-____"},{name:"Cape Verde",code:"+238",prefix:null,iso:"CV",flag:"https://cdn.kcak11.com/CountryFlags/countries/cv.svg",mask:"(___) __-__"},{name:"Cayman Islands",code:"+1",prefix:"345",iso:"KY",flag:"https://cdn.kcak11.com/CountryFlags/countries/ky.svg",mask:"(345) ___-____"},{name:"Central African Republic",code:"+236",prefix:null,iso:"CF",flag:"https://cdn.kcak11.com/CountryFlags/countries/cf.svg",mask:"__-__-____"},{name:"Chad",code:"+235",prefix:null,iso:"TD",flag:"https://cdn.kcak11.com/CountryFlags/countries/td.svg",mask:"__-__-__-__"},{name:"Chile",code:"+56",prefix:null,iso:"CL",flag:"https://cdn.kcak11.com/CountryFlags/countries/cl.svg",mask:"_-____-____"},{name:"China",code:"+86",prefix:null,iso:"CN",flag:"https://cdn.kcak11.com/CountryFlags/countries/cn.svg",mask:"__-_____-_____"},{name:"Christmas Island",code:"+61",prefix:null,iso:"CX",flag:"https://cdn.kcak11.com/CountryFlags/countries/cx.svg",mask:"_-____-____"},{name:"Cocos (Keeling) Islands",code:"+61",prefix:null,iso:"CC",flag:"https://cdn.kcak11.com/CountryFlags/countries/cc.svg",mask:"_-____-____"},{name:"Colombia",code:"+57",prefix:null,iso:"CO",flag:"https://cdn.kcak11.com/CountryFlags/countries/co.svg",mask:"(___) ___-____"},{name:"Comoros",code:"+269",prefix:null,iso:"KM",flag:"https://cdn.kcak11.com/CountryFlags/countries/km.svg",mask:"__-_____"},{name:"Congo",code:"+242",prefix:null,iso:"CG",flag:"https://cdn.kcak11.com/CountryFlags/countries/cg.svg",mask:"__-_____"},{name:"Cook Islands",code:"+682",prefix:null,iso:"CK",flag:"https://cdn.kcak11.com/CountryFlags/countries/ck.svg",mask:"__-___"},{name:"Costa Rica",code:"+506",prefix:null,iso:"CR",flag:"https://cdn.kcak11.com/CountryFlags/countries/cr.svg",mask:"____-____"},{name:"Croatia",code:"+385",prefix:null,iso:"HR",flag:"https://cdn.kcak11.com/CountryFlags/countries/hr.svg",mask:"__-___-___"},{name:"Cuba",code:"+53",prefix:null,iso:"CU",flag:"https://cdn.kcak11.com/CountryFlags/countries/cu.svg",mask:"_-___-____"},{name:"Cyprus",code:"+357",prefix:null,iso:"CY",flag:"https://cdn.kcak11.com/CountryFlags/countries/cy.svg",mask:"__-___-___"},{name:"Czech Republic",code:"+420",prefix:null,iso:"CZ",flag:"https://cdn.kcak11.com/CountryFlags/countries/cz.svg",mask:"(___) ___-___"},{name:"Democratic Republic of the Congo",code:"+243",prefix:null,iso:"CD",flag:"https://cdn.kcak11.com/CountryFlags/countries/cd.svg",mask:"(___) ___-___"},{name:"Denmark",code:"+45",prefix:null,iso:"DK",flag:"https://cdn.kcak11.com/CountryFlags/countries/dk.svg",mask:"__-__-__-__"},{name:"Djibouti",code:"+253",prefix:null,iso:"DJ",flag:"https://cdn.kcak11.com/CountryFlags/countries/dj.svg",mask:"__-__-__-__"},{name:"Dominica",code:"+1",prefix:"767",iso:"DM",flag:"https://cdn.kcak11.com/CountryFlags/countries/dm.svg",mask:"(767) ___-____"},{name:"Dominican Republic",code:"+1",prefix:"849",iso:"DO",flag:"https://cdn.kcak11.com/CountryFlags/countries/do.svg",mask:"(894) ___-____"},{name:"Ecuador",code:"+593",prefix:null,iso:"EC",flag:"https://cdn.kcak11.com/CountryFlags/countries/ec.svg",mask:"__-___-____"},{name:"Egypt",code:"+20",prefix:null,iso:"EG",flag:"https://cdn.kcak11.com/CountryFlags/countries/eg.svg",mask:"(___) ___-____"},{name:"El Salvador",code:"+503",prefix:null,iso:"SV",flag:"https://cdn.kcak11.com/CountryFlags/countries/sv.svg",mask:"__-__-____"},{name:"Equatorial Guinea",code:"+240",prefix:null,iso:"GQ",flag:"https://cdn.kcak11.com/CountryFlags/countries/gq.svg",mask:"__-___-____"},{name:"Eritrea",code:"+291",prefix:null,iso:"ER",flag:"https://cdn.kcak11.com/CountryFlags/countries/er.svg",mask:"_-___-___"},{name:"Estonia",code:"+372",prefix:null,iso:"EE",flag:"https://cdn.kcak11.com/CountryFlags/countries/ee.svg",mask:"____-____"},{name:"Eswatini",code:"+268",prefix:null,iso:"SZ",flag:"https://cdn.kcak11.com/CountryFlags/countries/sz.svg",mask:"__-__-____"},{name:"Ethiopia",code:"+251",prefix:null,iso:"ET",flag:"https://cdn.kcak11.com/CountryFlags/countries/et.svg",mask:"__-___-____"},{name:"Falkland Islands (Malvinas)",code:"+500",prefix:null,iso:"FK",flag:"https://cdn.kcak11.com/CountryFlags/countries/fk.svg",mask:"_____"},{name:"Faroe Islands",code:"+298",prefix:null,iso:"FO",flag:"https://cdn.kcak11.com/CountryFlags/countries/fo.svg",mask:"__ __ __"},{name:"Fiji",code:"+679",prefix:null,iso:"FJ",flag:"https://cdn.kcak11.com/CountryFlags/countries/fj.svg",mask:"__-_____"},{name:"Finland",code:"+358",prefix:null,iso:"FI",flag:"https://cdn.kcak11.com/CountryFlags/countries/fi.svg",mask:"__ ___ ____"},{name:"France",code:"+33",prefix:null,iso:"FR",flag:"https://cdn.kcak11.com/CountryFlags/countries/fr.svg",mask:"_ __ __ __ __"},{name:"French Guiana",code:"+594",prefix:null,iso:"GF",flag:"https://cdn.kcak11.com/CountryFlags/countries/gf.svg",mask:"___ __ __ __"},{name:"French Polynesia",code:"+689",prefix:null,iso:"PF",flag:"https://cdn.kcak11.com/CountryFlags/countries/pf.svg",mask:"__ __ __ __"},{name:"Gabon",code:"+241",prefix:null,iso:"GA",flag:"https://cdn.kcak11.com/CountryFlags/countries/ga.svg",mask:"_ __ __ __"},{name:"Gambia",code:"+220",prefix:null,iso:"GM",flag:"https://cdn.kcak11.com/CountryFlags/countries/gm.svg",mask:"___ ____"},{name:"Georgia",code:"+995",prefix:null,iso:"GE",flag:"https://cdn.kcak11.com/CountryFlags/countries/ge.svg",mask:"(___) ___-___"},{name:"Germany",code:"+49",prefix:"3",iso:"DE",flag:"https://cdn.kcak11.com/CountryFlags/countries/de.svg",mask:"(3____) __-____"},{name:"Ghana",code:"+233",prefix:"03",iso:"GH",flag:"https://cdn.kcak11.com/CountryFlags/countries/gh.svg",mask:"03_ ___ ____"},{name:"Gibraltar",code:"+350",prefix:null,iso:"GI",flag:"https://cdn.kcak11.com/CountryFlags/countries/gi.svg",mask:"___-_____"},{name:"Greece",code:"+30",prefix:null,iso:"GR",flag:"https://cdn.kcak11.com/CountryFlags/countries/gr.svg",mask:"(___) ___-____"},{name:"Greenland",code:"+299",prefix:null,iso:"GL",flag:"https://cdn.kcak11.com/CountryFlags/countries/gl.svg",mask:"__-__-__"},{name:"Grenada",code:"+1",prefix:"473",iso:"GD",flag:"https://cdn.kcak11.com/CountryFlags/countries/gd.svg",mask:"(473) ___-____"},{name:"Guadeloupe",code:"+590",prefix:null,iso:"GP",flag:"https://cdn.kcak11.com/CountryFlags/countries/gp.svg",mask:"___ __ __ __"},{name:"Guam",code:"+1",prefix:"671",iso:"GU",flag:"https://cdn.kcak11.com/CountryFlags/countries/gu.svg",mask:"671 ___ ____"},{name:"Guatemala",code:"+502",prefix:null,iso:"GT",flag:"https://cdn.kcak11.com/CountryFlags/countries/gt.svg",mask:"_-___-____"},{name:"Guernsey",code:"+44",prefix:null,iso:"GG",flag:"https://cdn.kcak11.com/CountryFlags/countries/gg.svg",mask:"(____) ______"},{name:"Guinea",code:"+224",prefix:null,iso:"GN",flag:"https://cdn.kcak11.com/CountryFlags/countries/gn.svg",mask:"__-___-___"},{name:"Guinea-Bissau",code:"+245",prefix:null,iso:"GW",flag:"https://cdn.kcak11.com/CountryFlags/countries/gw.svg",mask:"_-______"},{name:"Guyana",code:"+592",prefix:null,iso:"GY",flag:"https://cdn.kcak11.com/CountryFlags/countries/gy.svg",mask:"___-____"},{name:"Haiti",code:"+509",prefix:null,iso:"HT",flag:"https://cdn.kcak11.com/CountryFlags/countries/ht.svg",mask:"__-__-____"},{name:"Holy See (Vatican City State)",code:"+39",prefix:"06698",iso:"VA",flag:"https://cdn.kcak11.com/CountryFlags/countries/va.svg",mask:"06 698_____"},{name:"Honduras",code:"+504",prefix:null,iso:"HN",flag:"https://cdn.kcak11.com/CountryFlags/countries/hn.svg",mask:"____-____"},{name:"Hong Kong",code:"+852",prefix:null,iso:"HK",flag:"https://cdn.kcak11.com/CountryFlags/countries/hk.svg",mask:"____-____"},{name:"Hungary",code:"+36",prefix:null,iso:"HU",flag:"https://cdn.kcak11.com/CountryFlags/countries/hu.svg",mask:"__ ___ ____"},{name:"Iceland",code:"+354",prefix:null,iso:"IS",flag:"https://cdn.kcak11.com/CountryFlags/countries/is.svg",mask:"___-____"},{name:"India",code:"+91",prefix:null,iso:"IN",flag:"https://cdn.kcak11.com/CountryFlags/countries/in.svg",mask:"(____) ___-___"},{name:"Indonesia",code:"+62",prefix:"8",iso:"ID",flag:"https://cdn.kcak11.com/CountryFlags/countries/id.svg",mask:"(8__) ___-__-___"},{name:"Iran",code:"+98",prefix:null,iso:"IR",flag:"https://cdn.kcak11.com/CountryFlags/countries/ir.svg",mask:"(___) ___-____"},{name:"Iraq",code:"+964",prefix:null,iso:"IQ",flag:"https://cdn.kcak11.com/CountryFlags/countries/iq.svg",mask:"(___) ___-____"},{name:"Ireland",code:"+353",prefix:null,iso:"IE",flag:"https://cdn.kcak11.com/CountryFlags/countries/ie.svg",mask:"(___) ___-___"},{name:"Isle of Man",code:"+44",prefix:null,iso:"IM",flag:"https://cdn.kcak11.com/CountryFlags/countries/im.svg",mask:"(____) ______"},{name:"Israel",code:"+972",prefix:"5",iso:"IL",flag:"https://cdn.kcak11.com/CountryFlags/countries/il.svg",mask:"__-___-____"},{name:"Italy",code:"+39",prefix:null,iso:"IT",flag:"https://cdn.kcak11.com/CountryFlags/countries/it.svg",mask:"(___) ____-___"},{name:"Ivory Coast / Cote d'Ivoire",code:"+225",prefix:null,iso:"CI",flag:"https://cdn.kcak11.com/CountryFlags/countries/ci.svg",mask:"__-___-___"},{name:"Jamaica",code:"+1",prefix:"876",iso:"JM",flag:"https://cdn.kcak11.com/CountryFlags/countries/jm.svg",mask:"(876) ___-____"},{name:"Japan",code:"+81",prefix:null,iso:"JP",flag:"https://cdn.kcak11.com/CountryFlags/countries/jp.svg",mask:"__-____-____"},{name:"Jersey",code:"+44",prefix:null,iso:"JE",flag:"https://cdn.kcak11.com/CountryFlags/countries/je.svg",mask:"(____) ____-______"},{name:"Jordan",code:"+962",prefix:null,iso:"JO",flag:"https://cdn.kcak11.com/CountryFlags/countries/jo.svg",mask:"_-____-____"},{name:"Kazakhstan",code:"+77",prefix:null,iso:"KZ",flag:"https://cdn.kcak11.com/CountryFlags/countries/kz.svg",mask:"(_____) _ __ __"},{name:"Kenya",code:"+254",prefix:null,iso:"KE",flag:"https://cdn.kcak11.com/CountryFlags/countries/ke.svg",mask:"___-______"},{name:"Kiribati",code:"+686",prefix:null,iso:"KI",flag:"https://cdn.kcak11.com/CountryFlags/countries/ki.svg",mask:"__-___"},{name:"Korea, Democratic People's Republic of Korea",code:"+850",prefix:null,iso:"KP",flag:"https://cdn.kcak11.com/CountryFlags/countries/kp.svg",mask:"____-_____________"},{name:"Korea, Republic of South Korea",code:"+82",prefix:null,iso:"KR",flag:"https://cdn.kcak11.com/CountryFlags/countries/kr.svg",mask:"__-___-____"},{name:"Kosovo",code:"+383",prefix:null,iso:"XK",flag:"https://cdn.kcak11.com/CountryFlags/countries/xk.svg",mask:"___-___-___"},{name:"Kuwait",code:"+965",prefix:null,iso:"KW",flag:"https://cdn.kcak11.com/CountryFlags/countries/kw.svg",mask:"____-____"},{name:"Kyrgyzstan",code:"+996",prefix:null,iso:"KG",flag:"https://cdn.kcak11.com/CountryFlags/countries/kg.svg",mask:"(___) ___-___"},{name:"Laos",code:"+856",prefix:"20",iso:"LA",flag:"https://cdn.kcak11.com/CountryFlags/countries/la.svg",mask:"(20__) ___-___"},{name:"Latvia",code:"+371",prefix:null,iso:"LV",flag:"https://cdn.kcak11.com/CountryFlags/countries/lv.svg",mask:"__-___-___"},{name:"Lebanon",code:"+961",prefix:null,iso:"LB",flag:"https://cdn.kcak11.com/CountryFlags/countries/lb.svg",mask:"__-___-___"},{name:"Lesotho",code:"+266",prefix:null,iso:"LS",flag:"https://cdn.kcak11.com/CountryFlags/countries/ls.svg",mask:"_-___-____"},{name:"Liberia",code:"+231",prefix:null,iso:"LR",flag:"https://cdn.kcak11.com/CountryFlags/countries/lr.svg",mask:"__-___-___"},{name:"Libya",code:"+218",prefix:"21",iso:"LY",flag:"https://cdn.kcak11.com/CountryFlags/countries/ly.svg",mask:"21-___-____"},{name:"Liechtenstein",code:"+423",prefix:null,iso:"LI",flag:"https://cdn.kcak11.com/CountryFlags/countries/li.svg",mask:"(___) ___-____"},{name:"Lithuania",code:"+370",prefix:null,iso:"LT",flag:"https://cdn.kcak11.com/CountryFlags/countries/lt.svg",mask:"(___) __-___"},{name:"Luxembourg",code:"+352",prefix:null,iso:"LU",flag:"https://cdn.kcak11.com/CountryFlags/countries/lu.svg",mask:"(___) ___-___"},{name:"Macau",code:"+853",prefix:null,iso:"MO",flag:"https://cdn.kcak11.com/CountryFlags/countries/mo.svg",mask:"____-____"},{name:"Madagascar",code:"+261",prefix:null,iso:"MG",flag:"https://cdn.kcak11.com/CountryFlags/countries/mg.svg",mask:"__-__-_____"},{name:"Malawi",code:"+265",prefix:null,iso:"MW",flag:"https://cdn.kcak11.com/CountryFlags/countries/mw.svg",mask:"_-____-____"},{name:"Malaysia",code:"+60",prefix:null,iso:"MY",flag:"https://cdn.kcak11.com/CountryFlags/countries/my.svg",mask:"__-___-____"},{name:"Maldives",code:"+960",prefix:null,iso:"MV",flag:"https://cdn.kcak11.com/CountryFlags/countries/mv.svg",mask:"___-____"},{name:"Mali",code:"+223",prefix:null,iso:"ML",flag:"https://cdn.kcak11.com/CountryFlags/countries/ml.svg",mask:"__-__-____"},{name:"Malta",code:"+356",prefix:null,iso:"MT",flag:"https://cdn.kcak11.com/CountryFlags/countries/mt.svg",mask:"____-____"},{name:"Marshall Islands",code:"+692",prefix:null,iso:"MH",flag:"https://cdn.kcak11.com/CountryFlags/countries/mh.svg",mask:"___-____"},{name:"Martinique",code:"+596",prefix:null,iso:"MQ",flag:"https://cdn.kcak11.com/CountryFlags/countries/mq.svg",mask:"(___) __-__-__"},{name:"Mauritania",code:"+222",prefix:null,iso:"MR",flag:"https://cdn.kcak11.com/CountryFlags/countries/mr.svg",mask:"__-__-____"},{name:"Mauritius",code:"+230",prefix:null,iso:"MU",flag:"https://cdn.kcak11.com/CountryFlags/countries/mu.svg",mask:"___-____"},{name:"Mayotte",code:"+262",prefix:null,iso:"YT",flag:"https://cdn.kcak11.com/CountryFlags/countries/yt.svg",mask:"_____-____"},{name:"Mexico",code:"+52",prefix:null,iso:"MX",flag:"https://cdn.kcak11.com/CountryFlags/countries/mx.svg",mask:"(___) ___-____"},{name:"Micronesia, Federated States of Micronesia",code:"+691",prefix:null,iso:"FM",flag:"https://cdn.kcak11.com/CountryFlags/countries/fm.svg",mask:"___-____"},{name:"Moldova",code:"+373",prefix:null,iso:"MD",flag:"https://cdn.kcak11.com/CountryFlags/countries/md.svg",mask:"____-____"},{name:"Monaco",code:"+377",prefix:null,iso:"MC",flag:"https://cdn.kcak11.com/CountryFlags/countries/mc.svg",mask:"(___) ___-___"},{name:"Mongolia",code:"+976",prefix:null,iso:"MN",flag:"https://cdn.kcak11.com/CountryFlags/countries/mn.svg",mask:"__-__-____"},{name:"Montenegro",code:"+382",prefix:null,iso:"ME",flag:"https://cdn.kcak11.com/CountryFlags/countries/me.svg",mask:"__-___-___"},{name:"Montserrat",code:"+1",prefix:"664",iso:"MS",flag:"https://cdn.kcak11.com/CountryFlags/countries/ms.svg",mask:"(664) ___-____"},{name:"Morocco",code:"+212",prefix:null,iso:"MA",flag:"https://cdn.kcak11.com/CountryFlags/countries/ma.svg",mask:"__-____-___"},{name:"Mozambique",code:"+258",prefix:null,iso:"MZ",flag:"https://cdn.kcak11.com/CountryFlags/countries/mz.svg",mask:"__-___-___"},{name:"Myanmar",code:"+95",prefix:null,iso:"MM",flag:"https://cdn.kcak11.com/CountryFlags/countries/mm.svg",mask:"__-___-___"},{name:"Namibia",code:"+264",prefix:null,iso:"NA",flag:"https://cdn.kcak11.com/CountryFlags/countries/na.svg",mask:"__-___-____"},{name:"Nauru",code:"+674",prefix:null,iso:"NR",flag:"https://cdn.kcak11.com/CountryFlags/countries/nr.svg",mask:"___-____"},{name:"Nepal",code:"+977",prefix:null,iso:"NP",flag:"https://cdn.kcak11.com/CountryFlags/countries/np.svg",mask:"__-___-___"},{name:"Netherlands",code:"+31",prefix:null,iso:"NL",flag:"https://cdn.kcak11.com/CountryFlags/countries/nl.svg",mask:"__-___-____"},{name:"New Caledonia",code:"+687",prefix:null,iso:"NC",flag:"https://cdn.kcak11.com/CountryFlags/countries/nc.svg",mask:"__-____"},{name:"New Zealand",code:"+64",prefix:null,iso:"NZ",flag:"https://cdn.kcak11.com/CountryFlags/countries/nz.svg",mask:"(___) ___-____"},{name:"Nicaragua",code:"+505",prefix:null,iso:"NI",flag:"https://cdn.kcak11.com/CountryFlags/countries/ni.svg",mask:"____-____"},{name:"Niger",code:"+227",prefix:null,iso:"NE",flag:"https://cdn.kcak11.com/CountryFlags/countries/ne.svg",mask:"__-__-____"},{name:"Nigeria",code:"+234",prefix:null,iso:"NG",flag:"https://cdn.kcak11.com/CountryFlags/countries/ng.svg",mask:"(___) ___-____"},{name:"Niue",code:"+683",prefix:null,iso:"NU",flag:"https://cdn.kcak11.com/CountryFlags/countries/nu.svg",mask:"____"},{name:"Norfolk Island",code:"+672",prefix:"3",iso:"NF",flag:"https://cdn.kcak11.com/CountryFlags/countries/nf.svg",mask:"3__-___"},{name:"North Macedonia",code:"+389",prefix:null,iso:"MK",flag:"https://cdn.kcak11.com/CountryFlags/countries/mk.svg",mask:"__-___-___"},{name:"Northern Mariana Islands",code:"+1",prefix:"670",iso:"MP",flag:"https://cdn.kcak11.com/CountryFlags/countries/mp.svg",mask:"(670) ___-____"},{name:"Norway",code:"+47",prefix:null,iso:"NO",flag:"https://cdn.kcak11.com/CountryFlags/countries/no.svg",mask:"(___) __-___"},{name:"Oman",code:"+968",prefix:null,iso:"OM",flag:"https://cdn.kcak11.com/CountryFlags/countries/om.svg",mask:"__-___-___"},{name:"Pakistan",code:"+92",prefix:null,iso:"PK",flag:"https://cdn.kcak11.com/CountryFlags/countries/pk.svg",mask:"(___) ___-____"},{name:"Palau",code:"+680",prefix:null,iso:"PW",flag:"https://cdn.kcak11.com/CountryFlags/countries/pw.svg",mask:"___-____"},{name:"Palestine",code:"+970",prefix:null,iso:"PS",flag:"https://cdn.kcak11.com/CountryFlags/countries/ps.svg",mask:"__-___-____"},{name:"Panama",code:"+507",prefix:null,iso:"PA",flag:"https://cdn.kcak11.com/CountryFlags/countries/pa.svg",mask:"___-____"},{name:"Papua New Guinea",code:"+675",prefix:null,iso:"PG",flag:"https://cdn.kcak11.com/CountryFlags/countries/pg.svg",mask:"(___) __-___"},{name:"Paraguay",code:"+595",prefix:null,iso:"PY",flag:"https://cdn.kcak11.com/CountryFlags/countries/py.svg",mask:"(___) ___-___"},{name:"Peru",code:"+51",prefix:null,iso:"PE",flag:"https://cdn.kcak11.com/CountryFlags/countries/pe.svg",mask:"(___) ___-___"},{name:"Philippines",code:"+63",prefix:null,iso:"PH",flag:"https://cdn.kcak11.com/CountryFlags/countries/ph.svg",mask:"(___) ___-____"},{name:"Pitcairn",code:"+870",prefix:null,iso:"PN",flag:"https://cdn.kcak11.com/CountryFlags/countries/pn.svg",mask:"___-___-___"},{name:"Poland",code:"+48",prefix:null,iso:"PL",flag:"https://cdn.kcak11.com/CountryFlags/countries/pl.svg",mask:"(___) ___-___"},{name:"Portugal",code:"+351",prefix:null,iso:"PT",flag:"https://cdn.kcak11.com/CountryFlags/countries/pt.svg",mask:"__-___-____"},{name:"Puerto Rico",code:"+1",prefix:null,iso:"PR",flag:"https://cdn.kcak11.com/CountryFlags/countries/pr.svg",mask:"(___) ___ ____"},{name:"Qatar",code:"+974",prefix:null,iso:"QA",flag:"https://cdn.kcak11.com/CountryFlags/countries/qa.svg",mask:"____-____"},{name:"Reunion",code:"+262",prefix:null,iso:"RE",flag:"https://cdn.kcak11.com/CountryFlags/countries/re.svg",mask:"_____-____"},{name:"Romania",code:"+40",prefix:null,iso:"RO",flag:"https://cdn.kcak11.com/CountryFlags/countries/ro.svg",mask:"__-___-____"},{name:"Russia",code:"+7",prefix:null,iso:"RU",flag:"https://cdn.kcak11.com/CountryFlags/countries/ru.svg",mask:"(___) ___-__-__"},{name:"Rwanda",code:"+250",prefix:null,iso:"RW",flag:"https://cdn.kcak11.com/CountryFlags/countries/rw.svg",mask:"(___) ___-___"},{name:"Saint Barthelemy",code:"+590",prefix:null,iso:"BL",flag:"https://cdn.kcak11.com/CountryFlags/countries/bl.svg",mask:"___-__-__-__"},{name:"Saint Helena, Ascension and Tristan Da Cunha",code:"+290",prefix:null,iso:"SH",flag:"https://cdn.kcak11.com/CountryFlags/countries/sh.svg",mask:"____"},{name:"Saint Kitts and Nevis",code:"+1",prefix:null,iso:"KN",flag:"https://cdn.kcak11.com/CountryFlags/countries/kn.svg",mask:"(869) ___-____"},{name:"Saint Lucia",code:"+1",prefix:"758",iso:"LC",flag:"https://cdn.kcak11.com/CountryFlags/countries/lc.svg",mask:"(758) ___-____"},{name:"Saint Martin",code:"+590",prefix:null,iso:"MF",flag:"https://cdn.kcak11.com/CountryFlags/countries/mf.svg",mask:"(___) ___-___"},{name:"Saint Pierre and Miquelon",code:"+508",prefix:null,iso:"PM",flag:"https://cdn.kcak11.com/CountryFlags/countries/pm.svg",mask:"__-____"},{name:"Saint Vincent and the Grenadines",code:"+1",prefix:"784",iso:"VC",flag:"https://cdn.kcak11.com/CountryFlags/countries/vc.svg",mask:"(784) ___-____"},{name:"Samoa",code:"+685",prefix:null,iso:"WS",flag:"https://cdn.kcak11.com/CountryFlags/countries/ws.svg",mask:"__-____"},{name:"San Marino",code:"+378",prefix:null,iso:"SM",flag:"https://cdn.kcak11.com/CountryFlags/countries/sm.svg",mask:"____-______"},{name:"Sao Tome and Principe",code:"+239",prefix:null,iso:"ST",flag:"https://cdn.kcak11.com/CountryFlags/countries/st.svg",mask:"__-_____"},{name:"Saudi Arabia",code:"+966",prefix:null,iso:"SA",flag:"https://cdn.kcak11.com/CountryFlags/countries/sa.svg",mask:"_-____-____"},{name:"Senegal",code:"+221",prefix:null,iso:"SN",flag:"https://cdn.kcak11.com/CountryFlags/countries/sn.svg",mask:"__-___-____"},{name:"Serbia",code:"+381",prefix:null,iso:"RS",flag:"https://cdn.kcak11.com/CountryFlags/countries/rs.svg",mask:"__-___-____"},{name:"Seychelles",code:"+248",prefix:null,iso:"SC",flag:"https://cdn.kcak11.com/CountryFlags/countries/sc.svg",mask:"_-___-___"},{name:"Sierra Leone",code:"+232",prefix:null,iso:"SL",flag:"https://cdn.kcak11.com/CountryFlags/countries/sl.svg",mask:"__-______"},{name:"Singapore",code:"+65",prefix:null,iso:"SG",flag:"https://cdn.kcak11.com/CountryFlags/countries/sg.svg",mask:"____-____"},{name:"Sint Maarten",code:"+1",prefix:"721",iso:"SX",flag:"https://cdn.kcak11.com/CountryFlags/countries/sx.svg",mask:"(721) ___-____"},{name:"Slovakia",code:"+421",prefix:null,iso:"SK",flag:"https://cdn.kcak11.com/CountryFlags/countries/sk.svg",mask:"(___) ___-___"},{name:"Slovenia",code:"+386",prefix:null,iso:"SI",flag:"https://cdn.kcak11.com/CountryFlags/countries/si.svg",mask:"__-___-___"},{name:"Solomon Islands",code:"+677",prefix:null,iso:"SB",flag:"https://cdn.kcak11.com/CountryFlags/countries/sb.svg",mask:"___-____"},{name:"Somalia",code:"+252",prefix:null,iso:"SO",flag:"https://cdn.kcak11.com/CountryFlags/countries/so.svg",mask:"__-___-___"},{name:"South Africa",code:"+27",prefix:null,iso:"ZA",flag:"https://cdn.kcak11.com/CountryFlags/countries/za.svg",mask:"__-___-____"},{name:"South Georgia and the South Sandwich Islands",code:"+500",prefix:null,iso:"GS",flag:"https://cdn.kcak11.com/CountryFlags/countries/gs.svg",mask:"_____"},{name:"South Sudan",code:"+211",prefix:null,iso:"SS",flag:"https://cdn.kcak11.com/CountryFlags/countries/ss.svg",mask:"__-___-____"},{name:"Spain",code:"+34",prefix:null,iso:"ES",flag:"https://cdn.kcak11.com/CountryFlags/countries/es.svg",mask:"(___) ___-___"},{name:"Sri Lanka",code:"+94",prefix:null,iso:"LK",flag:"https://cdn.kcak11.com/CountryFlags/countries/lk.svg",mask:"__-___-____"},{name:"Sudan",code:"+249",prefix:null,iso:"SD",flag:"https://cdn.kcak11.com/CountryFlags/countries/sd.svg",mask:"__-___-____"},{name:"Suriname",code:"+597",prefix:null,iso:"SR",flag:"https://cdn.kcak11.com/CountryFlags/countries/sr.svg",mask:"___-____"},{name:"Svalbard and Jan Mayen",code:"+47",prefix:null,iso:"SJ",flag:"https://cdn.kcak11.com/CountryFlags/countries/sj.svg",mask:"(___) __-___"},{name:"Sweden",code:"+46",prefix:null,iso:"SE",flag:"https://cdn.kcak11.com/CountryFlags/countries/se.svg",mask:"__-___-____"},{name:"Switzerland",code:"+41",prefix:null,iso:"CH",flag:"https://cdn.kcak11.com/CountryFlags/countries/ch.svg",mask:"__-___-____"},{name:"Syrian Arab Republic",code:"+963",prefix:null,iso:"SY",flag:"https://cdn.kcak11.com/CountryFlags/countries/sy.svg",mask:"__-____-___"},{name:"Taiwan",code:"+886",prefix:null,iso:"TW",flag:"https://cdn.kcak11.com/CountryFlags/countries/tw.svg",mask:"_-____-____"},{name:"Tajikistan",code:"+992",prefix:null,iso:"TJ",flag:"https://cdn.kcak11.com/CountryFlags/countries/tj.svg",mask:"__-___-____"},{name:"United Republic of Tanzania",code:"+255",prefix:null,iso:"TZ",flag:"https://cdn.kcak11.com/CountryFlags/countries/tz.svg",mask:"__-___-____"},{name:"Thailand",code:"+66",prefix:null,iso:"TH",flag:"https://cdn.kcak11.com/CountryFlags/countries/th.svg",mask:"__-___-____"},{name:"Timor-Leste",code:"+670",prefix:null,iso:"TL",flag:"https://cdn.kcak11.com/CountryFlags/countries/tl.svg",mask:"___-_____"},{name:"Togo",code:"+228",prefix:null,iso:"TG",flag:"https://cdn.kcak11.com/CountryFlags/countries/tg.svg",mask:"__-___-___"},{name:"Tokelau",code:"+690",prefix:null,iso:"TK",flag:"https://cdn.kcak11.com/CountryFlags/countries/tk.svg",mask:"____"},{name:"Tonga",code:"+676",prefix:null,iso:"TO",flag:"https://cdn.kcak11.com/CountryFlags/countries/to.svg",mask:"_____"},{name:"Trinidad and Tobago",code:"+1",prefix:"868",iso:"TT",flag:"https://cdn.kcak11.com/CountryFlags/countries/tt.svg",mask:"(868) ___-____"},{name:"Tunisia",code:"+216",prefix:null,iso:"TN",flag:"https://cdn.kcak11.com/CountryFlags/countries/tn.svg",mask:"__-___-___"},{name:"Turkey",code:"+90",prefix:null,iso:"TR",flag:"https://cdn.kcak11.com/CountryFlags/countries/tr.svg",mask:"(___) ___-____"},{name:"Turkmenistan",code:"+993",prefix:null,iso:"TM",flag:"https://cdn.kcak11.com/CountryFlags/countries/tm.svg",mask:"_-___-____"},{name:"Turks and Caicos Islands",code:"+1",prefix:"249",iso:"TC",flag:"https://cdn.kcak11.com/CountryFlags/countries/tc.svg",mask:"(249) ___-___"},{name:"Tuvalu",code:"+688",prefix:null,iso:"TV",flag:"https://cdn.kcak11.com/CountryFlags/countries/tv.svg",mask:"______"},{name:"Uganda",code:"+256",prefix:null,iso:"UG",flag:"https://cdn.kcak11.com/CountryFlags/countries/ug.svg",mask:"(___) ___-___"},{name:"Ukraine",code:"+380",prefix:null,iso:"UA",flag:"https://cdn.kcak11.com/CountryFlags/countries/ua.svg",mask:"(__) ___-__-__"},{name:"United Arab Emirates",code:"+971",prefix:null,iso:"AE",flag:"https://cdn.kcak11.com/CountryFlags/countries/ae.svg",mask:"_-___-____"},{name:"United Kingdom",code:"+44",prefix:null,iso:"GB",flag:"https://cdn.kcak11.com/CountryFlags/countries/gb.svg",mask:"__-____-____"},{name:"United States",code:"+1",prefix:"408",iso:"US",flag:"https://cdn.kcak11.com/CountryFlags/countries/us.svg",mask:"(408) ___-____"},{name:"Uruguay",code:"+598",prefix:null,iso:"UY",flag:"https://cdn.kcak11.com/CountryFlags/countries/uy.svg",mask:"_-___-__-__"},{name:"Uzbekistan",code:"+998",prefix:null,iso:"UZ",flag:"https://cdn.kcak11.com/CountryFlags/countries/uz.svg",mask:"__-___-____"},{name:"Vanuatu",code:"+678",prefix:null,iso:"VU",flag:"https://cdn.kcak11.com/CountryFlags/countries/vu.svg",mask:"__-_____"},{name:"Venezuela, Bolivarian Republic of Venezuela",code:"+58",prefix:null,iso:"VE",flag:"https://cdn.kcak11.com/CountryFlags/countries/ve.svg",mask:"(___) ___-____"},{name:"Vietnam",code:"+84",prefix:null,iso:"VN",flag:"https://cdn.kcak11.com/CountryFlags/countries/vn.svg",mask:"(___) ____-___"},{name:"Virgin Islands, British",code:"+1",prefix:"284",iso:"VG",flag:"https://cdn.kcak11.com/CountryFlags/countries/vg.svg",mask:"(284) ___-____"},{name:"Virgin Islands, U.S.",code:"+1",prefix:"340",iso:"VI",flag:"https://cdn.kcak11.com/CountryFlags/countries/vi.svg",mask:"(340) ___-____"},{name:"Wallis and Futuna",code:"+681",prefix:null,iso:"WF",flag:"https://cdn.kcak11.com/CountryFlags/countries/wf.svg",mask:"__-____"},{name:"Yemen",code:"+967",prefix:null,iso:"YE",flag:"https://cdn.kcak11.com/CountryFlags/countries/ye.svg",mask:"___-___-___"},{name:"Zambia",code:"+260",prefix:null,iso:"ZM",flag:"https://cdn.kcak11.com/CountryFlags/countries/zm.svg",mask:"__-___-____"},{name:"Zimbabwe",code:"+263",prefix:null,iso:"ZW",flag:"https://cdn.kcak11.com/CountryFlags/countries/zw.svg",mask:"_-______"}],b={USD:{countryLanguage:"en-US",countryCurrency:"USD"},EUR:{countryLanguage:"de-DE",countryCurrency:"EUR"},JPY:{countryLanguage:"ja-JP",countryCurrency:"JPY"},GBP:{countryLanguage:"en-GB",countryCurrency:"GBP"},AUD:{countryLanguage:"en-AU",countryCurrency:"AUD"},CAD:{countryLanguage:"en-CA",countryCurrency:"CAD"},CHF:{countryLanguage:"de-CH",countryCurrency:"CHF"},CNY:{countryLanguage:"zh-CN",countryCurrency:"CNY"},SEK:{countryLanguage:"sv-SE",countryCurrency:"SEK"},NZD:{countryLanguage:"en-NZ",countryCurrency:"NZD"},BRL:{countryLanguage:"pt-BR",countryCurrency:"BRL"},INR:{countryLanguage:"en-IN",countryCurrency:"INR"},RUB:{countryLanguage:"ru-RU",countryCurrency:"RUB"},ZAR:{countryLanguage:"en-ZA",countryCurrency:"ZAR"},MXN:{countryLanguage:"es-MX",countryCurrency:"MXN"},SGD:{countryLanguage:"en-SG",countryCurrency:"SGD"},HKD:{countryLanguage:"zh-HK",countryCurrency:"HKD"},NOK:{countryLanguage:"nb-NO",countryCurrency:"NOK"},KRW:{countryLanguage:"ko-KR",countryCurrency:"KRW"},TRY:{countryLanguage:"tr-TR",countryCurrency:"TRY"},IDR:{countryLanguage:"id-ID",countryCurrency:"IDR"},THB:{countryLanguage:"th-TH",countryCurrency:"THB"}},N=n=>n.replace(new RegExp("(?:R\\$|\\p{Sc}|[$€¥£])","gu"),"").trim(),z=(n,a,s={showPrefix:!0})=>{if(!b[a])throw new Error("Unsupported currency code");const{countryCurrency:e,countryLanguage:_}=b[a],t=new Intl.NumberFormat(_,{style:"currency",currency:e}).format(n);return s.showPrefix?t.replace(/\s/g," "):N(t).replace(/\s/g," ")},O=([n,a="00:00:00"],s,e=0)=>{const _=n.split(/[-/]/).map(Number),t=a.split(".")[0].split(":").map(Number);let r,i,c;const[l=0,d=0,y=0]=t;switch(s){case"brazilianDate":[r,i,c]=_;break;case"isoDate":[c,i,r]=_;break;case"timestamp":[c,i,r]=_.map(Number);break;default:throw new Error("Invalid input format")}const h=new Date(Date.UTC(c,i-1,r,l-e,d,y));if(isNaN(h.getTime()))throw new Error("Invalid date");return h},J=(n,a)=>{if(n.length>a){let s=n.substring(0,a).trimEnd();return s=s.replace(/[.,!?;:]$/,""),`${s}...`}return n},V=/^\d$/,W=n=>{let a=0;const s=n.split("").map(e=>V.test(e)?{character:e,kind:"digit",digit:++a}:{character:e,kind:"other"});return{digits:a,children:s,kind:"root"}},Z=(n,a)=>Array.isArray(n)?n:n>=0?[0,n]:[a+1-Math.abs(n),a],q=(n,a)=>a>=n[0]&&a<=n[1],j=(n,a)=>{const s=W(n),e=Z(a.range??3,s.digits);return s.children.map(_=>_.kind==="digit"&&q(e,_.digit)?a.hider??"*":_.character).join("")};function Q(n){return n.length>10?"NINE":"EIGTH"}const I={EIGTH:"(99) 9999-9999",NINE:"(99) 99999-9999"},X=k(I.NINE).length;function nn(n,a){let s="",e=0;for(let _=0;_<a.length;_++)if(a[_]==="9")if(e<n.length)s+=n[e],e++;else break;else if(e<n.length)s+=a[_];else break;return s}function M(n,a){if(a.code==="+55"){let _=k(n);const t=Q(_);return _.length>X||(_=nn(_,I[t])),_}let e=a.mask;if(a.prefix){const _=/\$+/g;e=e.replace(_,a.prefix)}for(let _=0,t=0;_<e.length&&t<n.length;_++)e[_]==="_"&&(e=e.substring(0,_)+n[t]+e.substring(_+1),t++);return e}function an(n,a){const s=v.find(e=>e.code===n&&e.prefix===a);if(!s)throw new Error("Invalid country code or prefix");if(s.prefix!==a)throw new Error("Invalid country code or prefix");if(!s.prefix)throw new Error("Invalid country code or prefix");return s}function _n(n){const a=v.find(s=>s.code===n);if(!a)throw new Error("Invalid country code");if(a.prefix)throw new Error("Invalid country code");return a}const sn=n=>{if(!/^\+\d{1,4}(-\d{1,4})? \d+$/.test(n))throw new Error("Invalid phone number format. Expected format: +<countryCode>-<optionalPrefix> <phoneNumber>");const s=n.split(" ")[0].split("-")[0],e=n.split(" ")[0].split("-")[1],_=n.split(" ")[1];if(!s||!_)throw new Error("Invalid phone number format");if(e){const r=an(s,e);return M(_,r)}const t=_n(s);return M(_,t)},en=n=>{for(var a=0,s=0;s<n.length;s++)a=n.charCodeAt(s)+((a<<5)-a);var e=(a&16711680)>>16,_=(a&65280)>>8,t=a&255,r=e.toString(16).padStart(2,"0"),i=_.toString(16).padStart(2,"0"),c=t.toString(16).padStart(2,"0");return"#"+r+i+c};for(var u=[],x=0;x<256;++x)u.push((x+256).toString(16).slice(1));function T(n,a=0){return(u[n[a+0]]+u[n[a+1]]+u[n[a+2]]+u[n[a+3]]+"-"+u[n[a+4]]+u[n[a+5]]+"-"+u[n[a+6]]+u[n[a+7]]+"-"+u[n[a+8]]+u[n[a+9]]+"-"+u[n[a+10]]+u[n[a+11]]+u[n[a+12]]+u[n[a+13]]+u[n[a+14]]+u[n[a+15]]).toLowerCase()}var C,tn=new Uint8Array(16);function D(){if(!C&&(C=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!C))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return C(tn)}var on=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const E={randomUUID:on};function cn(n,a,s){if(E.randomUUID&&!n)return E.randomUUID();n=n||{};var e=n.random||(n.rng||D)();return e[6]=e[6]&15|64,e[8]=e[8]&63|128,T(e)}var A=null,L=null,m=0;function rn(n,a,s){n=n||{};var e=0,_=new Uint8Array(16),t=n.random||(n.rng||D)(),r=n.msecs!==void 0?n.msecs:Date.now(),i=n.seq!==void 0?n.seq:null,c=L,l=A;return r>m&&n.msecs===void 0&&(m=r,i!==null&&(c=null,l=null)),i!==null&&(i>2147483647&&(i=2147483647),c=i>>>19&4095,l=i&524287),(c===null||l===null)&&(c=t[6]&127,c=c<<8|t[7],l=t[8]&63,l=l<<8|t[9],l=l<<5|t[10]>>>3),r+1e4>m&&i===null?++l>524287&&(l=0,++c>4095&&(c=0,m++)):m=r,L=c,A=l,_[e++]=m/1099511627776&255,_[e++]=m/4294967296&255,_[e++]=m/16777216&255,_[e++]=m/65536&255,_[e++]=m/256&255,_[e++]=m&255,_[e++]=c>>>4&15|112,_[e++]=c&255,_[e++]=l>>>13&63|128,_[e++]=l>>>5&255,_[e++]=l<<3&255|t[10]&7,_[e++]=t[11],_[e++]=t[12],_[e++]=t[13],_[e++]=t[14],_[e++]=t[15],a||T(_)}function R(n){n=n.replace(/-/g,"");const a=new Uint8Array(n.length/2);for(let s=0;s<n.length;s+=2)a[s/2]=parseInt(n.substring(s,s+2),16);return a}function w(){const n=cn();return{text:n,binary:R(n)}}function G(){const n=rn();return{text:n,binary:R(n)}}function ln(n,a){if(n==="text"&&a==="v4")return w().text;if(n==="binary"&&a==="v4")return w().binary;if(n==="text"&&a==="v7")return G().text;if(n==="binary"&&a==="v7")return G().binary;throw new Error("Invalid type or format")}function un(n){let a=n.normalize("NFD").replace(/[\u0300-\u036f]/g,"");return a=a.replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").toLowerCase(),a=a.replace(/-{2,}/g,"-"),a=a.replace(/^-+|-+$/g,""),a}const gn=n=>{const{cashPrice:a,numberInstallments:s,fees:e=.0349}=n;if(e===0||s===1)return{totalPrice:a,installmentPrice:a/s};if(s<=0)throw new Error("Number of installments must be greater than 0");if(e<0)throw new Error("Fees must be greater than or equal to 0");let _=0,t=0,r=Math.pow(1+e,s)*e,i=Math.pow(1+e,s)-1;return _=a*(r/i),t=s*_,{totalPrice:+t.toFixed(2),installmentPrice:+_.toFixed(2)}},mn=n=>{const a=n.startsWith("'")&&n.endsWith("'"),s=n.startsWith('"')&&n.endsWith('"');return a||s?n:`"${n}"`};function dn(n){return/<\/?[a-z][\s\S]*>/i.test(n)}const kn=(n,a=["password","confirmPassword","creditCard"])=>{function s(_,t){return a.includes(_)?"****":t}function e(_){return Array.isArray(_)?_.map(t=>e(t)):_!==null&&typeof _=="object"?Object.keys(_).reduce((t,r)=>{let i=_[r];if(typeof i=="string")try{const c=JSON.parse(i);typeof c=="object"&&(i=JSON.stringify(e(c)))}catch{}return t[r]=e(s(r,i)),t},{}):_}try{const _=JSON.parse(n),t=e(_);return JSON.stringify(t)}catch{return n}},fn=n=>n.replace(/<\/?[^>]+(>|$)/g,""),pn=(n,a=1e3)=>{function s(_){return typeof _=="string"&&_.length>a?`To large information: field as ${_.length} characters`:_}function e(_){return Array.isArray(_)?_.map(t=>e(t)):_!==null&&typeof _=="object"?Object.fromEntries(Object.entries(_).map(([t,r])=>[t,e(r)])):s(_)}try{const _=JSON.parse(n),t=e(_);return JSON.stringify(t)}catch{throw new Error("Invalid JSON string")}},yn=n=>{if(!n||!/^[0-9-]+$/.test(n))return!1;const s=k(n),e=8,_=/^\d{8}$/.test(s);return s.length===e&&_};function hn(n){return n.length!==14}function Cn(n){const[a]=n;return[...n].every(s=>s===a)}function P(n,a){let s=0;for(let _=0;_<a.length;_++)s+=parseInt(n[_])*a[_];const e=s%11;return e<2?0:11-e}function vn(n){return n.slice(12)}const xn=n=>{if(!n)return!1;const a=k(n);if(hn(a)||Cn(a))return!1;const s=a.slice(0,12),e=P(s,[5,4,3,2,9,8,7,6,5,4,3,2]),_=P(s+e,[6,5,4,3,2,9,8,7,6,5,4,3,2]);return vn(a)===`${e}${_}`};function Fn(n){return n.length!==11}function Sn(n){const[a]=n;return[...n].every(s=>s===a)}function B(n,a){let s=0;for(const _ of n)a>1&&(s+=parseInt(_)*a--);const e=s%11;return e<2?0:11-e}function bn(n){return n.slice(9)}const Nn=n=>{if(!n)return!1;const a=k(n);if(Fn(a)||Sn(a))return!1;const s=B(a,10),e=B(a,11);return bn(a)===`${s}${e}`},In=(n,a)=>{let s,e,_;const t=(a==null?void 0:a.inputFormat)||"DD/MM/YYYY",r=(a==null?void 0:a.minYear)||1900,i=(a==null?void 0:a.maxYear)||3e3;if(t==="DD/MM/YYYY"){const g=/^(\d{2})\/(\d{2})\/(\d{4})$/;if(!g.test(n))return!1;[,s,e,_]=n.match(g)||[]}else if(t==="MM-DD-YYYY"){const g=/^(\d{2})-(\d{2})-(\d{4})$/;if(!g.test(n))return!1;[,e,s,_]=n.match(g)||[]}else if(t==="YYYY-MM-DD"){const g=/^(\d{4})-(\d{2})-(\d{2})$/;if(!g.test(n))return!1;[,_,e,s]=n.match(g)||[]}else throw new Error("Invalid date format");const c=parseInt(s,10),l=parseInt(e,10),d=parseInt(_,10);if(c<1||c>31||l<1||l>12)return!1;const y=[31,28,31,30,31,30,31,31,30,31,30,31];if(l===2){const g=d%4===0&&d%100!==0||d%400===0;if(c>(g?29:28))return!1}else if(c>y[l-1])return!1;return d<r||d>i?!1:new Date(d,l-1,c).getDate()===c},Mn=n=>{if(!n)return!1;const a=n.length>=8,s=/[A-Z]/.test(n),e=/[a-z]/.test(n),_=/\d/.test(n),t=/[!@#$%^&*(),.?":{}|<>_\-+=~`[\]\\\/]/.test(n);return[a,s,e,_,t].every(r=>r)},Tn=n=>{for(const a of v){const s=a.code,e=a.prefix?`-${a.prefix}`:"",_=a.mask.replace(/[^_]/g,"").length;if(a.iso==="BR"){if(new RegExp(`^\\${s} \\d{2}9?\\d{8}$`).test(n))return!0;continue}if(new RegExp(`^\\${s}${e} \\d{${_}}$`).test(n))return!0}return!1},Dn=n=>{if(!n||!/^[0-9a-zA-Z.-]+$/.test(n))return!1;const s=n.replace(/[^a-zA-Z0-9]/g,"");return s.length<7||s.length>9?!1:/^[0-9]{7,8}[0-9Xx]?$/.test(s)};o.calculateCardInstallment=gn,o.ensureQuotes=mn,o.formatDate=Y,o.formatJsonObject=p,o.formatJsonString=U,o.formatToCapitalizeFirstWordLetter=H,o.formatToCep=$,o.formatToCnpj=F,o.formatToCpf=S,o.formatToCpfCnpj=K,o.formatToCurrency=z,o.formatToDate=O,o.formatToEllipsis=J,o.formatToHiddenDigits=j,o.formatToPhone=sn,o.generateColorByString=en,o.generateId=ln,o.generateSlug=un,o.isHtml=dn,o.maskSensitiveData=kn,o.removeCurrencySymbols=N,o.removeNonNumeric=k,o.stripHtmlTags=fn,o.truncateLargeFields=pn,o.validateCep=yn,o.validateCnpj=xn,o.validateCpf=Nn,o.validateDate=In,o.validatePassword=Mn,o.validatePhone=Tn,o.validateRg=Dn,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a sentence by capitalizing the first letter of each word.
|
|
3
|
+
*
|
|
4
|
+
* This function takes a string and capitalizes the first letter of each word
|
|
5
|
+
* while the remaining letters are lowercase.
|
|
6
|
+
* Words are separated by spaces.
|
|
7
|
+
*
|
|
8
|
+
* @param sentence - The sentence to be formatted.
|
|
9
|
+
* @returns The sentence formatted with the first letter of each word capitalized.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // Basic example
|
|
14
|
+
* formatToCapitalizeFirstWordLetter("hello world");
|
|
15
|
+
* // Returns: "Hello World"
|
|
16
|
+
*
|
|
17
|
+
* // With capitalized text.
|
|
18
|
+
* formatToCapitalizeFirstWordLetter("HELLO WORLD");
|
|
19
|
+
* // Returns: "Hello World"
|
|
20
|
+
*
|
|
21
|
+
* // With mixed text.
|
|
22
|
+
* formatToCapitalizeFirstWordLetter("hELLO WoRLd"); * // Returns: "Hello World"
|
|
23
|
+
*
|
|
24
|
+
* // With multiple words
|
|
25
|
+
* formatToCapitalizeFirstWordLetter("javascript is an amazing language");
|
|
26
|
+
* // Returns: "Javascript is an amazing language"
|
|
27
|
+
*
|
|
28
|
+
* // Empty string
|
|
29
|
+
* formatToCapitalizeFirstWordLetter("");
|
|
30
|
+
* // Returns: ""
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
declare function formatToCapitalizeFirstWordLetter(sentence: string): string;
|
|
34
|
+
export { formatToCapitalizeFirstWordLetter };
|
|
35
|
+
//# sourceMappingURL=formatToCapitalizeFirstWordLetter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatToCapitalizeFirstWordLetter.d.ts","sourceRoot":"","sources":["../../src/formats/formatToCapitalizeFirstWordLetter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,iBAAS,iCAAiC,CAAC,QAAQ,EAAE,MAAM,UAU1D;AAED,OAAO,EAAE,iCAAiC,EAAE,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a sentence by capitalizing the first letter of each word.
|
|
3
|
+
*
|
|
4
|
+
* This function takes a string and capitalizes the first letter of each word
|
|
5
|
+
* while the remaining letters are lowercase.
|
|
6
|
+
* Words are separated by spaces.
|
|
7
|
+
*
|
|
8
|
+
* @param sentence - The sentence to be formatted.
|
|
9
|
+
* @returns The sentence formatted with the first letter of each word capitalized.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // Basic example
|
|
14
|
+
* formatToCapitalizeFirstWordLetter("hello world");
|
|
15
|
+
* // Returns: "Hello World"
|
|
16
|
+
*
|
|
17
|
+
* // With capitalized text.
|
|
18
|
+
* formatToCapitalizeFirstWordLetter("HELLO WORLD");
|
|
19
|
+
* // Returns: "Hello World"
|
|
20
|
+
*
|
|
21
|
+
* // With mixed text.
|
|
22
|
+
* formatToCapitalizeFirstWordLetter("hELLO WoRLd"); * // Returns: "Hello World"
|
|
23
|
+
*
|
|
24
|
+
* // With multiple words
|
|
25
|
+
* formatToCapitalizeFirstWordLetter("javascript is an amazing language");
|
|
26
|
+
* // Returns: "Javascript is an amazing language"
|
|
27
|
+
*
|
|
28
|
+
* // Empty string
|
|
29
|
+
* formatToCapitalizeFirstWordLetter("");
|
|
30
|
+
* // Returns: ""
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
function formatToCapitalizeFirstWordLetter(sentence) {
|
|
34
|
+
const words = sentence.split(" ");
|
|
35
|
+
const capitalizedWords = words.map((word) => {
|
|
36
|
+
const firstLetter = word.charAt(0).toUpperCase();
|
|
37
|
+
const restOfWord = word.slice(1).toLowerCase();
|
|
38
|
+
return firstLetter + restOfWord;
|
|
39
|
+
});
|
|
40
|
+
return capitalizedWords.join(" ");
|
|
41
|
+
}
|
|
42
|
+
export { formatToCapitalizeFirstWordLetter };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { formatDate } from "./formats/formatDate";
|
|
2
2
|
export { formatJsonObject } from "./formats/formatJsonObject";
|
|
3
3
|
export { formatJsonString } from "./formats/formatJsonString";
|
|
4
|
+
export { formatToCapitalizeFirstWordLetter } from "./formats/formatToCapitalizeFirstWordLetter";
|
|
4
5
|
export { formatToCep } from "./formats/formatToCep";
|
|
5
6
|
export { formatToCnpj } from "./formats/formatToCnpj";
|
|
6
7
|
export { formatToCpf } from "./formats/formatToCpf";
|
|
@@ -15,6 +16,7 @@ export { generateId } from "./generators/generateId";
|
|
|
15
16
|
export { generateSlug } from "./generators/generateSlug";
|
|
16
17
|
export { calculateCardInstallment } from "./services/calculateCardInstallment";
|
|
17
18
|
export { ensureQuotes } from "./services/ensureQuotes";
|
|
19
|
+
export { isHtml } from "./services/isHtml";
|
|
18
20
|
export { maskSensitiveData } from "./services/maskSensitiveData";
|
|
19
21
|
export { removeCurrencySymbols } from "./services/removeCurrencySymbols";
|
|
20
22
|
export { removeNonNumeric } from "./services/removeNonNumeric";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAGrE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,iCAAiC,EAAE,MAAM,6CAA6C,CAAC;AAChG,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAGrE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export { formatDate } from "./formats/formatDate";
|
|
3
3
|
export { formatJsonObject } from "./formats/formatJsonObject";
|
|
4
4
|
export { formatJsonString } from "./formats/formatJsonString";
|
|
5
|
+
export { formatToCapitalizeFirstWordLetter } from "./formats/formatToCapitalizeFirstWordLetter";
|
|
5
6
|
export { formatToCep } from "./formats/formatToCep";
|
|
6
7
|
export { formatToCnpj } from "./formats/formatToCnpj";
|
|
7
8
|
export { formatToCpf } from "./formats/formatToCpf";
|
|
@@ -18,6 +19,7 @@ export { generateSlug } from "./generators/generateSlug";
|
|
|
18
19
|
// services
|
|
19
20
|
export { calculateCardInstallment } from "./services/calculateCardInstallment";
|
|
20
21
|
export { ensureQuotes } from "./services/ensureQuotes";
|
|
22
|
+
export { isHtml } from "./services/isHtml";
|
|
21
23
|
export { maskSensitiveData } from "./services/maskSensitiveData";
|
|
22
24
|
export { removeCurrencySymbols } from "./services/removeCurrencySymbols";
|
|
23
25
|
export { removeNonNumeric } from "./services/removeNonNumeric";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verifica se uma string contém marcação HTML.
|
|
3
|
+
*
|
|
4
|
+
* Esta função utiliza uma expressão regular para detectar a presença de tags HTML
|
|
5
|
+
* em uma string. A verificação é case-insensitive e detecta tanto tags de abertura
|
|
6
|
+
* quanto de fechamento.
|
|
7
|
+
*
|
|
8
|
+
* @param str - A string a ser verificada
|
|
9
|
+
* @returns `true` se a string contém marcação HTML, `false` caso contrário
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* isHtml('<p>Hello world</p>'); // true
|
|
14
|
+
* isHtml('<div>Content</div>'); // true
|
|
15
|
+
* isHtml('Plain text'); // false
|
|
16
|
+
* isHtml('Text with <b>bold</b>'); // true
|
|
17
|
+
* isHtml(''); // false
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare function isHtml(str: string): boolean;
|
|
21
|
+
export { isHtml };
|
|
22
|
+
//# sourceMappingURL=isHtml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isHtml.d.ts","sourceRoot":"","sources":["../../src/services/isHtml.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,iBAAS,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGpC;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verifica se uma string contém marcação HTML.
|
|
3
|
+
*
|
|
4
|
+
* Esta função utiliza uma expressão regular para detectar a presença de tags HTML
|
|
5
|
+
* em uma string. A verificação é case-insensitive e detecta tanto tags de abertura
|
|
6
|
+
* quanto de fechamento.
|
|
7
|
+
*
|
|
8
|
+
* @param str - A string a ser verificada
|
|
9
|
+
* @returns `true` se a string contém marcação HTML, `false` caso contrário
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* isHtml('<p>Hello world</p>'); // true
|
|
14
|
+
* isHtml('<div>Content</div>'); // true
|
|
15
|
+
* isHtml('Plain text'); // false
|
|
16
|
+
* isHtml('Text with <b>bold</b>'); // true
|
|
17
|
+
* isHtml(''); // false
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
function isHtml(str) {
|
|
21
|
+
const htmlRegex = /<\/?[a-z][\s\S]*>/i;
|
|
22
|
+
return htmlRegex.test(str);
|
|
23
|
+
}
|
|
24
|
+
export { isHtml };
|
package/package.json
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkyn/shared",
|
|
3
|
-
"version": "3.0.1-beta.
|
|
3
|
+
"version": "3.0.1-beta.70",
|
|
4
4
|
"main": "./dist/bundle.js",
|
|
5
|
-
"module": "./
|
|
5
|
+
"module": "./dist/bundle.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"license": "Apache-2.0",
|
|
9
9
|
"author": "Arkyn | Lucas Gonçalves",
|
|
10
|
-
"description": "
|
|
10
|
+
"description": "Comprehensive collection of reusable utilities for data formatting, validation, generation, and manipulation, featuring Brazilian document validators and financial tools.",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"utilities",
|
|
13
|
+
"formatting",
|
|
14
|
+
"validation",
|
|
15
|
+
"brazilian-documents",
|
|
16
|
+
"cpf",
|
|
17
|
+
"cnpj",
|
|
18
|
+
"cep",
|
|
19
|
+
"currency",
|
|
20
|
+
"typescript",
|
|
21
|
+
"generators"
|
|
22
|
+
],
|
|
23
|
+
"homepage": "https://docs.arkyn.dev/en/shared/introduction",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/Lucas-Eduardo-Goncalves/arkyn.git",
|
|
27
|
+
"directory": "packages/shared"
|
|
28
|
+
},
|
|
11
29
|
"scripts": {
|
|
12
30
|
"clean": "rm -rf dist",
|
|
13
|
-
"build": "
|
|
31
|
+
"build": "bunx vite build && tsc",
|
|
14
32
|
"test": "vitest --config vitest.config.ts",
|
|
15
33
|
"typecheck": "bunx tsc --project tsconfig.json --noEmit"
|
|
16
34
|
},
|
|
@@ -20,7 +38,8 @@
|
|
|
20
38
|
"devDependencies": {
|
|
21
39
|
"@types/uuid": "^10.0.0",
|
|
22
40
|
"bun-types": "latest",
|
|
23
|
-
"vitest": "^3.
|
|
24
|
-
"typescript": "^5.
|
|
41
|
+
"vitest": "^3.2.4",
|
|
42
|
+
"typescript": "^5.9.2",
|
|
43
|
+
"vite": "^5.4.19"
|
|
25
44
|
}
|
|
26
45
|
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
type InputFormatTypes = "brazilianDate" | "isoDate" | "timestamp";
|
|
2
|
-
|
|
3
|
-
type FormatDateFunction = (
|
|
4
|
-
date: string[], // [date: string, time?: string]
|
|
5
|
-
inputFormat: InputFormatTypes,
|
|
6
|
-
outputFormat: string,
|
|
7
|
-
timezone?: number
|
|
8
|
-
) => string;
|
|
9
|
-
|
|
10
|
-
function formatDateString(date: Date, format: string): string {
|
|
11
|
-
const pad = (num: number) => num.toString().padStart(2, "0");
|
|
12
|
-
|
|
13
|
-
const replacements: Record<string, string> = {
|
|
14
|
-
YYYY: date.getFullYear().toString(),
|
|
15
|
-
YY: date.getFullYear().toString().slice(-2),
|
|
16
|
-
MM: pad(date.getMonth() + 1),
|
|
17
|
-
DD: pad(date.getDate()),
|
|
18
|
-
hh: pad(date.getHours()),
|
|
19
|
-
mm: pad(date.getMinutes()),
|
|
20
|
-
ss: pad(date.getSeconds()),
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
return format.replace(
|
|
24
|
-
/YYYY|YY|MM|DD|hh|mm|ss/g,
|
|
25
|
-
(match) => replacements[match]
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Formats a date and time string based on the provided input and output formats.
|
|
31
|
-
*
|
|
32
|
-
* @param {[string, string]} dateTime - An array containing the date and optional time.
|
|
33
|
-
* - The first element is the date string.
|
|
34
|
-
* - The second element is the time string (default is "00:00:00").
|
|
35
|
-
* @param {"brazilianDate" | "isoDate" | "timestamp"} inputFormat - The format of the input date.
|
|
36
|
-
* - "brazilianDate": Expects the date in "DD/MM/YYYY" format.
|
|
37
|
-
* - "isoDate": Expects the date in "YYYY-MM-DD" format.
|
|
38
|
-
* - "timestamp": Expects the date in "YYYY/MM/DD" format.
|
|
39
|
-
* @param {string} outputFormat - The desired output format for the date.
|
|
40
|
-
* - Use placeholders like "YYYY", "MM", "DD", "hh", "mm", "ss" to define the format.
|
|
41
|
-
* @param {number} [timezone=0] - The timezone offset in hours to apply to the date.
|
|
42
|
-
* - Defaults to 0 (UTC).
|
|
43
|
-
* @returns {string} The formatted date string based on the output format.
|
|
44
|
-
* @throws {Error} If the input format is invalid.
|
|
45
|
-
* @throws {Error} If the date is invalid.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* // Format a Brazilian date to ISO format
|
|
49
|
-
* formatDate(["25/12/2023", "15:30:00"], "brazilianDate", "YYYY-MM-DD hh:mm:ss");
|
|
50
|
-
* // Returns: "2023-12-25 15:30:00"
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* // Format an ISO date to a custom format with timezone adjustment
|
|
54
|
-
* formatDate(["2023-12-25", "15:30:00"], "isoDate", "DD/MM/YYYY hh:mm:ss", -3);
|
|
55
|
-
* // Returns: "25/12/2023 12:30:00"
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
const formatDate: FormatDateFunction = (
|
|
59
|
-
[date, time = "00:00:00"],
|
|
60
|
-
inputFormat,
|
|
61
|
-
outputFormat,
|
|
62
|
-
timezone = 0
|
|
63
|
-
) => {
|
|
64
|
-
const dateParts = date.split(/[-/]/).map(Number);
|
|
65
|
-
const timeParts = time.split(".")[0].split(":").map(Number);
|
|
66
|
-
|
|
67
|
-
let day, month, year;
|
|
68
|
-
const [hours = 0, minutes = 0, seconds = 0] = timeParts;
|
|
69
|
-
|
|
70
|
-
switch (inputFormat) {
|
|
71
|
-
case "brazilianDate":
|
|
72
|
-
[day, month, year] = dateParts;
|
|
73
|
-
break;
|
|
74
|
-
case "isoDate":
|
|
75
|
-
[year, month, day] = dateParts;
|
|
76
|
-
break;
|
|
77
|
-
case "timestamp":
|
|
78
|
-
[year, month, day] = dateParts.map(Number);
|
|
79
|
-
break;
|
|
80
|
-
default:
|
|
81
|
-
throw new Error("Invalid input format");
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const formattedDate = new Date(year, month - 1, day, hours, minutes, seconds);
|
|
85
|
-
if (isNaN(formattedDate.getTime())) throw new Error("Invalid date");
|
|
86
|
-
|
|
87
|
-
formattedDate.setUTCHours(formattedDate.getUTCHours() + timezone);
|
|
88
|
-
|
|
89
|
-
return formatDateString(formattedDate, outputFormat);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export { formatDate };
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
type FormatJsonObjectFunction = (jsonString: any, identLevel: number) => string;
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Formats a JSON object into a human-readable string with proper indentation.
|
|
5
|
-
*
|
|
6
|
-
* @param obj - The JSON object or value to format. It can be an object, array, string, or primitive value.
|
|
7
|
-
* @param indentLevel - The current level of indentation to apply. This is used recursively to format nested structures.
|
|
8
|
-
* @returns A formatted string representation of the JSON object.
|
|
9
|
-
*
|
|
10
|
-
* @remarks
|
|
11
|
-
* - If the input is an object, it will be formatted with keys and values properly indented.
|
|
12
|
-
* - If the input is an array, each element will be formatted and indented on a new line.
|
|
13
|
-
* - If the input is a string that can be parsed as JSON, it will attempt to parse and format it.
|
|
14
|
-
* - Primitive values (e.g., numbers, booleans, null) will be converted to their string representation.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const obj = { name: "John", age: 30, hobbies: ["reading", "gaming"] };
|
|
19
|
-
* const formatted = formatJsonObject(obj, 0);
|
|
20
|
-
* console.log(formatted);
|
|
21
|
-
* // Output:
|
|
22
|
-
* // {
|
|
23
|
-
* // "name": "John",
|
|
24
|
-
* // "age": 30,
|
|
25
|
-
* // "hobbies": [
|
|
26
|
-
* // "reading",
|
|
27
|
-
* // "gaming"
|
|
28
|
-
* // ]
|
|
29
|
-
* // }
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
const formatJsonObject: FormatJsonObjectFunction = (obj, indentLevel) => {
|
|
34
|
-
const indent = " ".repeat(indentLevel);
|
|
35
|
-
let formattedString = "";
|
|
36
|
-
|
|
37
|
-
if (typeof obj === "object" && obj !== null) {
|
|
38
|
-
if (Array.isArray(obj)) {
|
|
39
|
-
if (obj.length === 0) {
|
|
40
|
-
// Caso especial para arrays vazios
|
|
41
|
-
formattedString += "[]";
|
|
42
|
-
} else {
|
|
43
|
-
formattedString += "[\n";
|
|
44
|
-
obj.forEach((item, index) => {
|
|
45
|
-
formattedString +=
|
|
46
|
-
indent + " " + formatJsonObject(item, indentLevel + 1);
|
|
47
|
-
if (index < obj.length - 1) {
|
|
48
|
-
formattedString += ",";
|
|
49
|
-
}
|
|
50
|
-
formattedString += "\n";
|
|
51
|
-
});
|
|
52
|
-
formattedString += indent + "]";
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
const keys = Object.keys(obj);
|
|
56
|
-
if (keys.length === 0) {
|
|
57
|
-
// Caso especial para objetos vazios
|
|
58
|
-
formattedString += "{}";
|
|
59
|
-
} else {
|
|
60
|
-
formattedString += "{\n";
|
|
61
|
-
keys.forEach((key, index) => {
|
|
62
|
-
formattedString +=
|
|
63
|
-
indent +
|
|
64
|
-
' "' +
|
|
65
|
-
key +
|
|
66
|
-
'": ' +
|
|
67
|
-
formatJsonObject(obj[key], indentLevel + 1);
|
|
68
|
-
if (index < keys.length - 1) {
|
|
69
|
-
formattedString += ",";
|
|
70
|
-
}
|
|
71
|
-
formattedString += "\n";
|
|
72
|
-
});
|
|
73
|
-
formattedString += indent + "}";
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
} else if (typeof obj === "string") {
|
|
77
|
-
try {
|
|
78
|
-
const parsedObj = JSON.parse(obj);
|
|
79
|
-
formattedString += formatJsonObject(parsedObj, indentLevel);
|
|
80
|
-
} catch {
|
|
81
|
-
formattedString += '"' + obj + '"';
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
formattedString += obj;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return formattedString;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export { formatJsonObject };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { formatJsonObject } from "./formatJsonObject";
|
|
2
|
-
|
|
3
|
-
type FormatJsonStringFunction = (jsonString: string) => string;
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Formats a JSON string into a more readable format.
|
|
7
|
-
*
|
|
8
|
-
* This function attempts to parse the provided JSON string into a JavaScript object,
|
|
9
|
-
* and then formats it using the `formatJsonObject` function. If the input string
|
|
10
|
-
* is not a valid JSON, it logs an error to the console and returns an empty string.
|
|
11
|
-
*
|
|
12
|
-
* @param jsonString - The JSON string to be formatted.
|
|
13
|
-
* @returns A formatted JSON string, or an empty string if the input is invalid.
|
|
14
|
-
*
|
|
15
|
-
* @throws Will log an error to the console if the input is not a valid JSON string.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* const jsonString = '{"name":"John","age":30,"hobbies":["reading","gaming"]}';
|
|
20
|
-
* const formatted = formatJsonString(jsonString);
|
|
21
|
-
* console.log(formatted);
|
|
22
|
-
* // Output:
|
|
23
|
-
* // {
|
|
24
|
-
* // "name": "John",
|
|
25
|
-
* // "age": 30,
|
|
26
|
-
* // "hobbies": [
|
|
27
|
-
* // "reading",
|
|
28
|
-
* // "gaming"
|
|
29
|
-
* // ]
|
|
30
|
-
* // }
|
|
31
|
-
|
|
32
|
-
* const invalidJsonString = '{"name":"John", "age":30,';
|
|
33
|
-
* const formatted = formatJsonString(invalidJsonString);
|
|
34
|
-
* console.log(formatted);
|
|
35
|
-
* // Output:
|
|
36
|
-
* // (Logs "Invalid JSON string: ..." to the console)
|
|
37
|
-
* // ""
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
const formatJsonString: FormatJsonStringFunction = (jsonString) => {
|
|
42
|
-
try {
|
|
43
|
-
const jsonObject = JSON.parse(jsonString);
|
|
44
|
-
return formatJsonObject(jsonObject, 0);
|
|
45
|
-
} catch (error) {
|
|
46
|
-
throw new Error(`Invalid JSON string \n ${error}`);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export { formatJsonString };
|