"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrapReadableStream = wrapReadableStream;
const _1 = require("../Class/$");
const LockedReadableStreamError_1 = require("../exception/LockedReadableStreamError");
function wrapReadableStream(readableStream_, system) {
    const readableStream = new (class ReadableStream_ extends _1.$ {
        constructor() {
            super(...arguments);
            this.__ = ['RS'];
        }
        async json() {
            if (readableStream_.locked) {
                throw new LockedReadableStreamError_1.LockedReadableStreamError();
            }
            return new Response(readableStream_).json();
        }
        async text() {
            if (readableStream_.locked) {
                throw new LockedReadableStreamError_1.LockedReadableStreamError();
            }
            return new Response(readableStream_).text();
        }
        async blob() {
            if (readableStream_.locked) {
                throw new LockedReadableStreamError_1.LockedReadableStreamError();
            }
            return new Response(readableStream_).blob();
        }
        async raw() {
            return readableStream_;
        }
        async arrayBuffer() {
            if (readableStream_.locked) {
                throw new LockedReadableStreamError_1.LockedReadableStreamError();
            }
            return new Response(readableStream_).arrayBuffer();
        }
    })(system);
    return readableStream;
}
//# sourceMappingURL=ReadableStream.js.map