Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/request / dist / deps / fromResponseToSerialized.js
Size: Mime:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fromHeadersToSerialized_1 = require("./fromHeadersToSerialized");
/**
 * @see https://github.com/bitinn/node-fetch/tree/master/src
 * @see https://github.com/apollographql/apollo-server/blob/master/packages/apollo-server-env/src/index.ts
 * @see https://github.com/apollographql/apollo-server/blob/master/packages/apollo-server-env/src/index.d.ts *
 */
function fromResponseToSerialized(response) {
    const temp = {};
    const clean = {};
    Object.getOwnPropertySymbols(response).forEach(symbol => {
        // String(symbol) !== 'Symbol(Body internals)'
        if (!response[symbol].body) {
            temp[String(symbol)] = response[symbol];
        }
    });
    // const combined = { ...temp, ...response, ...temp['Symbol(Body internals)'] }
    const asResponse = response;
    const asOneResponse = response;
    if (asResponse.type) {
        clean.type = asResponse.type;
    }
    if (asResponse.status) {
        clean.status = asResponse.status;
    }
    if (asResponse.statusText) {
        clean.statusText = asResponse.statusText;
    }
    if (asResponse.url) {
        clean.url = asResponse.url;
    }
    if (asResponse.headers) {
        clean.headers = fromHeadersToSerialized_1.fromHeadersToSerialized(asResponse.headers);
    }
    if (asOneResponse.data) {
        clean.data = asOneResponse.data;
    }
    if (asOneResponse.prettyError) {
        // not that helpful, is on clean already
    }
    return clean;
}
exports.fromResponseToSerialized = fromResponseToSerialized;
//# sourceMappingURL=fromResponseToSerialized.js.map