| Total Complexity | 4 |
| Complexity/F | 2 |
| Lines of Code | 28 |
| Function Count | 2 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | "use strict"; |
||
| 2 | |||
| 3 | const Response = require('../../model/Response'); |
||
| 4 | |||
| 5 | /** |
||
| 6 | * @param {Response} response |
||
| 7 | * |
||
| 8 | * @returns {Object} |
||
| 9 | */ |
||
| 10 | module.exports = response => { |
||
| 11 | const format = object => { |
||
| 12 | if (object instanceof Response) { |
||
| 13 | return { |
||
| 14 | body: object.getBody(), |
||
| 15 | statusCode: object.getStatusCode(), |
||
| 16 | headers: object.getHeaders() |
||
| 17 | }; |
||
| 18 | } |
||
| 19 | |||
| 20 | return object; |
||
| 21 | }; |
||
| 22 | |||
| 23 | if (Array.isArray(response)) { |
||
| 24 | return response.map(format); |
||
| 25 | } |
||
| 26 | |||
| 27 | return format(response); |
||
| 28 | }; |
||
| 29 |