@acrool/js-utils
Version:
Common javascript utils methods for project development
128 lines (127 loc) • 2.45 kB
JavaScript
import { p as U } from "../common-933bb6d6.js";
const c = [
"html",
"head",
"body",
"main",
"footer",
"article",
"section",
"nav",
"aside",
"img",
"figcaption",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"div",
"p",
"span",
"em",
"strong",
"blockquote",
"a",
"pre",
"code",
"time",
"hr",
"br",
"iframe",
"embed",
"video",
"audio",
"source",
"canvas",
"svg",
"thead",
"tbody",
"tfoot",
"tr",
"td",
"th"
];
function s(e) {
return e.replace(/\b(\w)/g, (r) => r.toUpperCase());
}
function u(e) {
return e.toLowerCase().replace(/\_(\w)/g, function(r, t) {
return t.toUpperCase();
});
}
function i(e) {
return e.toLowerCase().replace(/\-(\w)/g, function(r, t) {
return t.toUpperCase();
});
}
function p(e) {
return e.replace(/\-(.*)/g, (t) => t.toUpperCase()).replace(/(.*)+\-/g, (t) => t.toLowerCase());
}
function f(e) {
return e.replace(/([A-Z])/g, "-$1").toLowerCase();
}
function d(e) {
return e.replace(/([A-Z])/g, "_$1").toUpperCase();
}
function l(e, r) {
try {
return e.split(r);
} catch {
}
return [];
}
function g(e) {
try {
const r = JSON.parse(e);
if (r && typeof r == "object" && r !== null)
return r;
} catch {
}
}
function m(e, r, t) {
const o = `\\${r}|\\${t}`, n = new RegExp(`^${o}$`, "g");
return e.replace(n, "");
}
function C(e) {
return Object.fromEntries(
Object.entries(e).filter(([r, t]) => t !== void 0)
);
}
function b(e, r) {
const t = r && (r == null ? void 0 : r.length) > 0 ? c.filter((n) => !r.includes(n)) : c;
let o = e.toString();
for (const n of t) {
const a = new RegExp("<" + n + ".*?>|<\\/" + n + ">", "gi");
o = o.replace(a, "");
}
return o;
}
function h(e, r = 0) {
return new RegExp(/^\d+$/).test(e) ? Number(e) : r;
}
function L(e) {
const r = /(-?\d+(\.\d+)?)/g, t = e.match(r);
return [e.replace(r, "").trim(), ...(t == null ? void 0 : t.map(Number)) ?? []];
}
function w(e) {
return (e.match(/[a-df-z][^a-df-z]*/ig) || []).map((t) => t.trim());
}
export {
i as dashToLowerCase,
L as decodeStrAndNumber,
w as decodeStrAndNumberGroup,
h as filterNumber,
g as jsonDecode,
f as lowerCaseToLowerDashCase,
d as lowerCaseToUpLineCase,
p as lowerLocaleToISOCode,
U as paddingLeft,
b as removeHtmlTag,
m as removeStartEnd,
C as removeUndefinedValues,
l as stringSplit,
s as toCapitalize,
u as upperLineToLowerCase
};