UNPKG

@minionorg/share

Version:
2 lines (1 loc) 1.91 kB
(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 y=Object.defineProperty;var m=(r,n,i)=>n in r?y(r,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[n]=i;var c=(r,n,i)=>(m(r,typeof n!="symbol"?n+"":n,i),i);function n(e){return e.charAt(0).toUpperCase()+e.slice(1)}function i(e){if(!e)throw new SyntaxError("type is must");return function(t){return Object.prototype.toString.call(t)===`[object ${n(e)}]`}}function l(e){if(!e)throw new SyntaxError("type is must");return function(t){return Object.prototype.toString.call(t)===`[object ${n(e)}]`}}i("Function"),i("Object");class s{constructor(){}static notNull(t,u){if(t===null)throw new SyntaxError(u||"The value must not be empty")}static notEmpty(t,u){if(t.length===0)throw new SyntaxError(u||"The String must not be empty")}static errMsg(t){return function(u){return`${t}: ${u}`}}static isString(t){if(t===null)return null;if(l("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)}}c(s,"DEFAULT_NOT_NAN_EX_MESSAGE","\u9A8C\u8BC1\u7684\u503C\u4E0D\u662F\u6570\u5B57");function f(e){const t=s.isString(e);return t===null?null:t.replace(/(^\s*)|(\s*$)/g,"")}function a(e){return new RegExp("[A-Za-z]+","g").test(e)}const p=function(e,t){let u=0;for(let o=0;o<e.length;o++)a(e[o])?u++:u+=t;return u};function g(e,t=!1,u=2){return t?p(f(e),u):e.length}r.default=g,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});