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

46 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-11-11 16:13:36 +08:00
const h = (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;
}) : t === 2 ? Object.keys(e).forEach((n) => {
delete e[n];
2023-11-11 15:30:11 +08:00
}) : Object.assign(e, {});
},
replace: function(t) {
this.clear(
3
/* clear */
), Object.assign(e, t);
}
});
2023-11-11 16:13:36 +08:00
function g(e, t, n) {
const f = t, o = n || t;
return function(i) {
const s = [], u = i.matchAll(e);
let r = 0;
for (const c of u) {
const l = i.slice(r, c.index);
l && s.push(o(l, !1)), s.push(f(c[0], !0)), r = c.index + c[0].length;
2023-11-10 16:35:59 +08:00
}
2023-11-11 16:13:36 +08:00
return r < i.length && s.push(o(i.slice(r), !1)), s;
2023-11-10 16:35:59 +08:00
};
}
2023-11-11 16:13:36 +08:00
function a(e, t) {
return typeof e == "string" && typeof t == "string" ? e.toLowerCase() === t.toLowerCase() : e === void 0 && t === void 0;
}
const p = (e, t) => {
for (let n = 0; n < e.length; n++) {
let f = e[n];
if (a(f, t))
return !0;
}
return !1;
};
2023-11-10 16:35:59 +08:00
export {
2023-11-11 16:13:36 +08:00
a as equalsIgnoreCase,
p as includeIgnoreCase,
g as stringTokenizer,
h as withRecord
2023-11-10 16:35:59 +08:00
};
//# sourceMappingURL=index.es.js.map