Comparing version 0.8.0 to 0.8.1
@@ -96,26 +96,26 @@ /* | ||
setString(value, startIndex, endIndex, charBits) { | ||
for (let i = 0; i < value.length && (charBits = Math.min(charBits, endIndex - startIndex)) > 0; ++i) { // iterate bytes | ||
this.set(value.charCodeAt(i), startIndex, startIndex += charBits); | ||
} | ||
for (; startIndex < endIndex; ++startIndex) { // clear remaining bits | ||
this.clearBit(startIndex); | ||
} | ||
for (let i = 0; i < value.length && (charBits = Math.min(charBits, endIndex - startIndex)) > 0; ++i) { // iterate bytes | ||
this.set(value.charCodeAt(i), startIndex, startIndex += charBits); | ||
} | ||
for (; startIndex < endIndex; ++startIndex) { // clear remaining bits | ||
this.clearBit(startIndex); | ||
} | ||
} | ||
/** | ||
* Return string from bit array | ||
* @param startIndex offset | ||
* @param endIndex last bit | ||
* @param charBits how many bits has stored in a byte (max 8 bits) | ||
* @return | ||
*/ | ||
getString(startIndex, endIndex, charBits) { | ||
let b, result = ""; | ||
for (let i = 0; (charBits = Math.min(charBits, endIndex - startIndex)) > 0; ++i) { // iterate bytes | ||
if(b = this.get(startIndex, startIndex += charBits)) { | ||
result += String.fromCharCode(b); | ||
} | ||
} | ||
return result; | ||
* Return string from bit array | ||
* @param startIndex offset | ||
* @param endIndex last bit | ||
* @param charBits how many bits has stored in a byte (max 8 bits) | ||
* @return | ||
*/ | ||
getString(startIndex, endIndex, charBits) { | ||
let b, result = ""; | ||
for (let i = 0; (charBits = Math.min(charBits, endIndex - startIndex)) > 0; ++i) { // iterate bytes | ||
if(b = this.get(startIndex, startIndex += charBits)) { | ||
result += String.fromCharCode(b); | ||
} | ||
} | ||
return result; | ||
} | ||
@@ -161,3 +161,3 @@ /** | ||
for (let j = 0, i = 0; i < this.length; i++, j += 2) { | ||
this.data[i] = BitArray.REVERSE_DEC_TABLE[hex.charCodeAt(j)] | (BitArray.REVERSE_DEC_TABLE[hex.charCodeAt(j+1)] << 4) | ||
this.data[i] = BitArray.REVERSE_DEC_TABLE[hex.charCodeAt(j)] | (BitArray.REVERSE_DEC_TABLE[hex.charCodeAt(j+1)] << 4) | ||
} | ||
@@ -216,2 +216,2 @@ return this; | ||
module.exports = { BitArray }; | ||
module.exports = { BitArray }; |
{ | ||
"name": "epc-tds", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "directories": { |
@@ -10,7 +10,7 @@ # epc-tds | ||
### Automatic decoding of any standard | ||
### Automatic decoding of any standard (SGTIN-96, SGTIN-198, SSCC-96, SGLN-96, SGLN-195, GRAI-96, GRAI-170 ...) | ||
```js | ||
const tds = require('epc-tds'); | ||
var epc = tds.valueOf("3074257bf7194e4000001a85"); | ||
var epc = tds.valueOf("3074257BF7194E4000001A85"); | ||
console.log(epc.toHexString()); | ||
@@ -63,2 +63,2 @@ | ||
[npm-url]: https://npmjs.org/package/epc-tds | ||
[npm-image]: https://img.shields.io/npm/v/epc-tds.svg | ||
[npm-image]: https://img.shields.io/npm/v/epc-tds.svg |
58785
1447
63