@minionorg/share
Version:
2 lines (1 loc) • 2.21 kB
JavaScript
(function(r,n){typeof exports=="object"&&typeof module<"u"?n(exports):typeof define=="function"&&define.amd?define(["exports"],n):(r=typeof globalThis<"u"?globalThis:r||self,n(r.index={}))})(this,function(r){"use strict";var h=Object.defineProperty;var w=(r,n,u)=>n in r?h(r,n,{enumerable:!0,configurable:!0,writable:!0,value:u}):r[n]=u;var f=(r,n,u)=>(w(r,typeof n!="symbol"?n+"":n,u),u);function n(e){return e.charAt(0).toUpperCase()+e.slice(1)}function u(e){if(!e)throw new SyntaxError("type is must");return function(t){return Object.prototype.toString.call(t)===`[object ${n(e)}]`}}function c(e){if(!e)throw new SyntaxError("type is must");return function(t){return Object.prototype.toString.call(t)===`[object ${n(e)}]`}}u("Function"),u("Object");class l{constructor(){}static notNull(t,o){if(t===null)throw new SyntaxError(o||"The value must not be empty")}static notEmpty(t,o){if(t.length===0)throw new SyntaxError(o||"The String must not be empty")}static errMsg(t){return function(o){return`${t}: ${o}`}}static isString(t){if(t===null)return null;if(c("string")(t))return t;throw new TypeError("The parameter type is string")}static isValidDateFormat(t){return/(^(y{4}|y{2})[.\u002f-](m{1,2})[.\u002f-](d{1,2})$)|(^(m{1,2})[.\u002f-](d{1,2})[.\u002f-]((y{4}|y{2})$))|(^(d{1,2})[.\u002f-](m{1,2})[.\u002f-]((y{4}|y{2})$))/gi.test(t)}static isTimeFormat(t){return/(^(h{1,2}):(m{1,2}):(s{1,2})$)|(^(h{1,2}):(m{1,2})$)/gi.test(t)}}f(l,"DEFAULT_NOT_NAN_EX_MESSAGE","\u9A8C\u8BC1\u7684\u503C\u4E0D\u662F\u6570\u5B57");function p(e,t){if(l.isString(e)===null)return!1;const d=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,g=/^[-+]?[0-9]+$/,i=t||{},s=Object.prototype.hasOwnProperty,m=(Object.prototype.hasOwnProperty.call(i,"zeroes")&&!i.zeroes?d:g).test(e),a=parseInt(e,10);return m&&(!s.call(i,"min")||a>=i.min)&&(!s.call(i,"max")||a<=i.max)&&(!s.call(i,"lt")||a<i.lt)&&(!s.call(i,"gt")||a>i.gt)}function y(e,t){if(!c("Date")(e))throw new TypeError(`Invalid date: ${e}`);if(!p(t+""))throw new SyntaxError(`Invalid number: ${t}`);const o=new Date(e.getTime());return o.setDate(o.getDate()+(c("Number")(t)?t:+t)),o}r.default=y,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});