Skip to content

Commit

Permalink
feat: getSpecialName
Browse files Browse the repository at this point in the history
  • Loading branch information
singuerinc committed Feb 20, 2019
1 parent 79f6bd5 commit e17ecf7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
3 changes: 3 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import { getProvinceCode } from "./getProvinceCode";
import { getCounter } from "./getCounter";
import { getNumber } from "./getNumber";
import { getSpecialCode } from "./getSpecialCode";
import { getSpecialName } from "./getSpecialName";

function _parseNew(str) {
const parsed = {};
parsed.isOld = false;
parsed.provinceName = null;
parsed.provinceCode = null;
parsed.specialCode = null;
parsed.specialName = null;
parsed.counter = getCounter(str);
parsed.number = getNumber(str);
return parsed;
Expand All @@ -24,6 +26,7 @@ function _parseOld(str) {
parsed.provinceName = getProvinceName(str);
parsed.provinceCode = getProvinceCode(str);
parsed.specialCode = null;
parsed.specialName = null;
parsed.counter = getCounter(str);
parsed.number = getNumber(str);
return parsed;
Expand All @@ -35,6 +38,7 @@ function _parseSpecial(str) {
parsed.provinceName = null;
parsed.provinceCode = null;
parsed.specialCode = getSpecialCode(str);
parsed.specialName = getSpecialName(str);
parsed.counter = null;
parsed.number = getNumber(str);
parsed.isSpecial = true;
Expand Down
3 changes: 3 additions & 0 deletions test/parse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe("#parse", () => {
isSpecial: true,
isOld: false,
specialCode: "DGP",
specialName: "Spanish Police",
provinceCode: null,
provinceName: null,
number: 1234,
Expand All @@ -41,6 +42,7 @@ describe("#parse", () => {
isSpecial: false,
isOld: true,
specialCode: null,
specialName: null,
provinceCode: "GI",
provinceName: "Province of Girona",
number: 2345,
Expand All @@ -55,6 +57,7 @@ describe("#parse", () => {
isSpecial: false,
isOld: false,
specialCode: null,
specialName: null,
provinceCode: null,
provinceName: null,
number: 2345,
Expand Down
13 changes: 6 additions & 7 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@ declare function getCounter(value: string): string;
declare function getNumber(value: string): number;
declare function getProvinceCode(value: string): string;
declare function getProvinceName(value: string): string;

declare function isSpecial(value: string): boolean;
/**
* Returns true if is a valid (old system 1971-2000) car plate
*/
declare function getSpecialName(value: string): string;
declare function getSpecialCode(value: string): string;
declare function isOld(value: string): boolean;
/**
* Returns true if is a valid (post year 2000) car plate
*/
declare function isValid(value: string): boolean;

interface IPlate {
isSpecial: boolean;
isOld: boolean;
specialCode: string;
specialName: string;
provinceCode: string;
provinceName: string;
number: number;
Expand All @@ -35,6 +32,8 @@ export {
getCounter,
getProvinceName,
getProvinceCode,
getSpecialName,
getSpecialCode,
getNumber,
PROVINCES,
SPECIALS
Expand Down

0 comments on commit e17ecf7

Please sign in to comment.