3 lines
2.5 KiB
JavaScript
3 lines
2.5 KiB
JavaScript
(function(r,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(r=typeof globalThis<"u"?globalThis:r||self,o(r["ez-common-ts"]={}))})(this,function(r){"use strict";var o=(e=>(e[e.delete=2]="delete",e[e.reset=1]="reset",e))(o||{});const O=e=>({clear:function(n=2){n===1?Object.keys(e).forEach(t=>{e[t]=void 0}):n===2&&Object.keys(e).forEach(t=>{delete e[t]})},replace:function(n){this.clear(2),Object.assign(e,n)}});function E(...e){let n=e??[];return{test:function(t){if(n.length<=1)return n.length===1?n[0]:[];let f=t??function(i,s){return i===s};return n.reduce((i,s)=>(s&&s.length>0&&(i.length===0?i.push(...s):s.forEach(u=>{i.some(l=>f(l,u))||i.push(u)})),i),[])},path:function(...t){return this.test((f,i)=>t.every(s=>f[s]===i[s]))}}}function b(e,n,t){const f=n,i=t||n;return function(s){const u=[],c=s.matchAll(e);let l=0;for(const d of c){const I=s.slice(l,d.index);I&&u.push(i(I,!1)),u.push(f(d[0],!0)),l=d.index+d[0].length}return l<s.length&&u.push(i(s.slice(l),!1)),u}}function a(e,n){return typeof e=="string"&&typeof n=="string"?e.toLowerCase()===n.toLowerCase():e===void 0&&n===void 0}const x=(e,n)=>{for(let t=0;t<e.length;t++){let f=e[t];if(a(f,n))return!0}return!1},h=e=>e.replaceAll(/[\u4e00-\u9fa5]/g,"--").length,y=(e,n,t=" ")=>{const f=n-(h(e)-e.length);return e.padEnd(f,t)};function p(e){const n=e.lastIndexOf(".");return n===-1?"":e.substring(n+1)}function m(e){let n=e.lastIndexOf("/");return n===-1&&(n=e.lastIndexOf("\\"),n===-1)?e:e.substring(n+1)}function F(e){const n=m(e),t=n.lastIndexOf(".");return t===-1?n:n.substring(0,t)}function N(e,n="win32"){const t=n==="win32"?"\\":"/";let f,i,s,u;const c=e.lastIndexOf(t);c===-1?(f="",i=e):(f=e.substring(0,c+1),i=e.substring(c+1));const l=i.lastIndexOf(".");return l===-1?(s="",u=i):(s=i.substring(l+1),u=i.substring(0,l)),{fileName:i,fileNameNoExt:u,fileExtName:s,fullPath:e,pathOnly:f}}const g={of(e){function n(t){return t==null}return{get(){return e},orElse(t){return n(e)?t:e},then(t,f){n(e)?f&&f():t(e)},ifPresent(t){e!=null&&t(e)},isPresent(){return!n(e)},filter(t){return n(e)||t(e)?this:g.of(void 0)},map(t){return e==null?g.of(void 0):g.of(t(e))},flatMap(t){return t(e)}}}};r.Optional=g,r.RecordClearMode=o,r.assignRecords=E,r.equalsIgnoreCase=a,r.getFileExt=p,r.getFileInfo=N,r.getFileName=m,r.getFileNameWithoutExt=F,r.includeIgnoreCase=x,r.strLength=h,r.strMonospacePad=y,r.stringTokenizer=b,r.withRecord=O,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
|
|
//# sourceMappingURL=index.umd.js.map
|