|
1 |
| -import { unpack, pack } from 'msgpackr'; |
| 1 | +import { encode, decode } from 'msgpackr'; |
2 | 2 | // eslint-disable-next-line import/order
|
3 | 3 | import { Buffer } from 'buffer'
|
4 | 4 | import { isUndefined } from 'lodash'
|
@@ -72,7 +72,7 @@ const formattingBuffer = (
|
72 | 72 | case KeyValueFormat.JSON: return bufferToJSON(reply, props as FormattingProps)
|
73 | 73 | case KeyValueFormat.Msgpack: {
|
74 | 74 | try {
|
75 |
| - const decoded = unpack(new Uint8Array(reply.data)); |
| 75 | + const decoded = decode(reply.data); |
76 | 76 | const value = JSONBigInt.stringify(decoded)
|
77 | 77 | return JSONViewer({ value, ...props })
|
78 | 78 | } catch (e) {
|
@@ -139,7 +139,7 @@ const bufferToSerializedFormat = (
|
139 | 139 | case KeyValueFormat.JSON: return reSerializeJSON(bufferToUTF8(value), space)
|
140 | 140 | case KeyValueFormat.Msgpack: {
|
141 | 141 | try {
|
142 |
| - const decoded = unpack(new Uint8Array(value.data) |
| 142 | + const decoded = decode(value.data) |
143 | 143 | const stringified = JSON.stringify(decoded)
|
144 | 144 | return reSerializeJSON(stringified, space)
|
145 | 145 | } catch (e) {
|
@@ -180,7 +180,7 @@ const stringToSerializedBufferFormat = (format: KeyValueFormat, value: string):
|
180 | 180 | case KeyValueFormat.Msgpack: {
|
181 | 181 | try {
|
182 | 182 | const json = JSON.parse(value)
|
183 |
| - const encoded = Uint8Array.from(pack(json)) |
| 183 | + const encoded = encode(json) |
184 | 184 | return anyToBuffer(encoded)
|
185 | 185 | } catch (e) {
|
186 | 186 | return stringToBuffer(value, format)
|
|
0 commit comments