ez-common-ts/lib/index.es.js
2023-11-14 16:17:22 +08:00

97 lines
2.5 KiB
JavaScript

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