Swap-Aggregator-Subgraph/node_modules/then-request/lib/ResponsePromise.js
Richa-iitr d211083153 Revert "Revert "added handler""
This reverts commit c36ee8c5ca.
2022-07-03 07:30:05 +05:30

28 lines
692 B
JavaScript

"use strict";
exports.__esModule = true;
var Promise = require("promise");
function getBody(encoding) {
if (!encoding) {
return this.then(getBodyBinary);
}
if (encoding === 'utf8') {
return this.then(getBodyUTF8);
}
return this.then(getBodyWithEncoding(encoding));
}
function getBodyWithEncoding(encoding) {
return function (res) { return res.getBody(encoding); };
}
function getBodyBinary(res) {
return res.getBody();
}
function getBodyUTF8(res) {
return res.getBody('utf8');
}
function toResponsePromise(result) {
result.getBody = getBody;
return result;
}
exports["default"] = toResponsePromise;
exports.ResponsePromise = undefined;