File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ export type DecodeOptions<ContextType = undefined> = Readonly<
3636 ContextOf < ContextType > ;
3737
3838export const defaultDecodeOptions : DecodeOptions = { } ;
39+ const defaultDecoder = new Decoder ( defaultDecodeOptions as any ) ;
3940
4041/**
4142 * It decodes a single MessagePack object in a buffer.
@@ -47,7 +48,7 @@ export function decode<ContextType = undefined>(
4748 buffer : ArrayLike < number > | BufferSource ,
4849 options : DecodeOptions < SplitUndefined < ContextType > > = defaultDecodeOptions as any ,
4950) : unknown {
50- const decoder = new Decoder (
51+ const decoder = options === defaultDecodeOptions ? defaultDecoder : new Decoder (
5152 options . extensionCodec ,
5253 ( options as typeof options & { context : any } ) . context ,
5354 options . maxStrLength ,
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ export type EncodeOptions<ContextType = undefined> = Partial<
3636 ContextOf < ContextType > ;
3737
3838const defaultEncodeOptions : EncodeOptions = { } ;
39+ const defaultEncoder = new Encoder ( defaultEncodeOptions as any ) ;
3940
4041/**
4142 * It encodes `value` in the MessagePack format and
@@ -47,7 +48,7 @@ export function encode<ContextType = undefined>(
4748 value : unknown ,
4849 options : EncodeOptions < SplitUndefined < ContextType > > = defaultEncodeOptions as any ,
4950) : Uint8Array {
50- const encoder = new Encoder (
51+ const encoder = options === defaultEncodeOptions ? defaultEncoder : new Encoder (
5152 options . extensionCodec ,
5253 ( options as typeof options & { context : any } ) . context ,
5354 options . maxDepth ,
You can’t perform that action at this time.
0 commit comments