New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@univerjs/engine-numfmt

Package Overview
Dependencies
Maintainers
0
Versions
265
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@univerjs/engine-numfmt - npm Package Compare versions

Comparing version 0.1.15 to 0.1.16

380

lib/es/index.js

@@ -12,4 +12,3 @@ var Ke = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};

var K = { d: function(t, e) {
for (var n in e)
K.o(e, n) && !K.o(t, n) && Object.defineProperty(t, n, { enumerable: !0, get: e[n] });
for (var n in e) K.o(e, n) && !K.o(t, n) && Object.defineProperty(t, n, { enumerable: !0, get: e[n] });
}, o: function(t, e) {

@@ -25,9 +24,7 @@ return Object.prototype.hasOwnProperty.call(t, e);

const e = pe.exec(t);
if (!e)
throw new SyntaxError("Malformed locale: ".concat(t));
if (!e) throw new SyntaxError("Malformed locale: ".concat(t));
return { lang: e[1] + (e[2] ? "_" + e[2] : ""), language: e[1], territory: e[2] || "", codeset: e[3] || "", modifier: e[4] || "" };
}
function ae(t) {
if (typeof t == "number")
return q[65535 & t] || null;
if (typeof t == "number") return q[65535 & t] || null;
const e = parseInt(t, 16);

@@ -54,6 +51,4 @@ return isFinite(e) && q[65535 & e] ? q[65535 & e] || null : pe.test(t) ? t : null;

function E(t, e) {
if (typeof t != "number")
return t;
if (t < 0)
return -E(-t, e);
if (typeof t != "number") return t;
if (t < 0) return -E(-t, e);
if (e) {

@@ -69,12 +64,8 @@ const n = 10 ** (e || 0) || 1;

let o, i, a = Math.abs(t), c = 0, g = 0, l = 0, h = 1;
if ((t = a) % 1 == 0)
i = [t * r, 1];
else if (t < 1e-19)
i = [r, 1e19];
else if (t > 1e19)
i = [1e19 * r, 1];
if ((t = a) % 1 == 0) i = [t * r, 1];
else if (t < 1e-19) i = [r, 1e19];
else if (t > 1e19) i = [1e19 * r, 1];
else {
do
if (a = 1 / (a - Math.floor(a)), o = h, h = h * Math.floor(a) + c, c = o, g = l, l = Math.floor(t * h + 0.5), l >= s || h >= u)
return [r * g, c];
if (a = 1 / (a - Math.floor(a)), o = h, h = h * Math.floor(a) + c, c = o, g = l, l = Math.floor(t * h + 0.5), l >= s || h >= u) return [r * g, c];
while (Math.abs(t - l / h) >= 1e-10 && a !== Math.floor(a));

@@ -88,7 +79,6 @@ i = [r * l, h];

if (t === null && (t = Q), t) {
for (const e in t)
if (e in Q) {
const n = t[e];
he[e] = n == null ? Q[e] : n;
}
for (const e in t) if (e in Q) {
const n = t[e];
he[e] = n == null ? Q[e] : n;
}
}

@@ -122,9 +112,6 @@ return { ...he };

for (; r && !u; ) {
if (a = /^General/i.exec(r))
n.general = !0, S({ type: "general" }, e);
else if (s === "int" && (a = /^[#?0]+(?:,[#?0]+)*/.exec(r)) || s === "den" && (a = /^[#?\d]+/.exec(r)) || (a = /^[#?0]+/.exec(r)))
n[s + "_pattern"].push(a[0]), o = { type: s, num: a[0] }, S(o, e);
if (a = /^General/i.exec(r)) n.general = !0, S({ type: "general" }, e);
else if (s === "int" && (a = /^[#?0]+(?:,[#?0]+)*/.exec(r)) || s === "den" && (a = /^[#?\d]+/.exec(r)) || (a = /^[#?0]+/.exec(r))) n[s + "_pattern"].push(a[0]), o = { type: s, num: a[0] }, S(o, e);
else if ((a = /^\//.exec(r)) && n[s + "_pattern"].length) {
if (!o)
throw new SyntaxError("Missing a numerator in pattern ".concat(t));
if (!o) throw new SyntaxError("Missing a numerator in pattern ".concat(t));
n.fractions = !0, n.num_pattern.push(n[s + "_pattern"].pop()), o.type = "num", s = "den", S({ type: "div" }, e);

@@ -139,29 +126,18 @@ } else if (a = /^,+/.exec(r)) {

}
if (a = /^[@+-]/.exec(r))
a[0] === "@" && (n.text = !0), S({ type: Ye[a[0]] }, e);
if (a = /^[@+-]/.exec(r)) a[0] === "@" && (n.text = !0), S({ type: Ye[a[0]] }, e);
else if (a = /^(?:\[(h+|m+|s+)\])/i.exec(r)) {
const d = a[1].toLowerCase(), f = d[0], _ = { type: "", size: 0, date: 1, raw: a[0], pad: d.length };
f === "h" ? (_.size = 16, _.type = "hour-elap") : f === "m" ? (_.size = 32, _.type = "min-elap") : (_.size = 64, _.type = "sec-elap"), n.date = n.date | _.size, i.push(_), S(_, e);
} else if (a = /^(?:B2)/i.exec(r))
g || (n.date_system = 6);
else if (a = /^(?:B1)/i.exec(r))
g || (n.date_system = 1);
} else if (a = /^(?:B2)/i.exec(r)) g || (n.date_system = 6);
else if (a = /^(?:B1)/i.exec(r)) g || (n.date_system = 1);
else if (a = /^(?:([hHmMsSyYbBdDegG])\1*)/.exec(r)) {
const d = { type: "", size: 0, date: 1, raw: a[0] }, f = a[0].toLowerCase(), _ = f[0];
if (f === "y" || f === "yy")
d.size = 2, d.type = "year-short";
else if (_ === "y" || _ === "e")
d.size = 2, d.type = "year";
else if (f === "b" || f === "bb")
d.size = 2, d.type = "b-year-short";
else if (_ === "b")
d.size = 2, d.type = "b-year";
else if (f === "d" || f === "dd")
d.size = 8, d.type = "day", d.pad = /dd/.test(f);
else if (f === "ddd")
d.size = 8, d.type = "weekday-short";
else if (_ === "d")
d.size = 8, d.type = "weekday";
else if (_ === "h")
d.size = 16, d.type = "hour", d.pad = /hh/i.test(f);
if (f === "y" || f === "yy") d.size = 2, d.type = "year-short";
else if (_ === "y" || _ === "e") d.size = 2, d.type = "year";
else if (f === "b" || f === "bb") d.size = 2, d.type = "b-year-short";
else if (_ === "b") d.size = 2, d.type = "b-year";
else if (f === "d" || f === "dd") d.size = 8, d.type = "day", d.pad = /dd/.test(f);
else if (f === "ddd") d.size = 8, d.type = "weekday-short";
else if (_ === "d") d.size = 8, d.type = "weekday";
else if (_ === "h") d.size = 16, d.type = "hour", d.pad = /hh/i.test(f);
else if (_ === "m") {

@@ -177,11 +153,8 @@ f.length === 3 ? (d.size = 4, d.type = "monthname-short") : f.length === 5 ? (d.size = 4, d.type = "monthname-single") : f.length >= 4 && (d.size = 4, d.type = "monthname");

n.date = n.date | d.size, n.date_eval = !0, i.push(d), S(d, e);
} else if (a = /^(?:AM\/PM|am\/pm|A\/P)/.exec(r))
n.clock = 12, n.date = 16 | n.date, n.date_eval = !0, S({ type: "am", short: a[0] === "A/P" }, e);
} else if (a = /^(?:AM\/PM|am\/pm|A\/P)/.exec(r)) n.clock = 12, n.date = 16 | n.date, n.date_eval = !0, S({ type: "am", short: a[0] === "A/P" }, e);
else if (n.date && (a = /^\.0{1,3}/i.exec(r))) {
const d = a[0].length - 1, f = [64, 128, 256, 512][d];
n.date = n.date | f, n.date_eval = !0, n.sec_decimals = Math.max(n.sec_decimals, d), S({ type: "subsec", size: f, decimals: d, date: 1, raw: a[0] }, e);
} else if ((a = /^\\(.)/.exec(r)) || (a = /^"([^"]*?)"/.exec(r)))
S(a[1], e);
else if (a = /^\[(<[=>]?|>=?|=)\s*(-?[.\d]+)\]/.exec(r))
n.condition = [a[1], parseFloat(a[2], 10)];
} else if ((a = /^\\(.)/.exec(r)) || (a = /^"([^"]*?)"/.exec(r))) S(a[1], e);
else if (a = /^\[(<[=>]?|>=?|=)\s*(-?[.\d]+)\]/.exec(r)) n.condition = [a[1], parseFloat(a[2], 10)];
else if (a = /^\[\$([^\]]+)\]/.exec(r)) {

@@ -194,16 +167,10 @@ const d = a[1].split("-"), f = d.length < 2 ? "" : d[d.length - 1], _ = d[0];

isFinite(k) && 16711680 & k && (k >> 16 & 255) === 6 && (n.date_system = 6), g = !0;
} else if (a = /^\[(black|blue|cyan|green|magenta|red|white|yellow|color\s*(\d+))\]/i.exec(r))
n.color = a[2] ? Te[parseInt(a[2], 10)] || "#000" : a[1].toLowerCase();
} else if (a = /^\[(black|blue|cyan|green|magenta|red|white|yellow|color\s*(\d+))\]/i.exec(r)) n.color = a[2] ? Te[parseInt(a[2], 10)] || "#000" : a[1].toLowerCase();
else if (!(a = /^\[(DBNum1|ENG|HIJ|JPN|TWN)\]/i.exec(r))) {
if (a = /^%/.exec(r))
n.scale = 100, n.percent = !0, S("%", e);
else if (a = /^_(\\.|.)/.exec(r))
S(" ", e);
else if (a = /^\./.exec(r))
S({ type: "point", value: a[0] }, e), n.dec_fractions = !0, s = "frac";
else if (a = /^[Ee]([+-]?|(?=[0#?]))/.exec(r))
n.exponential = !0, n.exp_plus = a[1] === "+", s = "man", S({ type: "exp", plus: a[1] === "+" }, e);
if (a = /^%/.exec(r)) n.scale = 100, n.percent = !0, S("%", e);
else if (a = /^_(\\.|.)/.exec(r)) S(" ", e);
else if (a = /^\./.exec(r)) S({ type: "point", value: a[0] }, e), n.dec_fractions = !0, s = "frac";
else if (a = /^[Ee]([+-]?|(?=[0#?]))/.exec(r)) n.exponential = !0, n.exp_plus = a[1] === "+", s = "man", S({ type: "exp", plus: a[1] === "+" }, e);
else if (!(a = /^\*(\\.|.)/.exec(r))) {
if (a = /^[BENn[]/.exec(r))
throw new SyntaxError("Unexpected char ".concat(r.charAt(0), " in pattern ").concat(t));
if (a = /^[BENn[]/.exec(r)) throw new SyntaxError("Unexpected char ".concat(r.charAt(0), " in pattern ").concat(t));
r[0] === "(" && (n.parens = !0), a = [r[0]], S(a[0], e);

@@ -215,4 +182,3 @@ }

}
if (n.pattern = t.slice(0, t.length - r.length), /^((?:\[[^\]]+\])+)(;|$)/.test(n.pattern) && !/^\[(?:h+|m+|s+)\]/.test(n.pattern) && S({ type: "text" }, e), n.fractions && n.dec_fractions || n.fractions && n.exponential)
throw new SyntaxError("Invalid pattern: ".concat(n.pattern));
if (n.pattern = t.slice(0, t.length - r.length), /^((?:\[[^\]]+\])+)(;|$)/.test(n.pattern) && !/^\[(?:h+|m+|s+)\]/.test(n.pattern) && S({ type: "text" }, e), n.fractions && n.dec_fractions || n.fractions && n.exponential) throw new SyntaxError("Invalid pattern: ".concat(n.pattern));
const l = n.int_pattern.join("");

@@ -222,4 +188,3 @@ if (n.grouping = l.indexOf(",") >= 0, n.grouping) {

f === 2 ? (n.group_pri = d[1].length, n.group_sec = n.group_pri) : f > 2 && (n.group_pri = d[f - 1].length, n.group_sec = d[f - 2].length);
} else
n.group_pri = 0, n.group_sec = 0;
} else n.group_pri = 0, n.group_sec = 0;
B(l.replace(/[,]/g, ""), n, "int"), B(n.frac_pattern.join(""), n, "frac"), B(n.man_pattern.join(""), n, "man");

@@ -241,7 +206,5 @@ let h = n.num_pattern.join(""), b = n.den_pattern.join("");

do {
if (i = L(u), (i.date || i.general) && (i.int_pattern.length || i.frac_pattern.length || i.scale !== 1 || i.text))
throw new Error("Illegal format");
if (i = L(u), (i.date || i.general) && (i.int_pattern.length || i.frac_pattern.length || i.scale !== 1 || i.text)) throw new Error("Illegal format");
if (i.condition && (c++, r = !0), i.text) {
if (s)
throw new Error("Unexpected partition");
if (s) throw new Error("Unexpected partition");
s = i;

@@ -251,9 +214,6 @@ }

} while (o && a < 4 && c < 3);
if (o)
throw new Error("Unexpected partition");
if (c > 2)
throw new Error("Unexpected condition");
if (o) throw new Error("Unexpected partition");
if (c > 2) throw new Error("Unexpected condition");
const g = e[3];
if (g && (g.int_pattern.length || g.frac_pattern.length || g.date))
throw new Error("Unexpected partition");
if (g && (g.int_pattern.length || g.frac_pattern.length || g.date)) throw new Error("Unexpected partition");
if (r) {

@@ -263,4 +223,3 @@ const l = e.length;

const h = e[0], b = e[1];
if (ue(h), b.condition)
ue(b);
if (ue(h), b.condition) ue(b);
else {

@@ -270,8 +229,5 @@ const y = h.condition;

}
} else
e.forEach(ue);
} else e.forEach(ue);
} else {
if (e.length < 4 && s)
for (let l = 0, h = e.length; l < h; l++)
e[l] === s && e.splice(l, 1);
if (e.length < 4 && s) for (let l = 0, h = e.length; l < h; l++) e[l] === s && e.splice(l, 1);
if (e.length < 1 && s && (e[0] = L("General"), e[0].generated = !0), e.length < 2) {

@@ -285,9 +241,7 @@ const l = L(e[0].pattern);

}
if (e.length < 4)
if (s)
e.push(s);
else {
const l = L("@");
l.generated = !0, e.push(l);
}
if (e.length < 4) if (s) e.push(s);
else {
const l = L("@");
l.generated = !0, e.push(l);
}
e[0].condition = [">", 0], e[1].condition = ["<", 0], e[2].condition = null;

@@ -300,8 +254,5 @@ }

if ((!(arguments.length > 1 && arguments[1] !== void 0) || arguments[1]) && t >= 0) {
if (t === 0)
return [1900, 1, 0];
if (t === 60)
return [1900, 2, 29];
if (t < 60)
return [1900, t < 32 ? 1 : 2, (t - 1) % 31 + 1];
if (t === 0) return [1900, 1, 0];
if (t === 60) return [1900, 2, 29];
if (t < 60) return [1900, t < 32 ? 1 : 2, (t - 1) % 31 + 1];
}

@@ -322,8 +273,5 @@ let n = t + 68569 + 2415019;

function Pe(t) {
if (t === 60)
throw new Error("#VALUE!");
if (t <= 1)
return [1317, 8, 29];
if (t < 60)
return [1317, t < 32 ? 9 : 10, 1 + (t - 2) % 30];
if (t === 60) throw new Error("#VALUE!");
if (t <= 1) return [1317, 8, 29];
if (t < 60) return [1317, t < 32 ? 9 : 10, 1 + (t - 2) % 30];
const e = 10631 / 30, n = 0.1335;

@@ -384,6 +332,4 @@ let r = t + 466935;

const s = 0 | n;
if (typeof n == "string")
t.push(n);
else if (n === s)
t.push(Math.abs(s));
if (typeof n == "string") t.push(n);
else if (n === s) t.push(Math.abs(s));
else {

@@ -396,4 +342,3 @@ const u = Math.abs(n);

const h = Math.abs(g);
if (!h)
return Re;
if (!h) return Re;
const b = l && g < 0 ? 1 : 0, y = Math.floor(h), d = Math.floor(Math.log10(h) + 1);

@@ -426,10 +371,7 @@ let f = 0, _ = 0;

t.push($(g, r));
} else if (Math.abs(o) <= 9)
if (a.total <= 11) {
const g = E(u, 9).toFixed(a.frac);
t.push($(g, r));
} else
o === 9 ? t.push(Math.floor(u)) : o >= 0 && o < 9 ? t.push(E(u, 9 - o)) : c();
else
a.total >= 12 ? c() : Math.floor(u) === u ? t.push(Math.floor(u)) : t.push($(E(u, 9).toFixed(a.frac), r));
} else if (Math.abs(o) <= 9) if (a.total <= 11) {
const g = E(u, 9).toFixed(a.frac);
t.push($(g, r));
} else o === 9 ? t.push(Math.floor(u)) : o >= 0 && o < 9 ? t.push(E(u, 9 - o)) : c();
else a.total >= 12 ? c() : Math.floor(u) === u ? t.push(Math.floor(u)) : t.push($(E(u, 9).toFixed(a.frac), r));
}

@@ -447,4 +389,3 @@ return t;

if (!e.text && isFinite(e.scale) && e.scale !== 1 && (t = function(v) {
if (v === 0)
return v;
if (v === 0) return v;
const x = Math.ceil(Math.log10(v < 0 ? -v : v)), m = 10 ** (16 - Math.floor(x));

@@ -466,4 +407,3 @@ return Math.round(v * m) / m;

let v = "", x = a.length;
for (x > e.group_pri && (x -= e.group_pri, v = M.group + a.slice(x, x + e.group_pri) + v); x > e.group_sec; )
x -= e.group_sec, v = M.group + a.slice(x, x + e.group_sec) + v;
for (x > e.group_pri && (x -= e.group_pri, v = M.group + a.slice(x, x + e.group_pri) + v); x > e.group_sec; ) x -= e.group_sec, v = M.group + a.slice(x, x + e.group_sec) + v;
a = x ? a.slice(0, x) + v : v;

@@ -475,9 +415,7 @@ }

const v = Math.abs(e.integer ? t % 1 : t);
if (v)
if (D = !0, isFinite(e.denominator))
o += e.denominator, u += E(v * e.denominator), u === "0" && (u = "", o = "", D = !1, a || (a = "0"));
else {
const x = ge(v, e.integer ? e.num_max : 1 / 0, e.den_max);
u += x[0], o += x[1], e.integer && u === "0" && (a || (a = "0"), u = "", o = "", D = !1);
}
if (v) if (D = !0, isFinite(e.denominator)) o += e.denominator, u += E(v * e.denominator), u === "0" && (u = "", o = "", D = !1, a || (a = "0"));
else {
const x = ge(v, e.integer ? e.num_max : 1 / 0, e.den_max);
u += x[0], o += x[1], e.integer && u === "0" && (a || (a = "0"), u = "", o = "", D = !1);
}
}

@@ -500,4 +438,3 @@ if (e.date) {

if (d = (6 + g) % 7, e.date_eval && (I = t, U = g + l / W, n.dateSpanLarge ? I < -694324 || U >= 35830291 : I < 0 || U >= 2958466)) {
if (n.dateErrorThrows)
throw new Error("Date out of bounds");
if (n.dateErrorThrows) throw new Error("Date out of bounds");
return n.dateErrorNumber ? ve(t < 0 ? [M.negative] : [], 0, t, M).join("") : n.overflow;

@@ -516,60 +453,37 @@ }

const m = e.tokens[v], ne = m.num ? m.num.length : 0;
if (m.type === "string")
m.rule ? m.rule === "num" ? D ? p.push(m.value) : (e.num_min > 0 || e.den_min > 0) && p.push(m.value.replace(/./g, Y["?"])) : m.rule === "num+int" ? D && a ? p.push(m.value) : e.den_min > 0 && (a || e.num_min) && p.push(m.value.replace(/./g, Y["?"])) : m.rule === "den" && (D ? p.push(m.value) : (e.den_min > 0 || e.den_min > 0) && p.push(m.value.replace(/./g, Y["?"]))) : p.push(m.value);
else if (m.type === "error")
p.push(n.invalid);
else if (m.type === "point")
p.push(e.date ? m.value : M.decimal);
else if (m.type === "general")
ve(p, 0, t, M);
else if (m.type === "exp")
p.push(M.exponent);
else if (m.type === "minus")
m.volatile && e.date || m.volatile && (t >= 0 || typeof t != "number") || (m.volatile && !e.fractions && (e.integer || e.dec_fractions) ? (t < 0 && a && a !== "0" || i) && p.push(M.negative) : p.push(M.negative));
else if (m.type === "plus")
p.push(M.positive);
else if (m.type === "text")
p.push(t);
else if (m.type === "div")
D ? p.push("/") : e.num_min > 0 || e.den_min > 0 ? p.push(Y["?"]) : p.push(Y["#"]);
else if (m.type === "int")
if (e.int_pattern.length === 1)
p.push(a);
else {
const w = A ? e.int_pattern.join("").length - O.int : 1 / 0, G = A === e.int_pattern.length - 1 ? 0 : e.int_pattern.join("").length - (O.int + m.num.length);
p.push(a.substring(a.length - w, a.length - G)), A++, O.int += m.num.length;
}
if (m.type === "string") m.rule ? m.rule === "num" ? D ? p.push(m.value) : (e.num_min > 0 || e.den_min > 0) && p.push(m.value.replace(/./g, Y["?"])) : m.rule === "num+int" ? D && a ? p.push(m.value) : e.den_min > 0 && (a || e.num_min) && p.push(m.value.replace(/./g, Y["?"])) : m.rule === "den" && (D ? p.push(m.value) : (e.den_min > 0 || e.den_min > 0) && p.push(m.value.replace(/./g, Y["?"]))) : p.push(m.value);
else if (m.type === "error") p.push(n.invalid);
else if (m.type === "point") p.push(e.date ? m.value : M.decimal);
else if (m.type === "general") ve(p, 0, t, M);
else if (m.type === "exp") p.push(M.exponent);
else if (m.type === "minus") m.volatile && e.date || m.volatile && (t >= 0 || typeof t != "number") || (m.volatile && !e.fractions && (e.integer || e.dec_fractions) ? (t < 0 && a && a !== "0" || i) && p.push(M.negative) : p.push(M.negative));
else if (m.type === "plus") p.push(M.positive);
else if (m.type === "text") p.push(t);
else if (m.type === "div") D ? p.push("/") : e.num_min > 0 || e.den_min > 0 ? p.push(Y["?"]) : p.push(Y["#"]);
else if (m.type === "int") if (e.int_pattern.length === 1) p.push(a);
else {
const w = A ? e.int_pattern.join("").length - O.int : 1 / 0, G = A === e.int_pattern.length - 1 ? 0 : e.int_pattern.join("").length - (O.int + m.num.length);
p.push(a.substring(a.length - w, a.length - G)), A++, O.int += m.num.length;
}
else if (m.type === "frac") {
const w = O.frac;
for (let G = 0; G < ne; G++)
p.push(i[G + w] || Y[m.num[G]]);
for (let G = 0; G < ne; G++) p.push(i[G + w] || Y[m.num[G]]);
O.frac += ne;
} else if (m.type in Me)
e[m.type + "_pattern"].length === 1 ? (m.type === "int" && p.push(a), m.type === "frac" && p.push(i), m.type === "man" && p.push(s), m.type === "num" && p.push(u), m.type === "den" && p.push(o)) : (p.push(Me[m.type].slice(O[m.type], O[m.type] + ne)), O[m.type] += ne);
else if (m.type === "year")
h < 0 && p.push(M.negative), p.push(String(Math.abs(h)).padStart(4, "0"));
} else if (m.type in Me) e[m.type + "_pattern"].length === 1 ? (m.type === "int" && p.push(a), m.type === "frac" && p.push(i), m.type === "man" && p.push(s), m.type === "num" && p.push(u), m.type === "den" && p.push(o)) : (p.push(Me[m.type].slice(O[m.type], O[m.type] + ne)), O[m.type] += ne);
else if (m.type === "year") h < 0 && p.push(M.negative), p.push(String(Math.abs(h)).padStart(4, "0"));
else if (m.type === "year-short") {
const w = h % 100;
p.push(w < 10 ? "0" : "", w);
} else if (m.type === "month")
p.push(m.pad && b < 10 ? "0" : "", b);
else if (m.type === "monthname-single")
e.date_system === 6 ? p.push(M.mmmm6[b - 1].charAt(0)) : p.push(M.mmmm[b - 1].charAt(0));
else if (m.type === "monthname-short")
e.date_system === 6 ? p.push(M.mmm6[b - 1]) : p.push(M.mmm[b - 1]);
else if (m.type === "monthname")
e.date_system === 6 ? p.push(M.mmmm6[b - 1]) : p.push(M.mmmm[b - 1]);
else if (m.type === "weekday-short")
p.push(M.ddd[d]);
else if (m.type === "weekday")
p.push(M.dddd[d]);
else if (m.type === "day")
p.push(m.pad && y < 10 ? "0" : "", y);
} else if (m.type === "month") p.push(m.pad && b < 10 ? "0" : "", b);
else if (m.type === "monthname-single") e.date_system === 6 ? p.push(M.mmmm6[b - 1].charAt(0)) : p.push(M.mmmm[b - 1].charAt(0));
else if (m.type === "monthname-short") e.date_system === 6 ? p.push(M.mmm6[b - 1]) : p.push(M.mmm[b - 1]);
else if (m.type === "monthname") e.date_system === 6 ? p.push(M.mmmm6[b - 1]) : p.push(M.mmmm[b - 1]);
else if (m.type === "weekday-short") p.push(M.ddd[d]);
else if (m.type === "weekday") p.push(M.dddd[d]);
else if (m.type === "day") p.push(m.pad && y < 10 ? "0" : "", y);
else if (m.type === "hour") {
const w = f % e.clock || (e.clock < 24 ? e.clock : 0);
p.push(m.pad && w < 10 ? "0" : "", w);
} else if (m.type === "min")
p.push(m.pad && _ < 10 ? "0" : "", _);
else if (m.type === "sec")
p.push(m.pad && j < 10 ? "0" : "", j);
} else if (m.type === "min") p.push(m.pad && _ < 10 ? "0" : "", _);
else if (m.type === "sec") p.push(m.pad && j < 10 ? "0" : "", j);
else if (m.type === "subsec") {

@@ -594,4 +508,3 @@ p.push(M.decimal);

p.push(String(Math.abs(w)).padStart(m.pad, "0"));
} else if (m.type === "b-year")
p.push(h + 543);
} else if (m.type === "b-year") p.push(h + 543);
else if (m.type === "b-year-short") {

@@ -612,6 +525,4 @@ const w = (h + 543) % 100;

u === "=" ? s = t === o : u === ">" ? s = t > o : u === "<" ? s = t < o : u === ">=" ? s = t >= o : u === "<=" ? s = t <= o : u === "<>" && (s = t !== o);
} else
s = !0;
if (s)
return r;
} else s = !0;
if (s) return r;
}

@@ -625,4 +536,3 @@ }

e[n] = e[n] || {}, N(t.slice(1), e[n]);
} else
e.$ = !0;
} else e.$ = !0;
}

@@ -638,21 +548,16 @@ ["d-F-y", "d-F-Y", "d-M-y", "d-M-Y", "F-d-y", "F-d-Y", "F-j-y", "F-j-Y", "j-F-y", "j-F-Y", "j-M-y", "j-M-Y", "M-d-y", "M-d-Y", "M-j-y", "M-j-Y", "m-d-y", "m-d-Y", "m-j-y", "m-j-Y", "n-d-y", "n-d-Y", "n-j-y", "n-j-Y", "y-F-d", "y-F-j", "y-M-d", "y-M-j", "Y-F-d", "Y-F-j", "Y-M-d", "Y-m-d", "Y-M-j", "Y-m-j", "Y-n-d", "Y-n-j", "j-F", "j-M", "d-F", "d-M", "n-d", "n-j", "n-Y", "m-d", "m-j", "m-Y", "M-Y", "M-y", "F-y", "F-Y", "Y-M", "Y-n", "Y-m", "Y-F", "Y-M"].forEach((t) => {

let i = 1, a = "", c = !1, g = !1, l = !1, h = !1, b = !1, y = null, d = !1, f = parseFloat(r.replace(/,/g, ""));
if (!isFinite(f))
return null;
if (!isFinite(f)) return null;
for (let j = 0; j < n.length; j++) {
const k = n[j];
if (k === "-") {
if (c || g)
return null;
if (c || g) return null;
c = !0, i = -1;
} else if (le.test(k)) {
if (b)
return null;
if (b) return null;
b = !0, y = k;
} else if (k === "(") {
if (g || c)
return null;
if (g || c) return null;
g = !0, i = -1;
} else if (k === "%") {
if (h)
return null;
if (h) return null;
h = !0;

@@ -664,12 +569,9 @@ }

if (le.test(k)) {
if (b)
return null;
if (b) return null;
b = !0, y = k, d = !0;
} else if (k === ")") {
if (l || !g)
return null;
if (l || !g) return null;
l = !0;
} else if (k === "%") {
if (h)
return null;
if (h) return null;
h = !0;

@@ -679,8 +581,6 @@ }

if (u) {
if (h || b)
return null;
if (h || b) return null;
a = "0.00E+00";
} else if (h) {
if (b)
return null;
if (b) return null;
a = s.includes(".") ? "0.00%" : "0%", f *= 0.01;

@@ -690,4 +590,3 @@ } else if (b) {

a = d ? j + y : y + j;
} else
s.includes(",") && (a = s.includes(".") ? "#,##0.00" : "#,##0");
} else s.includes(",") && (a = s.includes(".") ? "#,##0.00" : "#,##0");
const _ = { v: f * i };

@@ -703,4 +602,3 @@ return a && (_.z = a), _;

if (e[i]) {
if (i === "$" || i === "€")
t || (o = n);
if (i === "$" || i === "€") t || (o = n);
else if (i === "-") {

@@ -743,4 +641,3 @@ const a = /^(\s*([./-]|,\s)\s*|\s+)/.exec(t);

} else {
if (i !== "x")
throw new Error('Unknown date token "'.concat(i, '"'));
if (i !== "x") throw new Error('Unknown date token "'.concat(i, '"'));
{

@@ -751,4 +648,3 @@ const a = ce(t);

}
if (o)
return o;
if (o) return o;
}

@@ -761,19 +657,13 @@ }

var r;
if (n.sep === "." && n.path.length === 3)
return null;
if (n.sep === "." && n.path.length === 3) return null;
const s = +((r = n.year) !== null && r !== void 0 ? r : $e);
if (n.day || (n.day = 1), !function(i, a, c) {
if (c < 1 || a < 1 || a > 12)
return !1;
if (c < 1 || a < 1 || a > 12) return !1;
if (a === 2) {
if (c > (i % 4 == 0 && i % 100 != 0 || i % 400 == 0 || i === 1900 ? 29 : 28))
return !1;
} else if ((a === 4 || a === 6 || a === 9 || a === 11) && c > 30 || (a === 1 || a === 3 || a === 5 || a === 7 || a === 8 || a === 10 || a === 12) && c > 31)
return !1;
if (c > (i % 4 == 0 && i % 100 != 0 || i % 400 == 0 || i === 1900 ? 29 : 28)) return !1;
} else if ((a === 4 || a === 6 || a === 9 || a === 11) && c > 30 || (a === 1 || a === 3 || a === 5 || a === 7 || a === 8 || a === 10 || a === 12) && c > 31) return !1;
return !0;
}(s, n.month, n.day))
return null;
}(s, n.month, n.day)) return null;
let u = -1 / 0;
if (s < 1900)
return null;
if (s < 1900) return null;
s <= 1900 && n.month <= 2 ? u = 25568 : s < 1e4 && (u = 25569);

@@ -792,8 +682,6 @@ const o = Date.UTC(s, n.month - 1, n.day) / 864e5 + u + (n.time || 0);

const [, n, r, s, u, o] = e;
if (u && !s || !o && !r && !s)
return null;
if (u && !s || !o && !r && !s) return null;
let i = 1 * (n || 0);
if (o) {
if (i >= 13)
return null;
if (i >= 13) return null;
o[0] !== "p" && o[0] !== "P" || (i += 12);

@@ -817,6 +705,4 @@ }

const y = fe(b.locale), d = h[3] ? h[3] : ze;
if (typeof l == "boolean" && (l = l ? "TRUE" : "FALSE"), l == null)
return "";
if (typeof l != "number")
return xe(l, d, b, y);
if (typeof l == "boolean" && (l = l ? "TRUE" : "FALSE"), l == null) return "";
if (typeof l != "number") return xe(l, d, b, y);
if (!isFinite(l)) {

@@ -831,4 +717,3 @@ const _ = y || ie;

o.color = (a, c) => function(g, l) {
if (typeof g != "number" || !isFinite(g))
return (l[3] ? l[3].color : ze.color) || we;
if (typeof g != "number" || !isFinite(g)) return (l[3] ? l[3].color : ze.color) || we;
const h = Fe(g, l);

@@ -842,6 +727,4 @@ return h && h.color || we;

let f = "G", _ = b >= 0 ? Math.min(15, b) : "", j = "", k = "";
if (h && h.color && (k = "-", y.color = 1), l.parens && (j = "()", y.parentheses = 1), d)
f = "C", y.type = "currency";
else if (l.error)
y.type = "error", y.maxDecimals = 0;
if (h && h.color && (k = "-", y.color = 1), l.parens && (j = "()", y.parentheses = 1), d) f = "C", y.type = "currency";
else if (l.error) y.type = "error", y.maxDecimals = 0;
else if (y.isDate) {

@@ -855,4 +738,3 @@ let M = 0, D = 0, I = "";

f = U ? "D" : "G", _ = U ? U[1] : "";
} else
y.isText ? (f = "G", y.type = "text", _ = "", y.maxDecimals = 0) : l.general ? (f = "G", y.type = "general", _ = "") : l.fractions ? (f = "G", y.type = "fraction", _ = "") : l.exponential ? (f = "S", y.type = "scientific") : y.isPercent ? (f = "P", y.type = "percent") : l.grouping ? (f = ",", y.type = "grouped") : (l.int_max || b) && (f = "F", y.type = "number");
} else y.isText ? (f = "G", y.type = "text", _ = "", y.maxDecimals = 0) : l.general ? (f = "G", y.type = "general", _ = "") : l.fractions ? (f = "G", y.type = "fraction", _ = "") : l.exponential ? (f = "S", y.type = "scientific") : y.isPercent ? (f = "P", y.type = "percent") : l.grouping ? (f = ",", y.type = "grouped") : (l.int_max || b) && (f = "F", y.type = "number");
return y.code = f + _ + k + j, y.level = Le[y.type], Object.freeze(y);

@@ -859,0 +741,0 @@ }(r, (e || {}).currency) || new SyntaxError();

{
"name": "@univerjs/engine-numfmt",
"version": "0.1.15",
"version": "0.1.16",
"private": false,

@@ -48,3 +48,2 @@ "description": "UniverSheet normal plugin UI manager",

],
"peerDependencies": {},
"dependencies": {

@@ -55,5 +54,5 @@ "numfmt": "^2.5.2"

"typescript": "^5.4.5",
"vite": "^5.2.13",
"vite": "^5.3.1",
"vitest": "^1.6.0",
"@univerjs/shared": "0.1.15"
"@univerjs/shared": "0.1.16"
},

@@ -60,0 +59,0 @@ "univerSpace": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc