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

46 lines
1.1 KiB
JavaScript

const h = (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];
}) : Object.assign(e, {});
},
replace: function(t) {
this.clear(
3
/* clear */
), Object.assign(e, t);
}
});
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;
}
return r < i.length && s.push(o(i.slice(r), !1)), s;
};
}
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;
};
export {
a as equalsIgnoreCase,
p as includeIgnoreCase,
g as stringTokenizer,
h as withRecord
};
//# sourceMappingURL=index.es.js.map