ez-common-ts/lib/index.es.js

77 lines
1.9 KiB
JavaScript
Raw Normal View History

2023-11-12 21:58:32 +08:00
var h = /* @__PURE__ */ ((e) => (e[e.delete = 2] = "delete", e[e.reset = 1] = "reset", e))(h || {});
const a = (e) => ({
2023-11-11 15:30:11 +08:00
clear: function(t = 2) {
2023-11-11 16:13:36 +08:00
t === 1 ? Object.keys(e).forEach((n) => {
e[n] = void 0;
2023-11-11 21:28:01 +08:00
}) : t === 2 && Object.keys(e).forEach((n) => {
2023-11-11 16:13:36 +08:00
delete e[n];
2023-11-11 21:28:01 +08:00
});
2023-11-11 15:30:11 +08:00
},
replace: function(t) {
this.clear(
2023-11-11 21:28:01 +08:00
2
/* delete */
2023-11-11 15:30:11 +08:00
), Object.assign(e, t);
}
});
2023-11-12 21:58:32 +08:00
function x(...e) {
2023-11-11 21:28:01 +08:00
let t = e ?? [];
return {
test: function(n) {
if (t.length <= 1)
return t.length === 1 ? t[0] : [];
let i = n ?? function(s, r) {
return s === r;
};
return t.reduce((s, r) => (r && r.length > 0 && (s.length === 0 ? s.push(...r) : r.forEach((u) => {
s.some((f) => i(f, u)) || s.push(u);
})), s), []);
},
path: function(...n) {
return this.test((i, s) => n.every((r) => i[r] === s[r]));
2023-11-10 16:35:59 +08:00
}
2023-11-11 21:28:01 +08:00
};
}
2023-11-12 21:58:32 +08:00
function d(e, t, n) {
2023-11-11 21:28:01 +08:00
const i = t, s = n || t;
return function(r) {
2023-11-12 21:58:32 +08:00
const u = [], o = r.matchAll(e);
2023-11-11 21:28:01 +08:00
let f = 0;
2023-11-12 21:58:32 +08:00
for (const l of o) {
const c = r.slice(f, l.index);
c && u.push(s(c, !1)), u.push(i(l[0], !0)), f = l.index + l[0].length;
2023-11-11 21:28:01 +08:00
}
return f < r.length && u.push(s(r.slice(f), !1)), u;
2023-11-10 16:35:59 +08:00
};
}
2023-11-12 21:58:32 +08:00
function g(e, t) {
2023-11-11 16:13:36 +08:00
return typeof e == "string" && typeof t == "string" ? e.toLowerCase() === t.toLowerCase() : e === void 0 && t === void 0;
}
2023-11-12 21:58:32 +08:00
const p = (e, t) => {
2023-11-11 16:13:36 +08:00
for (let n = 0; n < e.length; n++) {
2023-11-11 21:28:01 +08:00
let i = e[n];
2023-11-12 21:58:32 +08:00
if (g(i, t))
2023-11-11 16:13:36 +08:00
return !0;
}
return !1;
};
2023-11-12 21:58:32 +08:00
function y(e) {
const t = e.lastIndexOf(".");
return t === -1 ? "" : e.substring(t + 1);
}
function O(e) {
let t = e.lastIndexOf("/");
return t === -1 && (t = e.lastIndexOf("\\"), t === -1) ? e : e.substring(t + 1);
}
2023-11-10 16:35:59 +08:00
export {
2023-11-12 21:58:32 +08:00
h as RecordClearMode,
x as assignRecords,
g as equalsIgnoreCase,
y as getFileExt,
O as getFileName,
p as includeIgnoreCase,
d as stringTokenizer,
a as withRecord
2023-11-10 16:35:59 +08:00
};
//# sourceMappingURL=index.es.js.map