You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to our benchmark, reusing `Encoder` instance is about 2% faster
232
+
than `encode()` function, and reusing `Decoder` instance is about 35% faster
233
+
than `decode()` function. Note that the result should vary in environments
234
+
and data structure.
235
+
236
+
## Extension Types
216
237
217
238
To handle [MessagePack Extension Types](https://github.com/msgpack/msgpack/blob/master/spec.md#extension-types), this library provides `ExtensionCodec` class.
Not that extension types for custom objects must be `[0, 127]`, while `[-1, -128]` is reserved for MessagePack itself.
268
289
269
-
#### Codec context
290
+
#### ExtensionCodec context
270
291
271
292
When using an extension codec, it may be necessary to keep encoding/decoding state, to keep track of which objects got encoded/re-created. To do this, pass a `context` to the `EncodeOptions` and `DecodeOptions` (and if using typescript, type the `ExtensionCodec` too). Don't forget to pass the `{extensionCodec, context}` along recursive encoding/decoding:
0 commit comments