From 6ac4be71f249498e5b63b284ea8e661fb84b39f8 Mon Sep 17 00:00:00 2001 From: singuerinc Date: Mon, 25 Feb 2019 22:28:57 +0100 Subject: [PATCH] chore: build --- dist/index.js | 94 ++++++++++++++++++++++++++++------------------- dist/index.js.map | 2 +- 2 files changed, 57 insertions(+), 39 deletions(-) diff --git a/dist/index.js b/dist/index.js index 1e5e7eb..5d61638 100644 --- a/dist/index.js +++ b/dist/index.js @@ -9,14 +9,25 @@ (factory((global.SpanishCarPlate = {}))); }(this, (function (exports) { 'use strict'; + /** + * @param {string} str + */ function _partsSpecial(str) { - var cleaned = str.replace(/^[\s]*([CMEDGPNATFSHMORW]{1,5})[^A-Z0-9]*([0-9]{4})[\s]*$/i, "$1,$2"); + var cleaned = str.replace(/^[\s]*([CMEDGPNATFSHMORW]{1,5})[\W]*([0-9]{4})[\s]*$/i, "$1,$2"); return cleaned.split(","); } + /** + * @param {string} str + */ + function _partsOld(str) { var cleaned = str.replace(/^[\s]*([A-Z]{1,3})[^A-Z0-9]*([0-9]{4})[^A-Z0-9]*([A-Z]{2})[\s]*$/i, "$1,$2,$3"); return cleaned.split(","); } + /** + * @param {string} str + */ + function _partsNew(str) { var cleaned = str.replace(/^[\s]*([0-9]{4})[^A-Z0-9]*([BCDFGHJKLMNPRSTVWXYZ]{3})[\s]*$/i, "$1,$2"); return cleaned.split(","); @@ -43,31 +54,6 @@ return /^[A-Z]{1,3}[0-9]{4}[A-Z]{2}$/i.test(cleaned); } - /** - * Returns true if is a valid (post year 2000) car plate - * @param {string} value - * @returns {boolean} - * @since 0.0.1 - * @example - * isValid("2345BCF"); // => true - */ - - function isValid(value) { - if (isOld(value)) { - return true; - } - - var str = !value ? "" : value; - - var cleaned = _partsNew(str).join(""); - - if (cleaned.length !== 7) { - return false; - } - - return /^[0-9]{4}[BCDFGHJKLMNPRSTVWXYZ]{3}$/i.test(cleaned); - } - function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { @@ -156,7 +142,7 @@ MOP: "Public Works Ministry", PME: "State owned vehicles", PMM: "State owned vehicles, on a Ministry", - Crown: "King's Car" + CROWN: "King's Car" }; /** @@ -183,13 +169,42 @@ return false; } - if (!SPECIALS[code]) { + if (!SPECIALS[code.toUpperCase()]) { return false; } return /^[CMEDGPNATFSHMORW]{1,5}[0-9]{4}$/i.test(cleaned); } + /** + * Returns true if is a valid (post year 2000) car plate + * @param {string} value + * @returns {boolean} + * @since 0.0.1 + * @example + * isValid("2345BCF"); // => true + */ + + function isValid(value) { + if (isOld(value)) { + return true; + } + + if (isSpecial(value)) { + return true; + } + + var str = !value ? "" : value; + + var cleaned = _partsNew(str).join(""); + + if (cleaned.length !== 7) { + return false; + } + + return /^[0-9]{4}[BCDFGHJKLMNPRSTVWXYZ]{3}$/i.test(cleaned); + } + /** * * @param {string} value @@ -226,34 +241,37 @@ * @returns {number} * @since 0.0.5 * @example - * getNumber("2345BCF"); // => 2345 - * getNumber("GI-1234-CS"); // => 1234 + * getNumber("2345BCF"); // => "2345" + * getNumber("GI-1234-CS"); // => "1234" */ function getNumber(value) { var str = !value ? "" : value; + var n; if (isOld(str) === true) { var _partsOld2 = _partsOld(str), _partsOld3 = _slicedToArray(_partsOld2, 2), num = _partsOld3[1]; - return parseInt(num, 10); + n = num; } else if (isSpecial(str) === true) { var _partsSpecial2 = _partsSpecial(str), _partsSpecial3 = _slicedToArray(_partsSpecial2, 2), _num = _partsSpecial3[1]; - return parseInt(_num, 10); + n = _num; } else if (isValid(str)) { var _partsNew2 = _partsNew(str), _partsNew3 = _slicedToArray(_partsNew2, 1), _num2 = _partsNew3[0]; - return parseInt(_num2, 10); + n = _num2; + } else { + return null; } - return null; + return parseInt(n, 10).toString().padStart(4, "0"); } /** @@ -276,7 +294,7 @@ _partsSpecial3 = _slicedToArray(_partsSpecial2, 1), code = _partsSpecial3[0]; - return SPECIALS[code] ? code : null; + return code ? SPECIALS[code.toUpperCase()] ? code.toUpperCase() : null : null; } /** @@ -291,7 +309,7 @@ function getSpecialName(value) { var str = !value ? "" : value; var code = getSpecialCode(str); - return SPECIALS[code] || null; + return code ? SPECIALS[code.toUpperCase()] : null; } var PROVINCES = { @@ -374,7 +392,7 @@ _partsOld3 = _slicedToArray(_partsOld2, 1), code = _partsOld3[0]; - return PROVINCES[code] ? code : null; + return code ? PROVINCES[code.toUpperCase()] ? code.toUpperCase() : null : null; } /** @@ -389,7 +407,7 @@ function getProvinceName(value) { var str = !value ? "" : value; var code = getProvinceCode(str); - return PROVINCES[code] || null; + return code ? PROVINCES[code.toUpperCase()] : null; } function _parseNew(str) { diff --git a/dist/index.js.map b/dist/index.js.map index 862f2f2..44fc77b 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sources":["../src/_utils.js","../src/isOld.js","../src/isValid.js","../src/specials.js","../src/isSpecial.js","../src/getCounter.js","../src/getNumber.js","../src/getSpecialCode.js","../src/getSpecialName.js","../src/provinces.js","../src/getProvinceCode.js","../src/getProvinceName.js","../src/parse.js"],"sourcesContent":["export function _partsSpecial(str) {\n const cleaned = str.replace(\n /^[\\s]*([CMEDGPNATFSHMORW]{1,5})[^A-Z0-9]*([0-9]{4})[\\s]*$/i,\n \"$1,$2\"\n );\n\n return cleaned.split(\",\");\n}\n\nexport function _partsOld(str) {\n const cleaned = str.replace(\n /^[\\s]*([A-Z]{1,3})[^A-Z0-9]*([0-9]{4})[^A-Z0-9]*([A-Z]{2})[\\s]*$/i,\n \"$1,$2,$3\"\n );\n\n return cleaned.split(\",\");\n}\n\nexport function _partsNew(str) {\n const cleaned = str.replace(\n /^[\\s]*([0-9]{4})[^A-Z0-9]*([BCDFGHJKLMNPRSTVWXYZ]{3})[\\s]*$/i,\n \"$1,$2\"\n );\n\n return cleaned.split(\",\");\n}\n","import { _partsOld } from \"./_utils\";\n\n/**\n * Returns true if is a valid (old system 1971-2000) car plate\n * @param {string} value\n * @returns {boolean}\n * @since 0.0.2\n * @example\n * isOld(\"GI-1234-CS\"); // => true\n */\nfunction isOld(value) {\n const str = !value ? \"\" : value;\n const cleaned = _partsOld(str).join(\"\");\n\n if (cleaned.length < 7 || cleaned.length > 9) {\n return false;\n }\n\n return /^[A-Z]{1,3}[0-9]{4}[A-Z]{2}$/i.test(cleaned);\n}\n\nexport { isOld };\n","import { _partsNew } from \"./_utils\";\nimport { isOld } from \"./isOld\";\n\n/**\n * Returns true if is a valid (post year 2000) car plate\n * @param {string} value\n * @returns {boolean}\n * @since 0.0.1\n * @example\n * isValid(\"2345BCF\"); // => true\n */\nfunction isValid(value) {\n if (isOld(value)) {\n return true;\n }\n\n const str = !value ? \"\" : value;\n const cleaned = _partsNew(str).join(\"\");\n\n if (cleaned.length !== 7) {\n return false;\n }\n\n return /^[0-9]{4}[BCDFGHJKLMNPRSTVWXYZ]{3}$/i.test(cleaned);\n}\n\nexport { isValid };\n","export const SPECIALS = {\n CME: \"Corps of the Mossos d'Esquadra\",\n DGP: \"Spanish Police\",\n CNP: \"Spanish Police\",\n E: \"Autonomous police force of the Basque Country\",\n EA: \"Air Force\",\n ET: \"Spanish Army\",\n FAE: \"Allied Forces in Spain\",\n FN: \"Spanish Navy\",\n GSH: \"Colonial police on Sahara\",\n PGC: \"Spanish civil guard\",\n MF: \"Public Works Ministry\",\n MMA: \"Environment Ministry\",\n MOP: \"Public Works Ministry\",\n PME: \"State owned vehicles\",\n PMM: \"State owned vehicles, on a Ministry\",\n Crown: \"King's Car\"\n};\n","import { _partsSpecial } from \"./_utils\";\nimport { SPECIALS } from \"./specials\";\n\n/**\n * Returns true if is a valid spacial car plate\n * @param {string} value\n * @returns {boolean}\n * @since 0.0.7\n * @example\n * isSpecial(\"CME 2342\"); // => true\n * isSpecial(\"E 1660\"); // => true\n */\nfunction isSpecial(value) {\n const str = !value ? \"\" : value;\n const [code, num] = _partsSpecial(str);\n const cleaned = `${code}${num}`;\n\n if (cleaned.length < 5 || cleaned.length > 9) {\n return false;\n }\n\n if (!SPECIALS[code]) {\n return false;\n }\n\n return /^[CMEDGPNATFSHMORW]{1,5}[0-9]{4}$/i.test(cleaned);\n}\n\nexport { isSpecial };\n","import { isOld } from \"./isOld\";\nimport { isValid } from \"./isValid\";\nimport { _partsOld, _partsNew } from \"./_utils\";\n\n/**\n *\n * @param {string} value\n * @returns {string}\n * @since 0.0.5\n * @example\n * getCounter(\"GI-1234-CS\"); // => \"CS\"\n * getCounter(\"2345BCF\"); // => \"CS\"\n */\nfunction getCounter(value) {\n const str = !value ? \"\" : value;\n\n if (isOld(str) === true) {\n const [, , counter] = _partsOld(str);\n return counter;\n } else if (isValid(str)) {\n const [, counter] = _partsNew(str);\n return counter;\n }\n\n return null;\n}\n\nexport { getCounter };\n","import { isOld } from \"./isOld\";\nimport { isValid } from \"./isValid\";\nimport { isSpecial } from \"./isSpecial\";\nimport { _partsNew, _partsOld, _partsSpecial } from \"./_utils\";\n\n/**\n *\n * @param {string} value\n * @returns {number}\n * @since 0.0.5\n * @example\n * getNumber(\"2345BCF\"); // => 2345\n * getNumber(\"GI-1234-CS\"); // => 1234\n */\nfunction getNumber(value) {\n const str = !value ? \"\" : value;\n\n if (isOld(str) === true) {\n const [, num] = _partsOld(str);\n return parseInt(num, 10);\n } else if (isSpecial(str) === true) {\n const [, num] = _partsSpecial(str);\n return parseInt(num, 10);\n } else if (isValid(str)) {\n const [num] = _partsNew(str);\n return parseInt(num, 10);\n }\n\n return null;\n}\n\nexport { getNumber };\n","import { SPECIALS } from \"./specials\";\nimport { isSpecial } from \"./isSpecial\";\nimport { _partsSpecial } from \"./_utils\";\n\n/**\n * Returns the special code for a valid car plate\n * @param {string} value\n * @returns {string}\n * @since 0.0.7\n * @example\n * getSpecialCode(\"DGP-1234\"); // => \"DGP\"\n */\nfunction getSpecialCode(value) {\n const str = !value ? \"\" : value;\n\n if (!isSpecial(str)) {\n return null;\n }\n\n const [code] = _partsSpecial(str);\n\n return SPECIALS[code] ? code : null;\n}\n\nexport { getSpecialCode };\n","import { SPECIALS } from \"./specials\";\nimport { getSpecialCode } from \"./getSpecialCode\";\n\n/**\n * Returns the special name for a valid car plate\n * @param {string} value\n * @returns {string}\n * @since 0.0.7\n * @example\n * getSpecialCode(\"CME1234\"); // => \"Corps of the Mossos d'Esquadra\"\n */\nfunction getSpecialName(value) {\n const str = !value ? \"\" : value;\n const code = getSpecialCode(str);\n\n return SPECIALS[code] || null;\n}\n\nexport { getSpecialName };\n","export const PROVINCES = {\n A: \"Province of Alicante\",\n AB: \"Province of Albacete\",\n AL: \"Province of Almería\",\n AV: \"Province of Ávila\",\n B: \"Province of Barcelona\",\n BA: \"Province of Badajoz\",\n BI: \"Bilbao\",\n BU: \"Province of Burgos\",\n C: \"Province of A Coruña\",\n CA: \"Province of Cádiz\",\n CC: \"Province of Cáceres\",\n CE: \"Ceuta\",\n CO: \"Province of Córdoba\",\n CR: \"Province of Ciudad Real\",\n CS: \"Castelló\",\n CU: \"Province of Cuenca\",\n FP: \"Bioko\",\n GC: \"Province of Las Palmas\",\n GE: \"Gerona (Girona)\",\n GI: \"Province of Girona\",\n GR: \"Province of Granada\",\n GU: \"Province of Guadalajara\",\n H: \"Province of Huelva\",\n HU: \"Province of Huesca\",\n IF: \"Ifni\",\n J: \"Province of Jaén\",\n L: \"Province of Lleida\",\n LE: \"Province of León\",\n LO: \"Logroño\",\n LR: \"La Rioja\",\n LU: \"Province of Lugo\",\n M: \"Community of Madrid\",\n MA: \"Province of Málaga\",\n ML: \"Melilla\",\n MU: \"Region of Murcia\",\n NA: \"Navarre\",\n O: \"Oviedo\",\n OU: \"Province of Ourense\",\n P: \"Province of Palencia\",\n PM: \"Palma, Majorca\",\n PO: \"Province of Pontevedra\",\n RM: \"Rio Muni\",\n S: \"Santander\",\n SA: \"Province of Salamanca\",\n SE: \"Province of Seville\",\n SG: \"Province of Segovia\",\n SO: \"Province of Soria\",\n SS: \"Donostia\",\n T: \"Province of Tarragona\",\n TE: \"Province of Teruel\",\n TF: \"Province of Santa Cruz de Tenerife\",\n TO: \"Province of Toledo\",\n V: \"Province of Valencia\",\n VA: \"Province of Valladolid\",\n VI: \"Vitoria\",\n Z: \"Province of Zaragoza\",\n ZA: \"Province of Zamora\"\n};\n","import { PROVINCES } from \"./provinces\";\nimport { isOld } from \"./isOld\";\nimport { _partsOld } from \"./_utils\";\n\n/**\n * Returns the province code for a valid car plate in the old system (1971-2000)\n * @param {string} value\n * @returns {string}\n * @since 0.0.5\n * @example\n * getProvinceCode(\"GI-1234-CS\"); // => \"GI\"\n */\nfunction getProvinceCode(value) {\n const str = !value ? \"\" : value;\n\n if (!isOld(str)) {\n return null;\n }\n\n const [code] = _partsOld(str);\n\n return PROVINCES[code] ? code : null;\n}\n\nexport { getProvinceCode };\n","import { PROVINCES } from \"./provinces\";\nimport { getProvinceCode } from \"./getProvinceCode\";\n\n/**\n * Returns the province name for a valid car plate in the old system (1971-2000)\n * @param {string} value\n * @returns {string}\n * @since 0.0.5\n * @example\n * getProvinceName(\"GI-1234-CS\"); // => \"Province of Girona\"\n */\nfunction getProvinceName(value) {\n const str = !value ? \"\" : value;\n const code = getProvinceCode(str);\n\n return PROVINCES[code] || null;\n}\n\nexport { getProvinceName };\n","import { isValid } from \"./isValid\";\nimport { isOld } from \"./isOld\";\nimport { isSpecial } from \"./isSpecial\";\nimport { getProvinceName } from \"./getProvinceName\";\nimport { getProvinceCode } from \"./getProvinceCode\";\nimport { getCounter } from \"./getCounter\";\nimport { getNumber } from \"./getNumber\";\nimport { getSpecialCode } from \"./getSpecialCode\";\nimport { getSpecialName } from \"./getSpecialName\";\n\nfunction _parseNew(str) {\n const parsed = {};\n parsed.isOld = false;\n parsed.provinceName = null;\n parsed.provinceCode = null;\n parsed.specialCode = null;\n parsed.specialName = null;\n parsed.counter = getCounter(str);\n parsed.number = getNumber(str);\n return parsed;\n}\n\nfunction _parseOld(str) {\n const parsed = {};\n parsed.isOld = true;\n parsed.provinceName = getProvinceName(str);\n parsed.provinceCode = getProvinceCode(str);\n parsed.specialCode = null;\n parsed.specialName = null;\n parsed.counter = getCounter(str);\n parsed.number = getNumber(str);\n return parsed;\n}\n\nfunction _parseSpecial(str) {\n const parsed = {};\n parsed.isOld = false;\n parsed.provinceName = null;\n parsed.provinceCode = null;\n parsed.specialCode = getSpecialCode(str);\n parsed.specialName = getSpecialName(str);\n parsed.counter = null;\n parsed.number = getNumber(str);\n parsed.isSpecial = true;\n return parsed;\n}\n\n/**\n * Returns an object containing information about the plate\n * @param {string} value\n * @returns {boolean}\n * @since 0.0.5\n * @example\n * parse(\"2345BCF\"); // => { isSpecial: false, isOld: false, provinceCode: null, provinceName: null, number: 2345, counter: \"BCF\" }\n * parse(\"GI2345BC\"); // => { isSpecial: false, isOld: true, provinceCode: \"GI\", provinceName: \"Province of Girona\", number: 2345, counter: \"BC\" }\n */\nfunction parse(value) {\n const str = !value ? \"\" : value;\n const parsed = {\n isSpecial: false // TODO: not implemented\n };\n\n if (isOld(str) === true) {\n return {\n ...parsed,\n ..._parseOld(str)\n };\n } else if (isSpecial(str) === true) {\n return {\n ...parsed,\n ..._parseSpecial(str)\n };\n } else if (isValid(str) === true) {\n return {\n ...parsed,\n ..._parseNew(str)\n };\n }\n\n return null;\n}\n\nexport { parse };\n"],"names":["_partsSpecial","str","cleaned","replace","split","_partsOld","_partsNew","isOld","value","join","length","test","isValid","SPECIALS","CME","DGP","CNP","E","EA","ET","FAE","FN","GSH","PGC","MF","MMA","MOP","PME","PMM","Crown","isSpecial","code","num","getCounter","counter","getNumber","parseInt","getSpecialCode","getSpecialName","PROVINCES","A","AB","AL","AV","B","BA","BI","BU","C","CA","CC","CE","CO","CR","CS","CU","FP","GC","GE","GI","GR","GU","H","HU","IF","J","L","LE","LO","LR","LU","M","MA","ML","MU","NA","O","OU","P","PM","PO","RM","S","SA","SE","SG","SO","SS","T","TE","TF","TO","V","VA","VI","Z","ZA","getProvinceCode","getProvinceName","_parseNew","parsed","provinceName","provinceCode","specialCode","specialName","number","_parseOld","_parseSpecial","parse"],"mappings":";;;;;;;;;;;EAAO,S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;EAAA,GAAf;;EAIA,MAAIvB,KAAK,CAACN,GAAD,CAAL,KAAe,IAAnB,EAAyB;EACvB,6BACKmG,MADL,EAEKM,SAAS,CAACzG,GAAD,CAFd;EAID,GALD,MAKO,IAAI6B,SAAS,CAAC7B,GAAD,CAAT,KAAmB,IAAvB,EAA6B;EAClC,6BACKmG,MADL,EAEKO,aAAa,CAAC1G,GAAD,CAFlB;EAID,GALM,MAKA,IAAIW,OAAO,CAACX,GAAD,CAAP,KAAiB,IAArB,EAA2B;EAChC,6BACKmG,MADL,EAEKD,SAAS,CAAClG,GAAD,CAFd;EAID;;EAED,SAAO,IAAP;EACD;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"index.js","sources":["../src/_utils.js","../src/isOld.js","../src/specials.js","../src/isSpecial.js","../src/isValid.js","../src/getCounter.js","../src/getNumber.js","../src/getSpecialCode.js","../src/getSpecialName.js","../src/provinces.js","../src/getProvinceCode.js","../src/getProvinceName.js","../src/parse.js"],"sourcesContent":["/**\n * @param {string} str\n */\nexport function _partsSpecial(str) {\n const cleaned = str.replace(/^[\\s]*([CMEDGPNATFSHMORW]{1,5})[\\W]*([0-9]{4})[\\s]*$/i, \"$1,$2\");\n\n return cleaned.split(\",\");\n}\n\n/**\n * @param {string} str\n */\nexport function _partsOld(str) {\n const cleaned = str.replace(\n /^[\\s]*([A-Z]{1,3})[^A-Z0-9]*([0-9]{4})[^A-Z0-9]*([A-Z]{2})[\\s]*$/i,\n \"$1,$2,$3\"\n );\n\n return cleaned.split(\",\");\n}\n\n/**\n * @param {string} str\n */\nexport function _partsNew(str) {\n const cleaned = str.replace(\n /^[\\s]*([0-9]{4})[^A-Z0-9]*([BCDFGHJKLMNPRSTVWXYZ]{3})[\\s]*$/i,\n \"$1,$2\"\n );\n\n return cleaned.split(\",\");\n}\n","import { _partsOld } from \"./_utils\";\n\n/**\n * Returns true if is a valid (old system 1971-2000) car plate\n * @param {string} value\n * @returns {boolean}\n * @since 0.0.2\n * @example\n * isOld(\"GI-1234-CS\"); // => true\n */\nfunction isOld(value) {\n const str = !value ? \"\" : value;\n const cleaned = _partsOld(str).join(\"\");\n\n if (cleaned.length < 7 || cleaned.length > 9) {\n return false;\n }\n\n return /^[A-Z]{1,3}[0-9]{4}[A-Z]{2}$/i.test(cleaned);\n}\n\nexport { isOld };\n","export const SPECIALS = {\n CME: \"Corps of the Mossos d'Esquadra\",\n DGP: \"Spanish Police\",\n CNP: \"Spanish Police\",\n E: \"Autonomous police force of the Basque Country\",\n EA: \"Air Force\",\n ET: \"Spanish Army\",\n FAE: \"Allied Forces in Spain\",\n FN: \"Spanish Navy\",\n GSH: \"Colonial police on Sahara\",\n PGC: \"Spanish civil guard\",\n MF: \"Public Works Ministry\",\n MMA: \"Environment Ministry\",\n MOP: \"Public Works Ministry\",\n PME: \"State owned vehicles\",\n PMM: \"State owned vehicles, on a Ministry\",\n CROWN: \"King's Car\"\n};\n","import { _partsSpecial } from \"./_utils\";\nimport { SPECIALS } from \"./specials\";\n\n/**\n * Returns true if is a valid spacial car plate\n * @param {string} value\n * @returns {boolean}\n * @since 0.0.7\n * @example\n * isSpecial(\"CME 2342\"); // => true\n * isSpecial(\"E 1660\"); // => true\n */\nfunction isSpecial(value) {\n const str = !value ? \"\" : value;\n const [code, num] = _partsSpecial(str);\n const cleaned = `${code}${num}`;\n\n if (cleaned.length < 5 || cleaned.length > 9) {\n return false;\n }\n\n if (!SPECIALS[code.toUpperCase()]) {\n return false;\n }\n\n return /^[CMEDGPNATFSHMORW]{1,5}[0-9]{4}$/i.test(cleaned);\n}\n\nexport { isSpecial };\n","import { _partsNew } from \"./_utils\";\nimport { isOld } from \"./isOld\";\nimport { isSpecial } from \"./isSpecial\";\n\n/**\n * Returns true if is a valid (post year 2000) car plate\n * @param {string} value\n * @returns {boolean}\n * @since 0.0.1\n * @example\n * isValid(\"2345BCF\"); // => true\n */\nfunction isValid(value) {\n if (isOld(value)) {\n return true;\n }\n\n if (isSpecial(value)) {\n return true;\n }\n\n const str = !value ? \"\" : value;\n const cleaned = _partsNew(str).join(\"\");\n\n if (cleaned.length !== 7) {\n return false;\n }\n\n return /^[0-9]{4}[BCDFGHJKLMNPRSTVWXYZ]{3}$/i.test(cleaned);\n}\n\nexport { isValid };\n","import { isOld } from \"./isOld\";\nimport { isValid } from \"./isValid\";\nimport { _partsOld, _partsNew } from \"./_utils\";\n\n/**\n *\n * @param {string} value\n * @returns {string}\n * @since 0.0.5\n * @example\n * getCounter(\"GI-1234-CS\"); // => \"CS\"\n * getCounter(\"2345BCF\"); // => \"CS\"\n */\nfunction getCounter(value) {\n const str = !value ? \"\" : value;\n\n if (isOld(str) === true) {\n const [, , counter] = _partsOld(str);\n return counter;\n } else if (isValid(str)) {\n const [, counter] = _partsNew(str);\n return counter;\n }\n\n return null;\n}\n\nexport { getCounter };\n","import { isOld } from \"./isOld\";\nimport { isValid } from \"./isValid\";\nimport { isSpecial } from \"./isSpecial\";\nimport { _partsNew, _partsOld, _partsSpecial } from \"./_utils\";\n\n/**\n *\n * @param {string} value\n * @returns {number}\n * @since 0.0.5\n * @example\n * getNumber(\"2345BCF\"); // => \"2345\"\n * getNumber(\"GI-1234-CS\"); // => \"1234\"\n */\nfunction getNumber(value) {\n const str = !value ? \"\" : value;\n let n;\n\n if (isOld(str) === true) {\n const [, num] = _partsOld(str);\n n = num;\n } else if (isSpecial(str) === true) {\n const [, num] = _partsSpecial(str);\n n = num;\n } else if (isValid(str)) {\n const [num] = _partsNew(str);\n n = num;\n } else {\n return null;\n }\n\n return parseInt(n, 10)\n .toString()\n .padStart(4, \"0\");\n}\n\nexport { getNumber };\n","import { SPECIALS } from \"./specials\";\nimport { isSpecial } from \"./isSpecial\";\nimport { _partsSpecial } from \"./_utils\";\n\n/**\n * Returns the special code for a valid car plate\n * @param {string} value\n * @returns {string}\n * @since 0.0.7\n * @example\n * getSpecialCode(\"DGP-1234\"); // => \"DGP\"\n */\nfunction getSpecialCode(value) {\n const str = !value ? \"\" : value;\n\n if (!isSpecial(str)) {\n return null;\n }\n\n const [code] = _partsSpecial(str);\n\n return code ? (SPECIALS[code.toUpperCase()] ? code.toUpperCase() : null) : null;\n}\n\nexport { getSpecialCode };\n","import { SPECIALS } from \"./specials\";\nimport { getSpecialCode } from \"./getSpecialCode\";\n\n/**\n * Returns the special name for a valid car plate\n * @param {string} value\n * @returns {string}\n * @since 0.0.7\n * @example\n * getSpecialCode(\"CME1234\"); // => \"Corps of the Mossos d'Esquadra\"\n */\nfunction getSpecialName(value) {\n const str = !value ? \"\" : value;\n const code = getSpecialCode(str);\n\n return code ? SPECIALS[code.toUpperCase()] : null;\n}\n\nexport { getSpecialName };\n","export const PROVINCES = {\n A: \"Province of Alicante\",\n AB: \"Province of Albacete\",\n AL: \"Province of Almería\",\n AV: \"Province of Ávila\",\n B: \"Province of Barcelona\",\n BA: \"Province of Badajoz\",\n BI: \"Bilbao\",\n BU: \"Province of Burgos\",\n C: \"Province of A Coruña\",\n CA: \"Province of Cádiz\",\n CC: \"Province of Cáceres\",\n CE: \"Ceuta\",\n CO: \"Province of Córdoba\",\n CR: \"Province of Ciudad Real\",\n CS: \"Castelló\",\n CU: \"Province of Cuenca\",\n FP: \"Bioko\",\n GC: \"Province of Las Palmas\",\n GE: \"Gerona (Girona)\",\n GI: \"Province of Girona\",\n GR: \"Province of Granada\",\n GU: \"Province of Guadalajara\",\n H: \"Province of Huelva\",\n HU: \"Province of Huesca\",\n IF: \"Ifni\",\n J: \"Province of Jaén\",\n L: \"Province of Lleida\",\n LE: \"Province of León\",\n LO: \"Logroño\",\n LR: \"La Rioja\",\n LU: \"Province of Lugo\",\n M: \"Community of Madrid\",\n MA: \"Province of Málaga\",\n ML: \"Melilla\",\n MU: \"Region of Murcia\",\n NA: \"Navarre\",\n O: \"Oviedo\",\n OU: \"Province of Ourense\",\n P: \"Province of Palencia\",\n PM: \"Palma, Majorca\",\n PO: \"Province of Pontevedra\",\n RM: \"Rio Muni\",\n S: \"Santander\",\n SA: \"Province of Salamanca\",\n SE: \"Province of Seville\",\n SG: \"Province of Segovia\",\n SO: \"Province of Soria\",\n SS: \"Donostia\",\n T: \"Province of Tarragona\",\n TE: \"Province of Teruel\",\n TF: \"Province of Santa Cruz de Tenerife\",\n TO: \"Province of Toledo\",\n V: \"Province of Valencia\",\n VA: \"Province of Valladolid\",\n VI: \"Vitoria\",\n Z: \"Province of Zaragoza\",\n ZA: \"Province of Zamora\"\n};\n","import { PROVINCES } from \"./provinces\";\nimport { isOld } from \"./isOld\";\nimport { _partsOld } from \"./_utils\";\n\n/**\n * Returns the province code for a valid car plate in the old system (1971-2000)\n * @param {string} value\n * @returns {string}\n * @since 0.0.5\n * @example\n * getProvinceCode(\"GI-1234-CS\"); // => \"GI\"\n */\nfunction getProvinceCode(value) {\n const str = !value ? \"\" : value;\n\n if (!isOld(str)) {\n return null;\n }\n\n const [code] = _partsOld(str);\n\n return code ? (PROVINCES[code.toUpperCase()] ? code.toUpperCase() : null) : null;\n}\n\nexport { getProvinceCode };\n","import { PROVINCES } from \"./provinces\";\nimport { getProvinceCode } from \"./getProvinceCode\";\n\n/**\n * Returns the province name for a valid car plate in the old system (1971-2000)\n * @param {string} value\n * @returns {string}\n * @since 0.0.5\n * @example\n * getProvinceName(\"GI-1234-CS\"); // => \"Province of Girona\"\n */\nfunction getProvinceName(value) {\n const str = !value ? \"\" : value;\n const code = getProvinceCode(str);\n\n return code ? PROVINCES[code.toUpperCase()] : null;\n}\n\nexport { getProvinceName };\n","import { isValid } from \"./isValid\";\nimport { isOld } from \"./isOld\";\nimport { isSpecial } from \"./isSpecial\";\nimport { getProvinceName } from \"./getProvinceName\";\nimport { getProvinceCode } from \"./getProvinceCode\";\nimport { getCounter } from \"./getCounter\";\nimport { getNumber } from \"./getNumber\";\nimport { getSpecialCode } from \"./getSpecialCode\";\nimport { getSpecialName } from \"./getSpecialName\";\n\nfunction _parseNew(str) {\n const parsed = {};\n parsed.isOld = false;\n parsed.provinceName = null;\n parsed.provinceCode = null;\n parsed.specialCode = null;\n parsed.specialName = null;\n parsed.counter = getCounter(str);\n parsed.number = getNumber(str);\n return parsed;\n}\n\nfunction _parseOld(str) {\n const parsed = {};\n parsed.isOld = true;\n parsed.provinceName = getProvinceName(str);\n parsed.provinceCode = getProvinceCode(str);\n parsed.specialCode = null;\n parsed.specialName = null;\n parsed.counter = getCounter(str);\n parsed.number = getNumber(str);\n return parsed;\n}\n\nfunction _parseSpecial(str) {\n const parsed = {};\n parsed.isOld = false;\n parsed.provinceName = null;\n parsed.provinceCode = null;\n parsed.specialCode = getSpecialCode(str);\n parsed.specialName = getSpecialName(str);\n parsed.counter = null;\n parsed.number = getNumber(str);\n parsed.isSpecial = true;\n return parsed;\n}\n\n/**\n * Returns an object containing information about the plate\n * @param {string} value\n * @returns {boolean}\n * @since 0.0.5\n * @example\n * parse(\"2345BCF\"); // => { isSpecial: false, isOld: false, provinceCode: null, provinceName: null, number: 2345, counter: \"BCF\" }\n * parse(\"GI2345BC\"); // => { isSpecial: false, isOld: true, provinceCode: \"GI\", provinceName: \"Province of Girona\", number: 2345, counter: \"BC\" }\n */\nfunction parse(value) {\n const str = !value ? \"\" : value;\n const parsed = {\n isSpecial: false // TODO: not implemented\n };\n\n if (isOld(str) === true) {\n return {\n ...parsed,\n ..._parseOld(str)\n };\n } else if (isSpecial(str) === true) {\n return {\n ...parsed,\n ..._parseSpecial(str)\n };\n } else if (isValid(str) === true) {\n return {\n ...parsed,\n ..._parseNew(str)\n };\n }\n\n return null;\n}\n\nexport { parse };\n"],"names":["_partsSpecial","str","cleaned","replace","split","_partsOld","_partsNew","isOld","value","join","length","test","SPECIALS","CME","DGP","CNP","E","EA","ET","FAE","FN","GSH","PGC","MF","MMA","MOP","PME","PMM","CROWN","isSpecial","code","num","toUpperCase","isValid","getCounter","counter","getNumber","n","parseInt","toString","padStart","getSpecialCode","getSpecialName","PROVINCES","A","AB","AL","AV","B","BA","BI","BU","C","CA","CC","CE","CO","CR","CS","CU","FP","GC","GE","GI","GR","GU","H","HU","IF","J","L","LE","LO","LR","LU","M","MA","ML","MU","NA","O","OU","P","PM","PO","RM","S","SA","SE","SG","SO","SS","T","TE","TF","TO","V","VA","VI","Z","ZA","getProvinceCode","getProvinceName","_parseNew","parsed","provinceName","provinceCode","specialCode","specialName","number","_parseOld","_parseSpecial","parse"],"mappings":";;;;;;;;;;;EAAA;;;AAGA,EAAO,SAASA,aAAT,CAAuBC,GAAvB,EAA4B;EACjC,MAAMC,OAAO,GAAGD,GAAG,CAACE,OAAJ,CAAY,uDAAZ,EAAqE,OAArE,CAAhB;EAEA,SAAOD,OAAO,CAACE,KAAR,CAAc,GAAd,CAAP;EACD;EAED;;;;AAGA,EAAO,SAASC,SAAT,CAAmBJ,GAAnB,EAAwB;EAC7B,MAAMC,OAAO,GAAGD,GAAG,CAACE,OAAJ,CACd,mEADc,EAEd,UAFc,CAAhB;EAKA,SAAOD,OAAO,CAACE,KAAR,CAAc,GAAd,CAAP;EACD;EAED;;;;AAGA,EAAO,SAASE,SAAT,CAAmBL,GAAnB,EAAwB;EAC7B,MAAMC,OAAO,GAAGD,GAAG,CAACE,OAAJ,CACd,8DADc,EAEd,OAFc,CAAhB;EAKA,SAAOD,OAAO,CAACE,KAAR,CAAc,GAAd,CAAP;EACD;;EC7BD;;;;;;;;;EAQA,SAASG,KAAT,CAAeC,KAAf,EAAsB;EACpB,MAAMP,GAAG,GAAG,CAACO,KAAD,GAAS,EAAT,GAAcA,KAA1B;;EACA,MAAMN,OAAO,GAAGG,SAAS,CAACJ,GAAD,CAAT,CAAeQ,IAAf,CAAoB,EAApB,CAAhB;;EAEA,MAAIP,OAAO,CAACQ,MAAR,GAAiB,CAAjB,IAAsBR,OAAO,CAACQ,MAAR,GAAiB,CAA3C,EAA8C;EAC5C,WAAO,KAAP;EACD;;EAED,SAAO,gCAAgCC,IAAhC,CAAqCT,OAArC,CAAP;EACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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