hormander / json-lzw

GNU General Public License v2.0
4 stars 2 forks source link

TypeError: Cannot read property 'split' of undefined #6

Open wallali opened 7 years ago

wallali commented 7 years ago

I get an error during decode:

TypeError: Cannot read property 'split' of undefined
    at Object.unpack (node_modules/jsonpack/main.js:306:20)
    at JSONLZW.decode (node_modules/json-lzw/lib/json-lzw.js:14:16)

Also in the example I think there is error:

var encode = lzw.encode(buffer); console.log(encode);

var decode = lzw.decode(buffer encode); console.log(decode);

simrongit commented 7 years ago

I also faced same problem. on debugging found that "buffer = rawBuffers[2];" buffer is undefined hence the split error. changed the if condition but failed on next one "var len=rawBuffers[3].length;" It mean developer expect there have to be 4 splits from statement "var rawBuffers = packed.split('^');" which is not the case because {'message': 'hello world'} get converted into message|hello+world^?$0|1] Also can't provide input as string '{\'message\': \'hello world\'}' gets parse error.

daviemakz commented 6 years ago

Any word on this issue?