@argab/request-service
Advanced tools
Comparing version 3.1.5 to 3.1.6
@@ -197,2 +197,8 @@ "use strict"; | ||
return request[method] instanceof Function && (request._fetch[method] = function (arg) { | ||
if (_Request.REQUEST_RESOLVE_METHODS.includes(method)) { | ||
arg instanceof Function || (arg = function arg() { | ||
return undefined; | ||
}); | ||
} else request[method](arg); | ||
_this3._resolve.push({ | ||
@@ -207,3 +213,2 @@ method: method, | ||
}); | ||
_Request.REQUEST_RESOLVE_METHODS.includes(method) || request[method](arg); | ||
return request._fetch; | ||
@@ -267,21 +272,28 @@ }); | ||
_context4.prev = 2; | ||
_context4.next = 5; | ||
_context4.t0 = source[0].arg instanceof Function; | ||
if (!_context4.t0) { | ||
_context4.next = 7; | ||
break; | ||
} | ||
_context4.next = 7; | ||
return _this4.setResult(source[0].arg(data)); | ||
case 5: | ||
_context4.next = 11; | ||
case 7: | ||
_context4.next = 13; | ||
break; | ||
case 7: | ||
_context4.prev = 7; | ||
_context4.t0 = _context4["catch"](2); | ||
_context4.next = 11; | ||
return _this4.handleError(_context4.t0, handlers); | ||
case 9: | ||
_context4.prev = 9; | ||
_context4.t1 = _context4["catch"](2); | ||
_context4.next = 13; | ||
return _this4.handleError(_context4.t1, handlers); | ||
case 11: | ||
case 13: | ||
source.shift(); | ||
_context4.next = 14; | ||
_context4.next = 16; | ||
return fetch(_this4._request.data.result); | ||
case 14: | ||
case 16: | ||
case "end": | ||
@@ -291,3 +303,3 @@ return _context4.stop(); | ||
} | ||
}, _callee4, null, [[2, 7]]); | ||
}, _callee4, null, [[2, 9]]); | ||
})); | ||
@@ -364,27 +376,34 @@ | ||
_context6.next = 6; | ||
_context6.t0 = onCatch[0].arg instanceof Function; | ||
if (!_context6.t0) { | ||
_context6.next = 8; | ||
break; | ||
} | ||
_context6.next = 8; | ||
return _this5.setResult(onCatch[0].arg(error)); | ||
case 6: | ||
_context6.next = 14; | ||
case 8: | ||
_context6.next = 16; | ||
break; | ||
case 8: | ||
_context6.prev = 8; | ||
_context6.t0 = _context6["catch"](2); | ||
case 10: | ||
_context6.prev = 10; | ||
_context6.t1 = _context6["catch"](2); | ||
_this5.setError(_context6.t0); | ||
_this5.setError(_context6.t1); | ||
_context6.next = 13; | ||
return _this5.setResult(_this5.resolveHandlers(_context6.t0, handlers, 'onCatch')); | ||
_context6.next = 15; | ||
return _this5.setResult(_this5.resolveHandlers(_context6.t1, handlers, 'onCatch')); | ||
case 13: | ||
error = _context6.t0; | ||
case 15: | ||
error = _context6.t1; | ||
case 14: | ||
case 16: | ||
onCatch.shift(); | ||
_context6.next = 17; | ||
_context6.next = 19; | ||
return fetch(error); | ||
case 17: | ||
case 19: | ||
case "end": | ||
@@ -394,3 +413,3 @@ return _context6.stop(); | ||
} | ||
}, _callee6, null, [[2, 8]]); | ||
}, _callee6, null, [[2, 10]]); | ||
})); | ||
@@ -397,0 +416,0 @@ |
{ | ||
"name": "@argab/request-service", | ||
"version": "3.1.5", | ||
"version": "3.1.6", | ||
"description": "Provides a fully customizable Library for handling API using Request repositories and Stubs.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -87,5 +87,10 @@ import {RequestService, Request} from "./Request" | ||
request._methods.forEach(method => request[method] instanceof Function && (request._fetch[method] = (arg) => { | ||
if (REQUEST_RESOLVE_METHODS.includes(method)) { | ||
arg instanceof Function || (arg = () => undefined) | ||
} else request[method](arg) | ||
this._resolve.push({method, arg}) | ||
request.chain.push({method, args: [arg]}) | ||
REQUEST_RESOLVE_METHODS.includes(method) || request[method](arg) | ||
return request._fetch | ||
@@ -119,3 +124,3 @@ })) | ||
try { | ||
await this.setResult(source[0].arg(data)) | ||
source[0].arg instanceof Function && await this.setResult(source[0].arg(data)) | ||
} catch (err) { | ||
@@ -148,3 +153,3 @@ await this.handleError(err, handlers) | ||
this.setError(error) | ||
await this.setResult(onCatch[0].arg(error)) | ||
onCatch[0].arg instanceof Function && await this.setResult(onCatch[0].arg(error)) | ||
} catch (err) { | ||
@@ -151,0 +156,0 @@ this.setError(err) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
118789
2679