Files
relay/node_modules/@msgpack/msgpack/dist/decodeAsync.js
Luke Hagar 98eb98b91a saving
2024-10-21 18:46:35 +00:00

44 lines
2.4 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.decodeStream = exports.decodeMultiStream = exports.decodeArrayStream = exports.decodeAsync = void 0;
const Decoder_1 = require("./Decoder");
const stream_1 = require("./utils/stream");
const decode_1 = require("./decode");
/**
* @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.
*/
async function decodeAsync(streamLike, options = decode_1.defaultDecodeOptions) {
const stream = (0, stream_1.ensureAsyncIterable)(streamLike);
const decoder = new Decoder_1.Decoder(options.extensionCodec, options.context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength);
return decoder.decodeAsync(stream);
}
exports.decodeAsync = decodeAsync;
/**
* @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.
*/
function decodeArrayStream(streamLike, options = decode_1.defaultDecodeOptions) {
const stream = (0, stream_1.ensureAsyncIterable)(streamLike);
const decoder = new Decoder_1.Decoder(options.extensionCodec, options.context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength);
return decoder.decodeArrayStream(stream);
}
exports.decodeArrayStream = 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.
*/
function decodeMultiStream(streamLike, options = decode_1.defaultDecodeOptions) {
const stream = (0, stream_1.ensureAsyncIterable)(streamLike);
const decoder = new Decoder_1.Decoder(options.extensionCodec, options.context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength);
return decoder.decodeStream(stream);
}
exports.decodeMultiStream = decodeMultiStream;
/**
* @deprecated Use {@link decodeMultiStream()} instead.
*/
function decodeStream(streamLike, options = decode_1.defaultDecodeOptions) {
return decodeMultiStream(streamLike, options);
}
exports.decodeStream = decodeStream;
//# sourceMappingURL=decodeAsync.js.map