%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/share/nodejs/got/dist/as-promise/
Upload File :
Create Path :
Current File : //usr/share/nodejs/got/dist/as-promise/parse-body.js

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const types_1 = require("./types");
const parseBody = (response, responseType, parseJson, encoding) => {
    const { rawBody } = response;
    try {
        if (responseType === 'text') {
            return rawBody.toString(encoding);
        }
        if (responseType === 'json') {
            return rawBody.length === 0 ? '' : parseJson(rawBody.toString());
        }
        if (responseType === 'buffer') {
            return rawBody;
        }
        throw new types_1.ParseError({
            message: `Unknown body type '${responseType}'`,
            name: 'Error'
        }, response);
    }
    catch (error) {
        // @ts-ignore
        throw new types_1.ParseError(error, response);
    }
};
exports.default = parseBody;

Zerion Mini Shell 1.0