File tree 2 files changed +4
-2
lines changed
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<
36
36
ContextOf < ContextType > ;
37
37
38
38
export const defaultDecodeOptions : DecodeOptions = { } ;
39
+ const defaultDecoder = new Decoder ( defaultDecodeOptions as any ) ;
39
40
40
41
/**
41
42
* It decodes a single MessagePack object in a buffer.
@@ -47,7 +48,7 @@ export function decode<ContextType = undefined>(
47
48
buffer : ArrayLike < number > | BufferSource ,
48
49
options : DecodeOptions < SplitUndefined < ContextType > > = defaultDecodeOptions as any ,
49
50
) : unknown {
50
- const decoder = new Decoder (
51
+ const decoder = options === defaultDecodeOptions ? defaultDecoder : new Decoder (
51
52
options . extensionCodec ,
52
53
( options as typeof options & { context : any } ) . context ,
53
54
options . maxStrLength ,
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ export type EncodeOptions<ContextType = undefined> = Partial<
36
36
ContextOf < ContextType > ;
37
37
38
38
const defaultEncodeOptions : EncodeOptions = { } ;
39
+ const defaultEncoder = new Encoder ( defaultEncodeOptions as any ) ;
39
40
40
41
/**
41
42
* It encodes `value` in the MessagePack format and
@@ -47,7 +48,7 @@ export function encode<ContextType = undefined>(
47
48
value : unknown ,
48
49
options : EncodeOptions < SplitUndefined < ContextType > > = defaultEncodeOptions as any ,
49
50
) : Uint8Array {
50
- const encoder = new Encoder (
51
+ const encoder = options === defaultEncodeOptions ? defaultEncoder : new Encoder (
51
52
options . extensionCodec ,
52
53
( options as typeof options & { context : any } ) . context ,
53
54
options . maxDepth ,
You can’t perform that action at this time.
0 commit comments