chilean-plate-validator 0.6.0 → 0.6.7

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 CHANGED
@@ -1,10 +1,17 @@
1
1
  # chilean-plate-validator
2
2
 
3
+ ![Ridiculous badge, I wanted a shield too](https://img.shields.io/badge/sabrosura-extrema-brightgreen)
4
+ [![install size](https://packagephobia.com/badge?p=chilean-plate-validator)](https://packagephobia.com/result?p=chilean-plate-validator)
5
+ [![npm version](https://img.shields.io/npm/v/chilean-plate-validator)](https://www.npmjs.org/package/chilean-plate-validator)
6
+ [![npm downloads](https://img.shields.io/npm/dm/chilean-plate-validator)](https://npm-stat.com/charts.html?package=chilean-plate-validator)
7
+ [![Known Vulnerabilities](https://snyk.io/test/npm/chilean-plate-validator/badge.svg)](https://snyk.io/test/npm/chilean-plate-validator)
8
+ [![Coverage Status](https://coveralls.io/repos/github/gabo2151/chilean-plate-validator/badge.svg?branch=main)](https://coveralls.io/github/gabo2151/chilean-plate-validator?branch=main)
9
+
3
10
  ## Description
4
11
 
5
- This module will help you to verify if a chilean registration plate is valid.
12
+ This module will help you to verify if a chilean registration plate is valid (doesn't calculate the check digit).
6
13
 
7
- The RegExes built in code follows the chilean civil registration specifications.
14
+ The RegExes built in, follow the chilean civil registration specifications.
8
15
 
9
16
  [«Instructivo para Validación de Patentes - Servicio de Registro Civil e Identificación»](https://www.registrocivil.cl/PortalOI/Manuales/ValidacionPatentes.pdf)
10
17
 
@@ -36,7 +43,7 @@ $ npm i chilean-plate-validator --save
36
43
 
37
44
  ## License
38
45
 
39
- Read LICENCE.md
46
+ [MIT License](https://github.com/gabo2151/chilean-plate-validator/blob/main/LICENSE)
40
47
 
41
48
  ## Author
42
49
 
package/dist/index.js CHANGED
@@ -19,14 +19,9 @@ var REGEX_LIST = [
19
19
  * false otherwise.
20
20
  */
21
21
  function plateValid(plate) {
22
- var state = false;
23
22
  if (plate == null)
24
- return state;
25
- REGEX_LIST.forEach(function (reg) {
26
- if (reg.regex.test("".concat(plate)))
27
- state = true;
28
- });
29
- return state;
23
+ return false;
24
+ return !!REGEX_LIST.find(function (reg) { return reg.regex.test(plate.toUpperCase()); });
30
25
  }
31
26
  exports.plateValid = plateValid;
32
27
  /**
@@ -37,14 +32,10 @@ exports.plateValid = plateValid;
37
32
  * @returns The type according to the RegEx that matches the plate submitted.
38
33
  */
39
34
  function plateType(plate) {
40
- var type = 'INVALID';
41
35
  if (plate == null)
42
- return type;
43
- REGEX_LIST.forEach(function (reg) {
44
- if (reg.regex.test("".concat(plate)))
45
- type = reg.name;
46
- });
47
- return type;
36
+ return 'INVALID';
37
+ var findPlate = REGEX_LIST.find(function (reg) { return reg.regex.test(plate.toUpperCase()); });
38
+ return (findPlate ? findPlate.name : 'INVALID');
48
39
  }
49
40
  exports.plateType = plateType;
50
41
  /**
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,IAAM,UAAU,GAAG;IACjB,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,+BAA+B,EAAE;IAC7D,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,8CAA8C,EAAE;IACpF,EAAE,IAAI,EAAE,sBAAsB,EAAE,KAAK,EAAE,4CAA4C,EAAE;CACtF,CAAA;AAED;;;;;;;GAOG;AACH,SAAgB,UAAU,CAAC,KAAa;IACtC,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,KAAK,CAAC;IAChC,UAAU,CAAC,OAAO,CAAC,UAAA,GAAG;QACpB,IAAK,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,UAAG,KAAK,CAAE,CAAC;YAAG,KAAK,GAAG,IAAI,CAAC;IACjD,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC;AAPD,gCAOC;AAED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AAI,OAAA,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,EAAnC,CAAmC,CAAC,CAAC;AACvE,CAAC;AAHD,gCAGC;AAED;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,KAAa;IACrC,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,SAAS,CAAC;IACpC,IAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,EAAnC,CAAmC,CAAC,CAAC;IAC9E,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAClD,CAAC;AAJD,8BAIC;AAED;;GAEG;AACH;IAIE;;;;OAIG;IACH,iBAAY,KAAa;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,sBAAI,0BAAK;aAAT;YACE,OAAO,IAAI,CAAC,UAAU,CAAC;QACzB,CAAC;;;OAAA;IAED,sBAAI,yBAAI;aAAR;YACE,OAAO,IAAI,CAAC,SAAS,CAAC;QACxB,CAAC;;;OAAA;IAEH,cAAC;AAAD,CAAC,AAtBD,IAsBC;AAtBY,0BAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chilean-plate-validator",
3
- "version": "0.6.0",
3
+ "version": "0.6.7",
4
4
  "description": "Simple chilean plate validator",
5
5
  "author": "Gabriel Galilea",
6
6
  "license": "MIT License",
@@ -8,7 +8,7 @@
8
8
  "typings": "dist/index.d.ts",
9
9
  "scripts": {
10
10
  "build": "tsc",
11
- "test": "echo \"Error: no test specified\" && exit 1"
11
+ "test": "jest"
12
12
  },
13
13
  "repository": {
14
14
  "type": "git",
@@ -21,8 +21,10 @@
21
21
  "validator",
22
22
  "validar"
23
23
  ],
24
- "dependencies": {},
25
24
  "devDependencies": {
25
+ "@types/jest": "^28.1.4",
26
+ "jest": "^28.1.2",
27
+ "ts-jest": "^28.0.5",
26
28
  "typescript": "^4.7.4"
27
29
  }
28
30
  }