@@ -38,9 +38,10 @@ export type DecodeOptions<ContextType = undefined> = Readonly<
3838export const defaultDecodeOptions : DecodeOptions = { } ;
3939
4040/**
41- * It decodes a MessagePack-encoded buffer.
41+ * It decodes a single MessagePack object in a buffer.
4242 *
43- * This is a synchronous decoding function. See other variants for asynchronous decoding: `decodeAsync()`, `decodeStream()`, `decodeArrayStream()`.
43+ * This is a synchronous decoding function.
44+ * See other variants for asynchronous decoding: {@link decodeAsync()}, {@link decodeStream()}, or {@link decodeArrayStream()}.
4445 */
4546export function decode < ContextType = undefined > (
4647 buffer : ArrayLike < number > | BufferSource ,
@@ -57,3 +58,23 @@ export function decode<ContextType = undefined>(
5758 ) ;
5859 return decoder . decode ( buffer ) ;
5960}
61+
62+ /**
63+ * It decodes multiple MessagePack objects in a buffer.
64+ * This is corresponding to {@link decodeMultiStream()}.
65+ */
66+ export function decodeMulti < ContextType = undefined > (
67+ buffer : ArrayLike < number > | BufferSource ,
68+ options : DecodeOptions < SplitUndefined < ContextType > > = defaultDecodeOptions as any ,
69+ ) : Generator < unknown , void , unknown > {
70+ const decoder = new Decoder (
71+ options . extensionCodec ,
72+ ( options as typeof options & { context : any } ) . context ,
73+ options . maxStrLength ,
74+ options . maxBinLength ,
75+ options . maxArrayLength ,
76+ options . maxMapLength ,
77+ options . maxExtLength ,
78+ ) ;
79+ return decoder . decodeMulti ( buffer ) ;
80+ }
0 commit comments