UNPKG

692 BJavaScriptView Raw
1"use strict";
2exports.__esModule = true;
3var Promise = require("promise");
4function getBody(encoding) {
5 if (!encoding) {
6 return this.then(getBodyBinary);
7 }
8 if (encoding === 'utf8') {
9 return this.then(getBodyUTF8);
10 }
11 return this.then(getBodyWithEncoding(encoding));
12}
13function getBodyWithEncoding(encoding) {
14 return function (res) { return res.getBody(encoding); };
15}
16function getBodyBinary(res) {
17 return res.getBody();
18}
19function getBodyUTF8(res) {
20 return res.getBody('utf8');
21}
22function toResponsePromise(result) {
23 result.getBody = getBody;
24 return result;
25}
26exports["default"] = toResponsePromise;
27exports.ResponsePromise = undefined;