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