import { ExtensionCodecType } from "./ExtensionCodec.ts";import { Decoder } from "./Decoder.ts";import { ContextOf, SplitUndefined } from "./context.ts";
export type DecodeOptions<ContextType = undefined> = & Readonly< Partial<{ extensionCodec: ExtensionCodecType<ContextType>;
maxStrLength: number; maxBinLength: number; maxArrayLength: number; maxMapLength: number; maxExtLength: number; }> > & ContextOf<ContextType>;
export const defaultDecodeOptions: DecodeOptions = {};
export function decode<ContextType>( buffer: ArrayLike<number> | ArrayBuffer, options: DecodeOptions<SplitUndefined<ContextType>> = defaultDecodeOptions as any,): unknown { const decoder = new Decoder<ContextType>( options.extensionCodec, (options as typeof options & { context: any }).context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength, ); return decoder.decode(buffer);}