Skip to content

Commit

Permalink
Add isTz
Browse files Browse the repository at this point in the history
  • Loading branch information
lgaticaq committed Mar 2, 2016
1 parent a1b1be4 commit b2183ad
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,30 @@ const parse = (raw) => {
return result;
};

const isTz = (raw) => {
let result = false;
if (patterns.avl05.test(raw.toString())) {
result = true;
} else if (patterns.avl08.test(raw.toString())) {
result = true;
} else if (patterns.avl201.test(raw.toString())) {
result = true;
} else if (patterns.receiveOk.test(raw.toString())) {
result = true;
} else if (patterns.picture.test(raw.toString())) {
result = true;
} else if (patterns.receiveErr.test(raw.toString())) {
result = true;
} else if (patterns.info.test(raw.toString())) {
result = true;
} else if (patterns.firmware.test(raw.toString())) {
result = true;
} else if (patterns.map.test(raw.toString())) {
result = true;
}
return result;
};

module.exports = {
parse: parse,
patterns: patterns,
Expand All @@ -647,5 +671,6 @@ module.exports = {
getCommandInfo: getCommandInfo,
getCommandMap: getCommandMap,
verifyLen: verifyLen,
verifyCrc: verifyCrc
verifyCrc: verifyCrc,
isTz: isTz
};
6 changes: 6 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,4 +678,10 @@ describe('tz-parzer', () => {
data: 'FFD8FFDB008400100B0C0E0C0A100E0D0E1211101318281A181616183123251D283A333D3C3933383740485C4E404457453738506D51575F626768673E4D71797064785C656763011112121815182F1A1A2F634238426363636363636363636363636363'
}]);
});

it('should return true', () => {
const raw = new Buffer('$$B6869444005480041|AA$GPRMC,194329.000,A,3321.6735,S,07030.7640,W,0.00,0.00,090216,,,A*6C|02.1|01.3|01.7|000000000000|20160209194326|13981188|00000000|32D3A03F|0000|0.6376|0100|995F\r\n');
const data = tz.isTz(raw);
expect(data).to.be.a.true;
});
});

0 comments on commit b2183ad

Please sign in to comment.