commonly-decorators
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -214,4 +214,252 @@ import freezeClick from 'freeze-click'; | ||
/* | ||
* @Author: youzhao.zhou | ||
* @Date: 2021-08-19 16:51:33 | ||
* @Last Modified by: youzhao.zhou | ||
* @Last Modified time: 2021-09-08 21:01:35 | ||
* @Description 统一返回格式 | ||
*/ | ||
/** | ||
* 统一返回格式 | ||
*/ | ||
var ReturnData = /** @class */ (function () { | ||
function ReturnData(status, data, msg) { | ||
if (data === void 0) { data = null; } | ||
if (msg === void 0) { msg = "success"; } | ||
this.msg = ""; | ||
this.extraData = null; | ||
this.status = status; | ||
this.data = data; | ||
this.msg = msg; | ||
} | ||
ReturnData.prototype.getStatus = function () { | ||
return this.status; | ||
}; | ||
ReturnData.prototype.getData = function () { | ||
return this.data; | ||
}; | ||
ReturnData.prototype.getMsg = function () { | ||
return this.msg; | ||
}; | ||
ReturnData.prototype.setMsg = function (msg) { | ||
this.msg = msg; | ||
}; | ||
ReturnData.prototype.getExtraData = function () { | ||
return this.extraData; | ||
}; | ||
ReturnData.prototype.setExtraData = function (data) { | ||
this.extraData = data; | ||
}; | ||
/** | ||
* 判断是否成功 | ||
* @param {any} data | ||
* @returns boolean | ||
*/ | ||
ReturnData.isOk = function (data) { | ||
return getStatusIsFunction(data) && data.getStatus() === "ok"; | ||
}; | ||
ReturnData.isFail = function (data) { | ||
return getStatusIsFunction(data) && data.getStatus() === "fail"; | ||
}; | ||
ReturnData.isDeny = function (data) { | ||
return getStatusIsFunction(data) && data.getStatus() === "deny"; | ||
}; | ||
/** | ||
* 判断data是不是null或者undefined | ||
* @param param | ||
* @returns | ||
*/ | ||
ReturnData.hasData = function (param) { | ||
if (!param || typeof param.getData !== "function") { | ||
return false; | ||
} | ||
var data = param.getData(); | ||
return !(typeof data === "undefined" || data === null); | ||
}; | ||
/** | ||
* 是否是网络错误 | ||
* @param data | ||
* @returns | ||
*/ | ||
ReturnData.isNetWorkError = function (data) { | ||
return ((ReturnData.getStatusIsFunction(data) && | ||
data.getStatus() === "NETWORK_ERROR") || | ||
(data === null || data === void 0 ? void 0 : data.status) === "NETWORK_ERROR"); | ||
}; | ||
/** | ||
* 覆盖原有的逻辑 | ||
* @param data | ||
* @returns | ||
*/ | ||
ReturnData.cover = function (keyName, value) { | ||
ReturnData[keyName] = value; | ||
}; | ||
/** | ||
* 返回成功 | ||
* @param data | ||
* @returns ReturnData | ||
*/ | ||
ReturnData.success = function (data) { | ||
return new ReturnData("ok", data); | ||
}; | ||
/** | ||
* 返回失败 | ||
* @returns ReturnData | ||
*/ | ||
ReturnData.fail = function (msg) { | ||
var data = new ReturnData("fail", null); | ||
data.setMsg(msg || ""); | ||
return data; | ||
}; | ||
/** | ||
* 统一异常处理 | ||
* @param {IReturnData} ex | ||
* @returns | ||
*/ | ||
ReturnData.exception = function (ex) { | ||
return new ReturnData(ex.getStatus(), ex.getData(), ex.getMsg()); | ||
}; | ||
/** | ||
* 返回拒绝 | ||
* @returns ReturnData | ||
*/ | ||
ReturnData.deny = function (msg) { | ||
return new ReturnData("deny", null, msg || ""); | ||
}; | ||
/** | ||
* 网络异常返回类 | ||
* @returns ReturnData | ||
*/ | ||
ReturnData.networkError = function (msg) { | ||
return new ReturnData("NETWORK_ERROR", null, msg || "网络异常,请重试"); | ||
}; | ||
/** | ||
* 中断类 | ||
* @returns ReturnData | ||
*/ | ||
ReturnData.interrupt = function (msg) { | ||
return new ReturnData("INTERRUPT", null, msg || "程序中断,请重试"); | ||
}; | ||
/** | ||
* 是否是中断返回 | ||
* @param data | ||
* @returns | ||
*/ | ||
ReturnData.isInterrupt = function (data) { | ||
return ReturnData.getStatusValue(data) === "INTERRUPT"; | ||
}; | ||
/** | ||
* 取消返回类 | ||
* @returns ReturnData | ||
*/ | ||
ReturnData.cancel = function (msg) { | ||
return new ReturnData("CANCEL", null, msg || "网络异常,请重试"); | ||
}; | ||
/** | ||
* 是否是取消返回 | ||
* @param data | ||
* @returns | ||
*/ | ||
ReturnData.isCancel = function (data) { | ||
return ReturnData.getStatusValue(data) === "CANCEL"; | ||
}; | ||
/** | ||
* 顶级错误类 | ||
* @returns ReturnData | ||
*/ | ||
ReturnData.error = function (msg) { | ||
return new this("ERROR", null, msg || "程序中断,请重试"); | ||
}; | ||
/** | ||
* 是否是顶级错误 | ||
* @param data | ||
* @returns | ||
*/ | ||
ReturnData.isError = function (data) { | ||
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; | ||
}()); | ||
function getStatusIsFunction(param) { | ||
return param && typeof param.getStatus === "function"; | ||
} | ||
function Polling(intervalTime, pollingId) { | ||
if (intervalTime === void 0) { intervalTime = 1000; } | ||
if (pollingId === void 0) { pollingId = "__polling__"; } | ||
return function closurePolling(target, property, descriptor) { | ||
var originFn = descriptor.value; | ||
descriptor.value = function fn() { | ||
var _this = this; | ||
var opts = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
opts[_i] = arguments[_i]; | ||
} | ||
if (!this[pollingId]) { | ||
this[pollingId] = []; | ||
} | ||
if (!Array.isArray(this[pollingId])) { | ||
this[pollingId] = [this[pollingId]]; | ||
} | ||
return new Promise(function (resolve) { | ||
var timer = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () { | ||
var result; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, originFn.apply(this, opts)]; | ||
case 1: | ||
result = _a.sent(); | ||
if (ReturnData.isOk(result)) { | ||
resolve(result); | ||
return [2 /*return*/]; | ||
} | ||
this[pollingId] = this[pollingId].filter(function (item) { return item !== timer; }); | ||
clearTimeout(timer); | ||
fn.apply(this, opts); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }, intervalTime); | ||
_this[pollingId].push(timer); | ||
}); | ||
}; | ||
var originOnUnload = target.onUnload; | ||
target.onUnload = function newOnUnload() { | ||
var opts = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
opts[_i] = arguments[_i]; | ||
} | ||
return __awaiter(this, void 0, void 0, function () { | ||
var result; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
this[pollingId].forEach(function (item) { | ||
clearTimeout(item); | ||
}); | ||
this[pollingId] = null; | ||
return [4 /*yield*/, originOnUnload.apply(this, opts)]; | ||
case 1: | ||
result = _a.sent(); | ||
return [2 /*return*/, result]; | ||
} | ||
}); | ||
}); | ||
}; | ||
}; | ||
} | ||
var miniprogram = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
Polling: Polling, | ||
Assemble: Assemble, | ||
@@ -318,3 +566,3 @@ AssembleValue: AssembleValue | ||
export { Assemble, AssembleValue, param as ParamDecorator, index as default, freeze }; | ||
export { Assemble, AssembleValue, param as ParamDecorator, Polling, index as default, freeze }; | ||
//# sourceMappingURL=commonly-decorators.es.js.map |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("freeze-click")):"function"==typeof define&&define.amd?define(["exports","freeze-click"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).commonlyDecorators={},t.freezeClick)}(this,(function(t,e){"use strict";function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=n(e),o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)};function i(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,a)}c((r=r.apply(t,e||[])).next())}))}function u(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function a(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}function c(t){return void 0===t&&(t=1e4),function(e,n,o){var a=o.value;o.value=r.default((function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return i(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,3,4]),[4,a.apply(this,e)];case 1:return[2,n.sent()];case 2:throw n.sent();case 3:return t.cancel(),[7];case 4:return[2]}}))}))}),t)}}function l(t,e,n){return function(r,o){var c=r[t];"function"==typeof c||"function"==typeof(null==c?void 0:c.then)?r[t]=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return i(this,void 0,void 0,(function(){var r;return u(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),r=(t[0]?null==n?void 0:n.map((function(e){return t[0][e]})):[])||[],this[o]=new(e.bind.apply(e,a([void 0],r,!1))),[4,c.apply(this,t)];case 1:return[2,i.sent()];case 2:throw i.sent();case 3:return[2]}}))}))}:r[t]=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return i(this,void 0,void 0,(function(){var r;return u(this,(function(i){try{r=(t[0]?null==n?void 0:n.map((function(e){return t[0][e]})):[])||[],this[o]=new(e.bind.apply(e,a([void 0],r,!1)))}catch(t){console.error(t)}return[2]}))}))}}}function s(t,e){return function(n,r){var o=n[t];"function"==typeof o||"function"==typeof(null==o?void 0:o.then)?n[t]=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return i(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this[r]=e,[4,o.apply(this,t)];case 1:return[2,n.sent()];case 2:throw n.sent();case 3:return[2]}}))}))}:n[t]=function(){return i(this,void 0,void 0,(function(){return u(this,(function(t){try{this[r]=e}catch(t){console.error(t)}return[2]}))}))}}}var f=Object.freeze({__proto__:null,Assemble:l,AssembleValue:s});var p=function(t){function e(e){var n=t.call(this,e)||this;return n.__id="ParameterDecoratorError",n.status="PARAM_ERROR",n.data=null,n.from="CheckParamRequired",n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(e,t),e.prototype.setData=function(t){this.data=t},e.prototype.getData=function(){return this.data},e.prototype.setStatus=function(t){this.status=t},e.prototype.getStatus=function(){return this.status},e.prototype.setFrom=function(t){this.from=t},e.prototype.getFrom=function(){return this.from},e.isParameterDecoratorError=function(t){return t instanceof e||(null==t?void 0:t.__id)===new e("").__id},e}(Error);var h={Required:function(t,e){return void 0===e&&(e=""),function(n,r,o){(null==n?void 0:n.__requiredData)||(n.__requiredData=new Map),n.__requiredData.set(r,{index:o,errMsg:t,propertyPath:e})}},CheckParamRequired:function(t,e,n){var r=n.value;n.value=function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return i(this,void 0,void 0,(function(){var o,i,a,c,l,s;return u(this,(function(u){switch(u.label){case 0:if(o=null==t?void 0:t.__requiredData,i=o.get(e),a=Number(null==i?void 0:i.index),c=null==i?void 0:i.propertyPath,l=(null==c?void 0:c.split("."))||[],s=l.reduce((function(t,e){return null==t||!e&&0!==e||"."===e?t:null==t?void 0:t[e]}),null==n?void 0:n[a]),!isNaN(a)&&(void 0===s||""===s||null===s))throw new p((null==i?void 0:i.errMsg)||"第".concat(a+1,"个参数必传"));return[4,r.apply(this,n)];case 1:return[2,u.sent()]}}))}))}},ParameterDecoratorError:p},d={freeze:c,miniprogram:f};t.Assemble=l,t.AssembleValue=s,t.ParamDecorator=h,t.default=d,t.freeze=c,Object.defineProperty(t,"__esModule",{value:!0})}));//# sourceMappingURL=commonly-decorators.min.js.map | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("freeze-click")):"function"==typeof define&&define.amd?define(["exports","freeze-click"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).commonlyDecorators={},t.freezeClick)}(this,(function(t,n){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=e(n),o=function(t,n){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},o(t,n)};function u(t,n,e,r){return new(e||(e=Promise))((function(o,u){function i(t){try{s(r.next(t))}catch(t){u(t)}}function a(t){try{s(r.throw(t))}catch(t){u(t)}}function s(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(i,a)}s((r=r.apply(t,n||[])).next())}))}function i(t,n){var e,r,o,u,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return u={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function a(u){return function(a){return function(u){if(e)throw new TypeError("Generator is already executing.");for(;i;)try{if(e=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=n.call(t,i)}catch(t){u=[6,t],r=0}finally{e=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,a])}}}function a(t,n,e){if(e||2===arguments.length)for(var r,o=0,u=n.length;o<u;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))}function s(t){return void 0===t&&(t=1e4),function(n,e,o){var a=o.value;o.value=r.default((function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return u(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,3,4]),[4,a.apply(this,n)];case 1:return[2,e.sent()];case 2:throw e.sent();case 3:return t.cancel(),[7];case 4:return[2]}}))}))}),t)}}function c(t,n,e){return function(r,o){var s=r[t];"function"==typeof s||"function"==typeof(null==s?void 0:s.then)?r[t]=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return u(this,void 0,void 0,(function(){var r;return i(this,(function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),r=(t[0]?null==e?void 0:e.map((function(n){return t[0][n]})):[])||[],this[o]=new(n.bind.apply(n,a([void 0],r,!1))),[4,s.apply(this,t)];case 1:return[2,u.sent()];case 2:throw u.sent();case 3:return[2]}}))}))}:r[t]=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return u(this,void 0,void 0,(function(){var r;return i(this,(function(u){try{r=(t[0]?null==e?void 0:e.map((function(n){return t[0][n]})):[])||[],this[o]=new(n.bind.apply(n,a([void 0],r,!1)))}catch(t){console.error(t)}return[2]}))}))}}}function l(t,n){return function(e,r){var o=e[t];"function"==typeof o||"function"==typeof(null==o?void 0:o.then)?e[t]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return u(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),this[r]=n,[4,o.apply(this,t)];case 1:return[2,e.sent()];case 2:throw e.sent();case 3:return[2]}}))}))}:e[t]=function(){return u(this,void 0,void 0,(function(){return i(this,(function(t){try{this[r]=n}catch(t){console.error(t)}return[2]}))}))}}}var f=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 p(t)&&"ok"===t.getStatus()},t.isFail=function(t){return p(t)&&"fail"===t.getStatus()},t.isDeny=function(t){return p(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,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(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 e;return t.getStatusIsFunction(n)?n.getStatus():null!==(e=null==n?void 0:n.status)&&void 0!==e?e:""},t}();function p(t){return t&&"function"==typeof t.getStatus}function h(t,n){return void 0===t&&(t=1e3),void 0===n&&(n="__polling__"),function(e,r,o){var a=o.value;o.value=function e(){for(var r=this,o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];return this[n]||(this[n]=[]),Array.isArray(this[n])||(this[n]=[this[n]]),new Promise((function(s){var c=setTimeout((function(){return u(r,void 0,void 0,(function(){var t;return i(this,(function(r){switch(r.label){case 0:return[4,a.apply(this,o)];case 1:return t=r.sent(),f.isOk(t)?(s(t),[2]):(this[n]=this[n].filter((function(t){return t!==c})),clearTimeout(c),e.apply(this,o),[2])}}))}))}),t);r[n].push(c)}))};var s=e.onUnload;e.onUnload=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return u(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this[n].forEach((function(t){clearTimeout(t)})),this[n]=null,[4,s.apply(this,t)];case 1:return[2,e.sent()]}}))}))}}}var d=Object.freeze({__proto__:null,Polling:h,Assemble:c,AssembleValue:l});var v=function(t){function n(n){var e=t.call(this,n)||this;return e.__id="ParameterDecoratorError",e.status="PARAM_ERROR",e.data=null,e.from="CheckParamRequired",e}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}o(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}(n,t),n.prototype.setData=function(t){this.data=t},n.prototype.getData=function(){return this.data},n.prototype.setStatus=function(t){this.status=t},n.prototype.getStatus=function(){return this.status},n.prototype.setFrom=function(t){this.from=t},n.prototype.getFrom=function(){return this.from},n.isParameterDecoratorError=function(t){return t instanceof n||(null==t?void 0:t.__id)===new n("").__id},n}(Error);var y={Required:function(t,n){return void 0===n&&(n=""),function(e,r,o){(null==e?void 0:e.__requiredData)||(e.__requiredData=new Map),e.__requiredData.set(r,{index:o,errMsg:t,propertyPath:n})}},CheckParamRequired:function(t,n,e){var r=e.value;e.value=function(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];return u(this,void 0,void 0,(function(){var o,u,a,s,c,l;return i(this,(function(i){switch(i.label){case 0:if(o=null==t?void 0:t.__requiredData,u=o.get(n),a=Number(null==u?void 0:u.index),s=null==u?void 0:u.propertyPath,c=(null==s?void 0:s.split("."))||[],l=c.reduce((function(t,n){return null==t||!n&&0!==n||"."===n?t:null==t?void 0:t[n]}),null==e?void 0:e[a]),!isNaN(a)&&(void 0===l||""===l||null===l))throw new v((null==u?void 0:u.errMsg)||"第".concat(a+1,"个参数必传"));return[4,r.apply(this,e)];case 1:return[2,i.sent()]}}))}))}},ParameterDecoratorError:v},g={freeze:s,miniprogram:d};t.Assemble=c,t.AssembleValue=l,t.ParamDecorator=y,t.Polling=h,t.default=g,t.freeze=s,Object.defineProperty(t,"__esModule",{value:!0})}));//# sourceMappingURL=commonly-decorators.min.js.map |
@@ -17,4 +17,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Polling = void 0; | ||
__exportStar(require("./Assemble"), exports); | ||
__exportStar(require("./Polling"), exports); | ||
var Polling_1 = require("./Polling"); | ||
exports.Polling = Polling_1.default; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "commonly-decorators", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "some commonly decorators", | ||
@@ -5,0 +5,0 @@ "author": "yiri.zhou", |
export * from "./Assemble"; | ||
export * from "./Polling"; | ||
import Polling from "./Polling"; | ||
export { Polling }; |
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
123410
1362