We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c66d264 commit 44db5ecCopy full SHA for 44db5ec
src/encode.ts
@@ -36,6 +36,7 @@ export type EncodeOptions<ContextType = undefined> = Partial<
36
ContextOf<ContextType>;
37
38
const defaultEncodeOptions: EncodeOptions = {};
39
+const defaultEncoder = new Encoder();
40
41
/**
42
* It encodes `value` in the MessagePack format and
@@ -47,7 +48,7 @@ export function encode<ContextType = undefined>(
47
48
value: unknown,
49
options: EncodeOptions<SplitUndefined<ContextType>> = defaultEncodeOptions as any,
50
): Uint8Array {
- const encoder = new Encoder(
51
+ const encoder = !options ? defaultEncoder : new Encoder(
52
options.extensionCodec,
53
(options as typeof options & { context: any }).context,
54
options.maxDepth,
0 commit comments