return-data
Advanced tools
Comparing version 0.3.2 to 0.3.3
@@ -76,3 +76,3 @@ "use strict"; | ||
ReturnData.isNetWorkError = function (data) { | ||
return ((BaseReturn_1.default.getStatusIsFunction(data) && | ||
return ((ReturnData.getStatusIsFunction(data) && | ||
data.getStatus() === "NETWORK_ERROR") || | ||
@@ -141,3 +141,3 @@ (data === null || data === void 0 ? void 0 : data.status) === "NETWORK_ERROR"); | ||
ReturnData.isInterrupt = function (data) { | ||
return BaseReturn_1.default.getStatusValue(data) === "INTERRUPT"; | ||
return ReturnData.getStatusValue(data) === "INTERRUPT"; | ||
}; | ||
@@ -157,3 +157,3 @@ /** | ||
ReturnData.isCancel = function (data) { | ||
return BaseReturn_1.default.getStatusValue(data) === "CANCEL"; | ||
return ReturnData.getStatusValue(data) === "CANCEL"; | ||
}; | ||
@@ -173,4 +173,14 @@ /** | ||
ReturnData.isError = function (data) { | ||
return BaseReturn_1.default.getStatusValue(data) === "ERROR"; | ||
return ReturnData.getStatusValue(data) === "ERROR"; | ||
}; | ||
ReturnData.getStatusIsFunction = function (param) { | ||
return param && typeof param.getStatus === "function"; | ||
}; | ||
ReturnData.getStatusValue = function (obj) { | ||
var _a; | ||
if (ReturnData.getStatusIsFunction(obj)) { | ||
return obj.getStatus(); | ||
} | ||
return (_a = obj === null || obj === void 0 ? void 0 : obj.status) !== null && _a !== void 0 ? _a : ""; | ||
}; | ||
return ReturnData; | ||
@@ -177,0 +187,0 @@ }()); |
@@ -201,3 +201,3 @@ var BaseReturn = /** @class */ (function () { | ||
ReturnData.isNetWorkError = function (data) { | ||
return ((BaseReturn.getStatusIsFunction(data) && | ||
return ((ReturnData.getStatusIsFunction(data) && | ||
data.getStatus() === "NETWORK_ERROR") || | ||
@@ -266,3 +266,3 @@ (data === null || data === void 0 ? void 0 : data.status) === "NETWORK_ERROR"); | ||
ReturnData.isInterrupt = function (data) { | ||
return BaseReturn.getStatusValue(data) === "INTERRUPT"; | ||
return ReturnData.getStatusValue(data) === "INTERRUPT"; | ||
}; | ||
@@ -282,3 +282,3 @@ /** | ||
ReturnData.isCancel = function (data) { | ||
return BaseReturn.getStatusValue(data) === "CANCEL"; | ||
return ReturnData.getStatusValue(data) === "CANCEL"; | ||
}; | ||
@@ -298,4 +298,14 @@ /** | ||
ReturnData.isError = function (data) { | ||
return BaseReturn.getStatusValue(data) === "ERROR"; | ||
return ReturnData.getStatusValue(data) === "ERROR"; | ||
}; | ||
ReturnData.getStatusIsFunction = function (param) { | ||
return param && typeof param.getStatus === "function"; | ||
}; | ||
ReturnData.getStatusValue = function (obj) { | ||
var _a; | ||
if (ReturnData.getStatusIsFunction(obj)) { | ||
return obj.getStatus(); | ||
} | ||
return (_a = obj === null || obj === void 0 ? void 0 : obj.status) !== null && _a !== void 0 ? _a : ""; | ||
}; | ||
return ReturnData; | ||
@@ -302,0 +312,0 @@ }()); |
@@ -1,1 +0,1 @@ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).ReturnData={})}(this,(function(t){"use strict";var n=function(){function t(t,n,e){void 0===t&&(t=""),void 0===n&&(n=null),void 0===e&&(e=""),this.status="",this.msg="",this.data=null,this.extraData=null,this.status=t,this.msg=e,this.data=n}return t.prototype.setStatus=function(t){this.status=t},t.prototype.setMsg=function(t){this.msg=t},t.prototype.setData=function(t){this.data=t},t.prototype.getStatus=function(){return this.status},t.prototype.getData=function(){return this.data},t.prototype.getMsg=function(){return this.msg},t.prototype.getExtraData=function(){return this.extraData},t.prototype.setExtraData=function(t){this.extraData=t},t.getStatusIsFunction=function(t){return t&&"function"==typeof t.getStatus},t.getStatusValue=function(n){return t.getStatusIsFunction(n)?n.getStatus():""},t.isOk=function(n){return t.getStatusIsFunction(n)&&"ok"===n.getStatus()},t.isFail=function(n){return t.getStatusIsFunction(n)&&"fail"===n.getStatus()},t.isDeny=function(n){return t.getStatusIsFunction(n)&&"deny"===n.getStatus()},t.isNetWorkError=function(n){return t.getStatusIsFunction(n)&&"NETWORK_ERROR"===n.getStatus()||"NETWORK_ERROR"===(null==n?void 0:n.status)},t.hasData=function(t){if(!t||"function"!=typeof t.getData)return!1;var n=t.getData();return!(null==n)},t.cancel=function(t){return new this("CANCEL",null,t||"网络异常,请重试")},t.isCancel=function(n){return"CANCEL"===t.getStatusValue(n)},t.interrupt=function(t){return new this("INTERRUPT",null,t||"程序中断,请重试")},t.isInterrupt=function(n){return"INTERRUPT"===t.getStatusValue(n)},t.error=function(t){return new this("ERROR",null,t||"程序中断,请重试")},t.isError=function(n){return"ERROR"===t.getStatusValue(n)},t}(),e=function(){function t(t,n,e){void 0===n&&(n=null),void 0===e&&(e="success"),this.msg="",this.extraData=null,this.status=t,this.data=n,this.msg=e}return t.prototype.getStatus=function(){return this.status},t.prototype.getData=function(){return this.data},t.prototype.getMsg=function(){return this.msg},t.prototype.setMsg=function(t){this.msg=t},t.prototype.getExtraData=function(){return this.extraData},t.prototype.setExtraData=function(t){this.extraData=t},t.isOk=function(t){return u(t)&&"ok"===t.getStatus()},t.isFail=function(t){return u(t)&&"fail"===t.getStatus()},t.isDeny=function(t){return u(t)&&"deny"===t.getStatus()},t.hasData=function(t){if(!t||"function"!=typeof t.getData)return!1;var n=t.getData();return!(null==n)},t.isNetWorkError=function(t){return n.getStatusIsFunction(t)&&"NETWORK_ERROR"===t.getStatus()||"NETWORK_ERROR"===(null==t?void 0:t.status)},t.cover=function(n,e){t[n]=e},t.success=function(n){return new t("ok",n)},t.fail=function(n){var e=new t("fail",null);return e.setMsg(n||""),e},t.exception=function(n){return new t(n.getStatus(),n.getData(),n.getMsg())},t.deny=function(n){return new t("deny",null,n||"")},t.networkError=function(n){return new t("NETWORK_ERROR",null,n||"网络异常,请重试")},t.interrupt=function(n){return new t("INTERRUPT",null,n||"程序中断,请重试")},t.isInterrupt=function(t){return"INTERRUPT"===n.getStatusValue(t)},t.cancel=function(n){return new t("CANCEL",null,n||"网络异常,请重试")},t.isCancel=function(t){return"CANCEL"===n.getStatusValue(t)},t.error=function(t){return new this("ERROR",null,t||"程序中断,请重试")},t.isError=function(t){return"ERROR"===n.getStatusValue(t)},t}();function u(t){return t&&"function"==typeof t.getStatus}t.BaseReturn=n,t.default=e,Object.defineProperty(t,"__esModule",{value:!0})}));//# sourceMappingURL=return-data.min.js.map | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).ReturnData={})}(this,(function(t){"use strict";var n=function(){function t(t,n,u){void 0===t&&(t=""),void 0===n&&(n=null),void 0===u&&(u=""),this.status="",this.msg="",this.data=null,this.extraData=null,this.status=t,this.msg=u,this.data=n}return t.prototype.setStatus=function(t){this.status=t},t.prototype.setMsg=function(t){this.msg=t},t.prototype.setData=function(t){this.data=t},t.prototype.getStatus=function(){return this.status},t.prototype.getData=function(){return this.data},t.prototype.getMsg=function(){return this.msg},t.prototype.getExtraData=function(){return this.extraData},t.prototype.setExtraData=function(t){this.extraData=t},t.getStatusIsFunction=function(t){return t&&"function"==typeof t.getStatus},t.getStatusValue=function(n){return t.getStatusIsFunction(n)?n.getStatus():""},t.isOk=function(n){return t.getStatusIsFunction(n)&&"ok"===n.getStatus()},t.isFail=function(n){return t.getStatusIsFunction(n)&&"fail"===n.getStatus()},t.isDeny=function(n){return t.getStatusIsFunction(n)&&"deny"===n.getStatus()},t.isNetWorkError=function(n){return t.getStatusIsFunction(n)&&"NETWORK_ERROR"===n.getStatus()||"NETWORK_ERROR"===(null==n?void 0:n.status)},t.hasData=function(t){if(!t||"function"!=typeof t.getData)return!1;var n=t.getData();return!(null==n)},t.cancel=function(t){return new this("CANCEL",null,t||"网络异常,请重试")},t.isCancel=function(n){return"CANCEL"===t.getStatusValue(n)},t.interrupt=function(t){return new this("INTERRUPT",null,t||"程序中断,请重试")},t.isInterrupt=function(n){return"INTERRUPT"===t.getStatusValue(n)},t.error=function(t){return new this("ERROR",null,t||"程序中断,请重试")},t.isError=function(n){return"ERROR"===t.getStatusValue(n)},t}(),u=function(){function t(t,n,u){void 0===n&&(n=null),void 0===u&&(u="success"),this.msg="",this.extraData=null,this.status=t,this.data=n,this.msg=u}return t.prototype.getStatus=function(){return this.status},t.prototype.getData=function(){return this.data},t.prototype.getMsg=function(){return this.msg},t.prototype.setMsg=function(t){this.msg=t},t.prototype.getExtraData=function(){return this.extraData},t.prototype.setExtraData=function(t){this.extraData=t},t.isOk=function(t){return e(t)&&"ok"===t.getStatus()},t.isFail=function(t){return e(t)&&"fail"===t.getStatus()},t.isDeny=function(t){return e(t)&&"deny"===t.getStatus()},t.hasData=function(t){if(!t||"function"!=typeof t.getData)return!1;var n=t.getData();return!(null==n)},t.isNetWorkError=function(n){return t.getStatusIsFunction(n)&&"NETWORK_ERROR"===n.getStatus()||"NETWORK_ERROR"===(null==n?void 0:n.status)},t.cover=function(n,u){t[n]=u},t.success=function(n){return new t("ok",n)},t.fail=function(n){var u=new t("fail",null);return u.setMsg(n||""),u},t.exception=function(n){return new t(n.getStatus(),n.getData(),n.getMsg())},t.deny=function(n){return new t("deny",null,n||"")},t.networkError=function(n){return new t("NETWORK_ERROR",null,n||"网络异常,请重试")},t.interrupt=function(n){return new t("INTERRUPT",null,n||"程序中断,请重试")},t.isInterrupt=function(n){return"INTERRUPT"===t.getStatusValue(n)},t.cancel=function(n){return new t("CANCEL",null,n||"网络异常,请重试")},t.isCancel=function(n){return"CANCEL"===t.getStatusValue(n)},t.error=function(t){return new this("ERROR",null,t||"程序中断,请重试")},t.isError=function(n){return"ERROR"===t.getStatusValue(n)},t.getStatusIsFunction=function(t){return t&&"function"==typeof t.getStatus},t.getStatusValue=function(n){var u;return t.getStatusIsFunction(n)?n.getStatus():null!==(u=null==n?void 0:n.status)&&void 0!==u?u:""},t}();function e(t){return t&&"function"==typeof t.getStatus}t.BaseReturn=n,t.default=u,Object.defineProperty(t,"__esModule",{value:!0})}));//# sourceMappingURL=return-data.min.js.map |
{ | ||
"name": "return-data", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "数据返回格式", | ||
@@ -5,0 +5,0 @@ "author": "yiri.zhou", |
@@ -111,2 +111,4 @@ import BaseReturn, { IReturnData } from "./BaseReturn"; | ||
static isError(data: any): boolean; | ||
static getStatusIsFunction(param: any): any; | ||
static getStatusValue(obj: any): any; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72698
1052