1 | "use strict";
|
2 | exports.__esModule = true;
|
3 | var Promise = require("promise");
|
4 | function 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 | }
|
13 | function getBodyWithEncoding(encoding) {
|
14 | return function (res) { return res.getBody(encoding); };
|
15 | }
|
16 | function getBodyBinary(res) {
|
17 | return res.getBody();
|
18 | }
|
19 | function getBodyUTF8(res) {
|
20 | return res.getBody('utf8');
|
21 | }
|
22 | function toResponsePromise(result) {
|
23 | result.getBody = getBody;
|
24 | return result;
|
25 | }
|
26 | exports["default"] = toResponsePromise;
|
27 | exports.ResponsePromise = undefined;
|