UNPKG

kakapo

Version:

Next generation mocking framework in Javascript

39 lines (38 loc) 1.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var KakapoResponse = (function () { function KakapoResponse(code, body, headers) { if (code === void 0) { code = 200; } if (body === void 0) { body = {}; } if (headers === void 0) { headers = {}; } this.code = code; this.body = body; this.headers = headers; } Object.defineProperty(KakapoResponse.prototype, "error", { get: function () { return this.code >= 400; }, enumerable: true, configurable: true }); Object.defineProperty(KakapoResponse.prototype, "ok", { get: function () { return this.code >= 200 && this.code <= 299; }, enumerable: true, configurable: true }); KakapoResponse.wrap = function (response) { if (response instanceof KakapoResponse) { return response; } else { return new KakapoResponse(200, response, { "content-type": "application/json; charset=utf-8" }); } }; return KakapoResponse; }()); exports.KakapoResponse = KakapoResponse;