Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

return-data

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

return-data - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

15

dist/BaseReturn.js

@@ -84,2 +84,17 @@ "use strict";

};
/**
* 取消返回类
* @returns ReturnData
*/
BaseReturn.cancel = function (msg) {
return new this("CANCEL", null, msg || "网络异常,请重试");
};
/**
* 是否是取消返回
* @param data
* @returns
*/
BaseReturn.isCancel = function (data) {
return BaseReturn.getStatusValue(data) === "CANCEL";
};
return BaseReturn;

@@ -86,0 +101,0 @@ }());

@@ -118,2 +118,17 @@ "use strict";

};
/**
* 取消返回类
* @returns ReturnData
*/
ReturnData.cancel = function (msg) {
return new ReturnData("CANCEL", null, msg || "网络异常,请重试");
};
/**
* 是否是取消返回
* @param data
* @returns
*/
ReturnData.isCancel = function (data) {
return BaseReturn_1.default.getStatusValue(data) === "CANCEL";
};
return ReturnData;

@@ -120,0 +135,0 @@ }());

@@ -82,2 +82,17 @@ var BaseReturn = /** @class */ (function () {

};
/**
* 取消返回类
* @returns ReturnData
*/
BaseReturn.cancel = function (msg) {
return new this("CANCEL", null, msg || "网络异常,请重试");
};
/**
* 是否是取消返回
* @param data
* @returns
*/
BaseReturn.isCancel = function (data) {
return BaseReturn.getStatusValue(data) === "CANCEL";
};
return BaseReturn;

@@ -198,2 +213,17 @@ }());

};
/**
* 取消返回类
* @returns ReturnData
*/
ReturnData.cancel = function (msg) {
return new ReturnData("CANCEL", null, msg || "网络异常,请重试");
};
/**
* 是否是取消返回
* @param data
* @returns
*/
ReturnData.isCancel = function (data) {
return BaseReturn.getStatusValue(data) === "CANCEL";
};
return ReturnData;

@@ -200,0 +230,0 @@ }());

2

dist/return-data.min.js

@@ -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()},t.hasData=function(t){if(!t||"function"!=typeof t.getData)return!1;var n=t.getData();return!(null==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()},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}();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,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()},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}(),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()},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.cancel=function(n){return new t("CANCEL",null,n||"网络异常,请重试")},t.isCancel=function(t){return"CANCEL"===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
{
"name": "return-data",
"version": "0.1.1",
"version": "0.1.2",
"description": "数据返回格式",

@@ -17,3 +17,3 @@ "author": "yiri.zhou",

"commit": "git-cz --disable-emoji",
"prepare": "npm run husky",
"prepare": "rimraf .husky && npm run husky",
"husky": "husky uninstall && husky install && npm run commit-msg && npm run pre-push",

@@ -20,0 +20,0 @@ "commit-msg": "husky add .husky/commit-msg 'npx --no-install commitlint --edit $1'",

@@ -50,2 +50,13 @@ export interface IReturnData<T = any> {

static hasData(param: any): boolean;
/**
* 取消返回类
* @returns ReturnData
*/
static cancel(msg?: string): BaseReturn<null>;
/**
* 是否是取消返回
* @param data
* @returns
*/
static isCancel(data: any): boolean;
}

@@ -72,2 +72,13 @@ import BaseReturn, { IReturnData } from "./BaseReturn";

static networkError(msg?: string): ReturnData<null>;
/**
* 取消返回类
* @returns ReturnData
*/
static cancel(msg?: string): ReturnData<null>;
/**
* 是否是取消返回
* @param data
* @returns
*/
static isCancel(data: any): boolean;
}

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc