Comparing version 0.7.0 to 0.8.0
@@ -28,3 +28,3 @@ /** | ||
static SERIAL_BITS = 112; | ||
static MAX_SERIAL_LEN = 16; | ||
static MAX_SERIAL_LEN = 16; | ||
static CHAR_BITS = (Grai170.SERIAL_END - Grai170.SERIAL_OFFSET) / Grai170.MAX_SERIAL_LEN; // 7 | ||
@@ -49,3 +49,3 @@ | ||
getType() { | ||
return Type.SGTIN96; | ||
return Type.GRAI170; | ||
} | ||
@@ -52,0 +52,0 @@ |
@@ -56,3 +56,3 @@ /** | ||
getType() { | ||
return Type.SGTIN96; | ||
return Type.GRAI96; | ||
} | ||
@@ -59,0 +59,0 @@ |
@@ -8,8 +8,12 @@ /* | ||
static SGTIN96 = "SGTIN96"; | ||
static SGTIN198 = "SGTIN198"; | ||
static SSCC96 = "SSCC96"; | ||
static SGLN96 = "SGLN96"; | ||
static SGTIN96 = "SGTIN-96"; | ||
static SGTIN198 = "SGTIN-198"; | ||
static SSCC96 = "SSCC-96"; | ||
static SGLN96 = "SGLN-96"; | ||
static SGLN195 = "SGLN-195"; | ||
static GRAI96 = "GRAI-96"; | ||
static GRAI170 = "GRAI-170"; | ||
static GID96 = "GID-96"; | ||
} | ||
module.exports = { Type }; |
@@ -12,5 +12,7 @@ /* | ||
const { Sgln96 } = require("./epc/sgln/sgln96"); | ||
const { Sgln195 } = require("./epc/sgln/sgln195"); | ||
const { Sscc96 } = require('./epc/sscc/sscc96'); | ||
const { Grai96 } = require('./epc/grai/grai96'); | ||
const { Grai170 } = require('./epc/grai/grai170'); | ||
const { Gid96 } = require('./epc/gid/gid96'); | ||
@@ -28,2 +30,4 @@ function valueOf(hexEpc) { | ||
return new Sgln96(hexEpc); | ||
case Sgln195.EPC_HEADER: | ||
return new Sgln195(hexEpc); | ||
case Sgtin96.EPC_HEADER: | ||
@@ -33,2 +37,4 @@ return new Sgtin96(hexEpc); | ||
return new Sgtin198(hexEpc); | ||
case Gid96.EPC_HEADER: | ||
return new Gid96(hexEpc); | ||
default: | ||
@@ -39,4 +45,3 @@ throw new Error(`Unsupported EPC: '${hexEpc}'`); | ||
exports = module.exports = { Sgtin96, Sgtin198, Sgln96, Sscc96, Grai96, Grai170, Utils }; | ||
exports = module.exports = { Sgtin96, Sgtin198, Sgln96, Sgln195, Sscc96, Grai96, Grai170, Gid96, Utils }; | ||
exports.valueOf = valueOf; |
{ | ||
"name": "epc-tds", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "directories": { |
36
test.js
@@ -8,2 +8,3 @@ /* | ||
const { Gid96 } = require("./epc/gid/gid96.js"); | ||
var tds = require("./index.js"); | ||
@@ -117,2 +118,37 @@ | ||
function sgln195Test(n) { | ||
let epc, ean; | ||
for(let i = 0; i < n; ++i) { | ||
ean = tds.Utils.randomEan(13); | ||
epc = new tds.Sgln195().setFilter(3).setPartition(6).setGln(ean).setExtension(tds.Utils.randomHex(tds.Sgln195.MAX_SERIAL_LEN)); | ||
epc = new tds.Sgln195(epc.toHexString()); | ||
if(ean !== epc.getGln()) { | ||
throw Error(`Sgln195, expected GLN: ${ean}, current: ${epc.getGln()}`); | ||
} | ||
} | ||
//console.log(epc.toHexString()) | ||
//console.log(epc.getGtin()); | ||
} | ||
time = test(sgln195Test, ITERATIONS); | ||
console.log("Test Sgln195 time: " + time); | ||
function gid96Test(n) { | ||
let epc; | ||
for(let i = 0; i < n; ++i) { | ||
let manager = Math.floor(Math.random() * tds.Gid96.MAX_MANAGER); | ||
let clazz = Math.floor(Math.random() * tds.Gid96.MAX_CLASS); | ||
let serial = Math.floor(Math.random() * tds.Gid96.MAX_SERIAL); | ||
epc = new tds.Gid96().setManager(manager).setClass (clazz).setSerial (serial); | ||
epc = new tds.Gid96(epc.toHexString()); | ||
if(manager !== epc.getManager() || clazz !== epc.getClass() || serial != epc.getSerial()) { | ||
throw Error(`Gid96, expected: [${manager}, ${clazz}, ${serial}] current: [${epc.getManager()}, ${epc.getClass()}, ${epc.getSerial()}]`); | ||
} | ||
} | ||
//console.log(epc.toHexString()) | ||
} | ||
time = test(gid96Test, ITERATIONS); | ||
console.log("Test Gid96 time: " + time); | ||
console.log("*** Test completed successfully! ***"); |
58710
20
1446