@minionorg/share
Version:
3 lines (2 loc) • 2.12 kB
JavaScript
(function(i,r){typeof exports=="object"&&typeof module<"u"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(i=typeof globalThis<"u"?globalThis:i||self,r(i.index={}))})(this,function(i){"use strict";var y=Object.defineProperty;var g=(i,r,u)=>r in i?y(i,r,{enumerable:!0,configurable:!0,writable:!0,value:u}):i[r]=u;var f=(i,r,u)=>(g(i,typeof r!="symbol"?r+"":r,u),u);function r(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 ${r(e)}]`}}function l(e,t){if(!u("string")(e))throw new TypeError("The parameter type is string");return t!==void 0&&e.length===0?t:e.charAt(0)}function a(e){const t=l(e);return t===" "||t===`
`||t==="\r"||t===" "||t==="\f"}function c(e){if(!e)throw new SyntaxError("type is must");return function(t){return Object.prototype.toString.call(t)===`[object ${r(e)}]`}}c("Function"),c("Object");class o{constructor(){}static notNull(t,n){if(t===null)throw new SyntaxError(n||"The value must not be empty")}static notEmpty(t,n){if(t.length===0)throw new SyntaxError(n||"The String must not be empty")}static errMsg(t){return function(n){return`${t}: ${n}`}}static isString(t){if(t===null)return null;if(u("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(o,"DEFAULT_NOT_NAN_EX_MESSAGE","\u9A8C\u8BC1\u7684\u503C\u4E0D\u662F\u6570\u5B57");function h(e){const t=o.isString(e);return t===null?0:t.length}function p(e,t=null){let n=h(e);if(n===0)return e;{const s=o.isString(t);if(s===null)for(;n!==0&&a(e.charAt(n-1));)--n;else{if(s.length===0)return e;for(;n!==0&&s.indexOf(e.charAt(n-1))!==-1;)--n}return e.substring(0,n)}}i.default=p,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});