chilean-plate-validator 0.6.1 → 0.7.0

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,24 @@
1
1
  # chilean-plate-validator
2
2
 
3
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
+ [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=gabo2151_chilean-plate-validator&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=gabo2151_chilean-plate-validator)
9
+ [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=gabo2151_chilean-plate-validator&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=gabo2151_chilean-plate-validator)
10
+ [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=gabo2151_chilean-plate-validator&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=gabo2151_chilean-plate-validator)
11
+ [![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=gabo2151_chilean-plate-validator&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=gabo2151_chilean-plate-validator)
12
+ [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=gabo2151_chilean-plate-validator&metric=coverage)](https://sonarcloud.io/summary/new_code?id=gabo2151_chilean-plate-validator)
13
+ [![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=gabo2151_chilean-plate-validator&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=gabo2151_chilean-plate-validator)
14
+ [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=gabo2151_chilean-plate-validator&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=gabo2151_chilean-plate-validator)
15
+ [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=gabo2151_chilean-plate-validator&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=gabo2151_chilean-plate-validator)
16
+ [![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=gabo2151_chilean-plate-validator&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=gabo2151_chilean-plate-validator)
17
+ [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=gabo2151_chilean-plate-validator&metric=bugs)](https://sonarcloud.io/summary/new_code?id=gabo2151_chilean-plate-validator)
4
18
 
5
19
  ## Description
6
20
 
7
- This module will help you to verify if a chilean registration plate is valid.
21
+ This module will help you to verify if a chilean registration plate is valid (doesn't calculate the check digit).
8
22
 
9
23
  The RegExes built in, follow the chilean civil registration specifications.
10
24
 
@@ -38,7 +52,7 @@ $ npm i chilean-plate-validator --save
38
52
 
39
53
  ## License
40
54
 
41
- Read LICENCE.md
55
+ [MIT License](https://github.com/gabo2151/chilean-plate-validator/blob/main/LICENSE)
42
56
 
43
57
  ## Author
44
58
 
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;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,KAAa;IACrC,IAAI,IAAI,GAAG,SAAS,CAAC;IACrB,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/B,UAAU,CAAC,OAAO,CAAC,UAAA,GAAG;QACpB,IAAK,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,UAAG,KAAK,CAAE,CAAC;YAAG,IAAI,GAAG,GAAG,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AAC,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.1",
3
+ "version": "0.7.0",
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
  }