Is there a recommended way to convert the output into a string?
papb opened this issue · 2 comments
I've noticed that this module returns an array of numbers. Is there a recommended way to convert the output into a string?
I could use .join(',')
for example, but I feel that such approach is contrary to the idea of compression. Surely a lot more information could fit in a string if I use all printable ASCII characters instead of only numbers and a comma.
Thanks!!
Hello, why did you think this is a duplicate of my other question? Maybe if I add some code it will make it more clear:
const lzwcompress = require('lzwcompress');
const data = [{
foo: ['bar', { baz: 123 }],
foobar: {
abc123: true
}
}];
const compressed = lzwcompress.pack(data);
console.log(compressed);
Output:
[
123, 34, 95, 95, 107, 34, 58, 91, 34, 102, 111,
111, 34, 44, 34, 98, 97, 122, 268, 264, 266, 271,
114, 274, 97, 98, 99, 49, 50, 51, 34, 93, 269,
258, 118, 261, 91, 256, 48, 291, 270, 97, 278, 44,
256, 49, 261, 283, 51, 125, 287, 34, 50, 261, 256,
285, 58, 116, 114, 117, 101, 125, 305, 125
]
The question: is there a recommended way to convert this array of numbers into a string in the context of LZW? I could do compressed.join(',')
of course but I think it is likely for another recommended way to exist. (Of course, I would also need a way to un-convert later as a pre-unpack step)