148 lines
3.5 KiB
JavaScript
148 lines
3.5 KiB
JavaScript
var h = /* @__PURE__ */ ((e) => (e[e.delete = 2] = "delete", e[e.reset = 1] = "reset", e))(h || {});
|
|
const p = (e) => ({
|
|
clear: function(t = 2) {
|
|
t === 1 ? Object.keys(e).forEach((n) => {
|
|
e[n] = void 0;
|
|
}) : t === 2 && Object.keys(e).forEach((n) => {
|
|
delete e[n];
|
|
});
|
|
},
|
|
replace: function(t) {
|
|
this.clear(
|
|
2
|
|
/* delete */
|
|
), Object.assign(e, t);
|
|
}
|
|
});
|
|
function m(...e) {
|
|
let t = e ?? [];
|
|
return {
|
|
test: function(n) {
|
|
if (t.length <= 1)
|
|
return t.length === 1 ? t[0] : [];
|
|
let r = n ?? function(s, i) {
|
|
return s === i;
|
|
};
|
|
return t.reduce((s, i) => (i && i.length > 0 && (s.length === 0 ? s.push(...i) : i.forEach((f) => {
|
|
s.some((o) => r(o, f)) || s.push(f);
|
|
})), s), []);
|
|
},
|
|
path: function(...n) {
|
|
return this.test((r, s) => n.every((i) => r[i] === s[i]));
|
|
}
|
|
};
|
|
}
|
|
const O = (e, ...t) => {
|
|
for (const n of t)
|
|
if (n !== void 0)
|
|
for (const r in n)
|
|
n.hasOwnProperty(r) && n[r] != null && (e[r] = n[r]);
|
|
return e;
|
|
};
|
|
function I(e, t, n) {
|
|
const r = t, s = n || t;
|
|
return function(i) {
|
|
const f = [], u = i.matchAll(e);
|
|
let o = 0;
|
|
for (const l of u) {
|
|
const g = i.slice(o, l.index);
|
|
g && f.push(s(g, !1)), f.push(r(l[0], !0)), o = l.index + l[0].length;
|
|
}
|
|
return o < i.length && f.push(s(i.slice(o), !1)), f;
|
|
};
|
|
}
|
|
function a(e, t) {
|
|
return typeof e == "string" && typeof t == "string" ? e.toLowerCase() === t.toLowerCase() : e === void 0 && t === void 0;
|
|
}
|
|
const E = (e, t) => {
|
|
for (let n = 0; n < e.length; n++) {
|
|
let r = e[n];
|
|
if (a(r, t))
|
|
return !0;
|
|
}
|
|
return !1;
|
|
}, d = (e) => e.replaceAll(/[\u4e00-\u9fa5]/g, "--").length, y = (e, t, n = " ") => {
|
|
const r = t - (d(e) - e.length);
|
|
return e.padEnd(r, n);
|
|
};
|
|
function b(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 N(e) {
|
|
const t = x(e), n = t.lastIndexOf(".");
|
|
return n === -1 ? t : t.substring(0, n);
|
|
}
|
|
function w(e, t = "win32") {
|
|
const n = t === "win32" ? "\\" : "/";
|
|
let r, s, i, f;
|
|
const u = e.lastIndexOf(n);
|
|
u === -1 ? (r = "", s = e) : (r = e.substring(0, u + 1), s = e.substring(u + 1));
|
|
const o = s.lastIndexOf(".");
|
|
return o === -1 ? (i = "", f = s) : (i = s.substring(o + 1), f = s.substring(0, o)), {
|
|
fileName: s,
|
|
fileNameNoExt: f,
|
|
fileExtName: i,
|
|
fullPath: e,
|
|
pathOnly: r
|
|
};
|
|
}
|
|
const c = {
|
|
/**
|
|
* Creates an optional of the specified value. The value may be undefined or null.
|
|
* @return OptionalInstance<T>
|
|
*/
|
|
of(e) {
|
|
function t(n) {
|
|
return n == null;
|
|
}
|
|
return {
|
|
get() {
|
|
return e;
|
|
},
|
|
orElse(n) {
|
|
return t(e) ? n : e;
|
|
},
|
|
then(n, r) {
|
|
t(e) ? r && r() : n(e);
|
|
},
|
|
ifPresent(n) {
|
|
e != null && n(e);
|
|
},
|
|
isPresent() {
|
|
return !t(e);
|
|
},
|
|
filter(n) {
|
|
return t(e) || n(e) ? this : c.of(void 0);
|
|
},
|
|
map(n) {
|
|
return e == null ? c.of(void 0) : c.of(n(e));
|
|
},
|
|
flatMap(n) {
|
|
return n(e);
|
|
}
|
|
};
|
|
}
|
|
};
|
|
export {
|
|
c as Optional,
|
|
h as RecordClearMode,
|
|
m as assignRecords,
|
|
a as equalsIgnoreCase,
|
|
O as extendRecord,
|
|
b as getFileExt,
|
|
w as getFileInfo,
|
|
x as getFileName,
|
|
N as getFileNameWithoutExt,
|
|
E as includeIgnoreCase,
|
|
d as strLength,
|
|
y as strMonospacePad,
|
|
I as stringTokenizer,
|
|
p as withRecord
|
|
};
|
|
//# sourceMappingURL=index.es.js.map
|