bytebuffer.js
bytebuffer.js copied to clipboard
ByteBuffer.fromHex returns an empty buffer for non-hex characters
Using version 3.5.5 with nodejs v0.12.4
var ByteBuffer = require('bytebuffer')
var a = ByteBuffer.fromHex('vvzzkk', true, false)
console.log(a);
var b = ByteBuffer.fromHex('vvzzkk', true, true)
console.log(b);
prints
{ buffer: <Buffer >,
offset: 0,
markedOffset: -1,
limit: 0,
littleEndian: true,
noAssert: true }
{ buffer: <Buffer >,
offset: 0,
markedOffset: -1,
limit: 0,
littleEndian: true,
noAssert: true }
I would expect it to throw an error for non-hex characters, given https://github.com/dcodeIO/ByteBuffer.js/blob/master/src/encodings/hex.js#L65
Hmm, in the node case, it's hardcoding noAssert to true... is that intentional?
https://github.com/dcodeIO/ByteBuffer.js/blob/master/src/encodings/hex.js#L53