Files
relay/node_modules/@msgpack/msgpack/dist.es5+esm/decode.mjs
Luke Hagar 98eb98b91a saving
2024-10-21 18:46:35 +00:00

29 lines
1.5 KiB
JavaScript

import { Decoder } from "./Decoder.mjs";
export var defaultDecodeOptions = {};
/**
* It decodes a single MessagePack object in a buffer.
*
* This is a synchronous decoding function.
* See other variants for asynchronous decoding: {@link decodeAsync()}, {@link decodeStream()}, or {@link decodeArrayStream()}.
*
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
* @throws {@link DecodeError} if the buffer contains invalid data.
*/
export function decode(buffer, options) {
if (options === void 0) { options = defaultDecodeOptions; }
var decoder = new Decoder(options.extensionCodec, options.context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength);
return decoder.decode(buffer);
}
/**
* It decodes multiple MessagePack objects in a buffer.
* This is corresponding to {@link decodeMultiStream()}.
*
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
* @throws {@link DecodeError} if the buffer contains invalid data.
*/
export function decodeMulti(buffer, options) {
if (options === void 0) { options = defaultDecodeOptions; }
var decoder = new Decoder(options.extensionCodec, options.context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength);
return decoder.decodeMulti(buffer);
}
//# sourceMappingURL=decode.mjs.map