Unable to serialise maps and UInt8Arrays at the same time
> a = new Map()
Map(0) {size: 0}
> a.set("test", 123);
Map(1) {'test' => 123}
> msgpack.decode(msgpack.encode(a))
{}
> msgpack.decode(msgpack.encode(a, {codec: msgpack.createCodec({usemap: true})}))
{test: 123}
> msgpack.decode(msgpack.encode(enc.encode("test")))
Uint8Array(4) [116, 101, 115, 116, buffer: ArrayBuffer(4), byteLength: 4, byteOffset: 0, length: 4, Symbol(Symbol.toStringTag): 'Uint8Array']
> msgpack.decode(msgpack.encode(enc.encode("test"), {codec: msgpack.createCodec({usemap: true})}))
{0: 116, 1: 101, 2: 115, 3: 116}
The last output is wrong. Note that deserialisation is without usemap in all examples; the issue is only at the serialization side (where, ideally, you'd not have to specify usemap at all, there is no reason you can't automatically detect that an object is a Map object just like you detect that it's a UInt8Array and handle it specially).
I'm using version 0.1.26 btw
I'm also facing the same issue. Though, this is happening only if i use webpack5 to build my webapp. It works fine when I use webpack3. Not sure about the reason yet.
Did you find a solution for it?
Nope, just worked around the issue (accepted that keys are garbled and recurse over object and ungarble them; all of mine are byte arrays, so the string representation of them are deterministic and the mapping reversable). But far from ideal.