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

33 lines
747 B
JavaScript
Raw Normal View History

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