This commit is contained in:
zhujingjing 2024-01-28 18:33:16 +08:00
parent c1ade4dc2a
commit d6e6a58a36
Signed by: karlcw
GPG Key ID: B11805D3A0F5C671
6 changed files with 82 additions and 73 deletions

4
lib/index.d.ts vendored
View File

@ -1,4 +1,4 @@
import { withRecord, assignRecords, RecordClearMode } from "./commons/record-util"; import { withRecord, assignRecords, RecordClearMode } from "./commons/record-util";
import { stringTokenizer, equalsIgnoreCase, includeIgnoreCase } from "./commons/str-utils"; import { stringTokenizer, equalsIgnoreCase, includeIgnoreCase, strLength, strMonospacePad } from "./commons/str-utils";
import { getFileExt, getFileFullName, getFileNameWithoutExt, getFileInfo } from "./commons/file-util"; import { getFileExt, getFileFullName, getFileNameWithoutExt, getFileInfo } from "./commons/file-util";
export { stringTokenizer, withRecord, equalsIgnoreCase, includeIgnoreCase, assignRecords, RecordClearMode, getFileExt, getFileFullName as getFileName, getFileNameWithoutExt, getFileInfo, }; export { stringTokenizer, withRecord, equalsIgnoreCase, includeIgnoreCase, assignRecords, RecordClearMode, getFileExt, getFileFullName as getFileName, getFileNameWithoutExt, getFileInfo, strLength, strMonospacePad };

View File

@ -1,10 +1,10 @@
var a = /* @__PURE__ */ ((e) => (e[e.delete = 2] = "delete", e[e.reset = 1] = "reset", e))(a || {}); var a = /* @__PURE__ */ ((e) => (e[e.delete = 2] = "delete", e[e.reset = 1] = "reset", e))(a || {});
const h = (e) => ({ const d = (e) => ({
clear: function(t = 2) { clear: function(t = 2) {
t === 1 ? Object.keys(e).forEach((s) => { t === 1 ? Object.keys(e).forEach((n) => {
e[s] = void 0; e[n] = void 0;
}) : t === 2 && Object.keys(e).forEach((s) => { }) : t === 2 && Object.keys(e).forEach((n) => {
delete e[s]; delete e[n];
}); });
}, },
replace: function(t) { replace: function(t) {
@ -14,48 +14,51 @@ const h = (e) => ({
), Object.assign(e, t); ), Object.assign(e, t);
} }
}); });
function d(...e) { function m(...e) {
let t = e ?? []; let t = e ?? [];
return { return {
test: function(s) { test: function(n) {
if (t.length <= 1) if (t.length <= 1)
return t.length === 1 ? t[0] : []; return t.length === 1 ? t[0] : [];
let r = s ?? function(n, i) { let i = n ?? function(s, r) {
return n === i; return s === r;
}; };
return t.reduce((n, i) => (i && i.length > 0 && (n.length === 0 ? n.push(...i) : i.forEach((u) => { return t.reduce((s, r) => (r && r.length > 0 && (s.length === 0 ? s.push(...r) : r.forEach((u) => {
n.some((f) => r(f, u)) || n.push(u); s.some((l) => i(l, u)) || s.push(u);
})), n), []); })), s), []);
}, },
path: function(...s) { path: function(...n) {
return this.test((r, n) => s.every((i) => r[i] === n[i])); return this.test((i, s) => n.every((r) => i[r] === s[r]));
} }
}; };
} }
function m(e, t, s) { function I(e, t, n) {
const r = t, n = s || t; const i = t, s = n || t;
return function(i) { return function(r) {
const u = [], l = i.matchAll(e); const u = [], f = r.matchAll(e);
let f = 0; let l = 0;
for (const o of l) { for (const o of f) {
const c = i.slice(f, o.index); const c = r.slice(l, o.index);
c && u.push(n(c, !1)), u.push(r(o[0], !0)), f = o.index + o[0].length; c && u.push(s(c, !1)), u.push(i(o[0], !0)), l = o.index + o[0].length;
} }
return f < i.length && u.push(n(i.slice(f), !1)), u; return l < r.length && u.push(s(r.slice(l), !1)), u;
}; };
} }
function g(e, t) { function g(e, t) {
return typeof e == "string" && typeof t == "string" ? e.toLowerCase() === t.toLowerCase() : e === void 0 && t === void 0; return typeof e == "string" && typeof t == "string" ? e.toLowerCase() === t.toLowerCase() : e === void 0 && t === void 0;
} }
const I = (e, t) => { const O = (e, t) => {
for (let s = 0; s < e.length; s++) { for (let n = 0; n < e.length; n++) {
let r = e[s]; let i = e[n];
if (g(r, t)) if (g(i, t))
return !0; return !0;
} }
return !1; return !1;
}, h = (e) => e.replaceAll(/[\u4e00-\u9fa5]/g, "--").length, p = (e, t, n = " ") => {
const i = t - (h(e) - e.length);
return e.padEnd(i, n);
}; };
function O(e) { function E(e) {
const t = e.lastIndexOf("."); const t = e.lastIndexOf(".");
return t === -1 ? "" : e.substring(t + 1); return t === -1 ? "" : e.substring(t + 1);
} }
@ -63,34 +66,36 @@ function x(e) {
let t = e.lastIndexOf("/"); let t = e.lastIndexOf("/");
return t === -1 && (t = e.lastIndexOf("\\"), t === -1) ? e : e.substring(t + 1); return t === -1 && (t = e.lastIndexOf("\\"), t === -1) ? e : e.substring(t + 1);
} }
function E(e) { function b(e) {
const t = x(e), s = t.lastIndexOf("."); const t = x(e), n = t.lastIndexOf(".");
return s === -1 ? t : t.substring(0, s); return n === -1 ? t : t.substring(0, n);
} }
function b(e, t = "win32") { function y(e, t = "win32") {
const s = t === "win32" ? "\\" : "/"; const n = t === "win32" ? "\\" : "/";
let r, n, i, u; let i, s, r, u;
const l = e.lastIndexOf(s); const f = e.lastIndexOf(n);
l === -1 ? (r = "", n = e) : (r = e.substring(0, l + 1), n = e.substring(l + 1)); f === -1 ? (i = "", s = e) : (i = e.substring(0, f + 1), s = e.substring(f + 1));
const f = n.lastIndexOf("."); const l = s.lastIndexOf(".");
return f === -1 ? (i = "", u = n) : (i = n.substring(f + 1), u = n.substring(0, f)), { return l === -1 ? (r = "", u = s) : (r = s.substring(l + 1), u = s.substring(0, l)), {
fileName: n, fileName: s,
fileNameNoExt: u, fileNameNoExt: u,
fileExtName: i, fileExtName: r,
fullPath: e, fullPath: e,
pathOnly: r pathOnly: i
}; };
} }
export { export {
a as RecordClearMode, a as RecordClearMode,
d as assignRecords, m as assignRecords,
g as equalsIgnoreCase, g as equalsIgnoreCase,
O as getFileExt, E as getFileExt,
b as getFileInfo, y as getFileInfo,
x as getFileName, x as getFileName,
E as getFileNameWithoutExt, b as getFileNameWithoutExt,
I as includeIgnoreCase, O as includeIgnoreCase,
m as stringTokenizer, h as strLength,
h as withRecord p as strMonospacePad,
I as stringTokenizer,
d as withRecord
}; };
//# sourceMappingURL=index.es.js.map //# sourceMappingURL=index.es.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
(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 m=e=>({clear:function(n=2){n===1?Object.keys(e).forEach(i=>{e[i]=void 0}):n===2&&Object.keys(e).forEach(i=>{delete e[i]})},replace:function(n){this.clear(2),Object.assign(e,n)}});function x(...e){let n=e??[];return{test:function(i){if(n.length<=1)return n.length===1?n[0]:[];let u=i??function(t,s){return t===s};return n.reduce((t,s)=>(s&&s.length>0&&(t.length===0?t.push(...s):s.forEach(f=>{t.some(l=>u(l,f))||t.push(f)})),t),[])},path:function(...i){return this.test((u,t)=>i.every(s=>u[s]===t[s]))}}}function I(e,n,i){const u=n,t=i||n;return function(s){const f=[],c=s.matchAll(e);let l=0;for(const g of c){const h=s.slice(l,g.index);h&&f.push(t(h,!1)),f.push(u(g[0],!0)),l=g.index+g[0].length}return l<s.length&&f.push(t(s.slice(l),!1)),f}}function a(e,n){return typeof e=="string"&&typeof n=="string"?e.toLowerCase()===n.toLowerCase():e===void 0&&n===void 0}const y=(e,n)=>{for(let i=0;i<e.length;i++){let u=e[i];if(a(u,n))return!0}return!1};function O(e){const n=e.lastIndexOf(".");return n===-1?"":e.substring(n+1)}function d(e){let n=e.lastIndexOf("/");return n===-1&&(n=e.lastIndexOf("\\"),n===-1)?e:e.substring(n+1)}function b(e){const n=d(e),i=n.lastIndexOf(".");return i===-1?n:n.substring(0,i)}function E(e,n="win32"){const i=n==="win32"?"\\":"/";let u,t,s,f;const c=e.lastIndexOf(i);c===-1?(u="",t=e):(u=e.substring(0,c+1),t=e.substring(c+1));const l=t.lastIndexOf(".");return l===-1?(s="",f=t):(s=t.substring(l+1),f=t.substring(0,l)),{fileName:t,fileNameNoExt:f,fileExtName:s,fullPath:e,pathOnly:u}}r.RecordClearMode=o,r.assignRecords=x,r.equalsIgnoreCase=a,r.getFileExt=O,r.getFileInfo=E,r.getFileName=d,r.getFileNameWithoutExt=b,r.includeIgnoreCase=y,r.stringTokenizer=I,r.withRecord=m,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}); (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 I=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 x(...e){let n=e??[];return{test:function(t){if(n.length<=1)return n.length===1?n[0]:[];let u=t??function(i,s){return i===s};return n.reduce((i,s)=>(s&&s.length>0&&(i.length===0?i.push(...s):s.forEach(l=>{i.some(f=>u(f,l))||i.push(l)})),i),[])},path:function(...t){return this.test((u,i)=>t.every(s=>u[s]===i[s]))}}}function b(e,n,t){const u=n,i=t||n;return function(s){const l=[],c=s.matchAll(e);let f=0;for(const a of c){const m=s.slice(f,a.index);m&&l.push(i(m,!1)),l.push(u(a[0],!0)),f=a.index+a[0].length}return f<s.length&&l.push(i(s.slice(f),!1)),l}}function g(e,n){return typeof e=="string"&&typeof n=="string"?e.toLowerCase()===n.toLowerCase():e===void 0&&n===void 0}const y=(e,n)=>{for(let t=0;t<e.length;t++){let u=e[t];if(g(u,n))return!0}return!1},d=e=>e.replaceAll(/[\u4e00-\u9fa5]/g,"--").length,E=(e,n,t=" ")=>{const u=n-(d(e)-e.length);return e.padEnd(u,t)};function O(e){const n=e.lastIndexOf(".");return n===-1?"":e.substring(n+1)}function h(e){let n=e.lastIndexOf("/");return n===-1&&(n=e.lastIndexOf("\\"),n===-1)?e:e.substring(n+1)}function F(e){const n=h(e),t=n.lastIndexOf(".");return t===-1?n:n.substring(0,t)}function N(e,n="win32"){const t=n==="win32"?"\\":"/";let u,i,s,l;const c=e.lastIndexOf(t);c===-1?(u="",i=e):(u=e.substring(0,c+1),i=e.substring(c+1));const f=i.lastIndexOf(".");return f===-1?(s="",l=i):(s=i.substring(f+1),l=i.substring(0,f)),{fileName:i,fileNameNoExt:l,fileExtName:s,fullPath:e,pathOnly:u}}r.RecordClearMode=o,r.assignRecords=x,r.equalsIgnoreCase=g,r.getFileExt=O,r.getFileInfo=N,r.getFileName=h,r.getFileNameWithoutExt=F,r.includeIgnoreCase=y,r.strLength=d,r.strMonospacePad=E,r.stringTokenizer=b,r.withRecord=I,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
//# sourceMappingURL=index.umd.js.map //# sourceMappingURL=index.umd.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,29 +1,33 @@
import { import {
withRecord, withRecord,
assignRecords, assignRecords,
RecordClearMode, RecordClearMode,
} from "./commons/record-util"; } from "./commons/record-util";
import { import {
stringTokenizer, stringTokenizer,
equalsIgnoreCase, equalsIgnoreCase,
includeIgnoreCase, includeIgnoreCase,
strLength,
strMonospacePad
} from "./commons/str-utils"; } from "./commons/str-utils";
import { import {
getFileExt, getFileExt,
getFileFullName, getFileFullName,
getFileNameWithoutExt, getFileNameWithoutExt,
getFileInfo, getFileInfo,
} from "./commons/file-util"; } from "./commons/file-util";
export { export {
stringTokenizer, stringTokenizer,
withRecord, withRecord,
equalsIgnoreCase, equalsIgnoreCase,
includeIgnoreCase, includeIgnoreCase,
assignRecords, assignRecords,
RecordClearMode, RecordClearMode,
getFileExt, getFileExt,
getFileFullName as getFileName, getFileFullName as getFileName,
getFileNameWithoutExt, getFileNameWithoutExt,
getFileInfo, getFileInfo,
strLength,
strMonospacePad
}; };