Skip to content

Commit

Permalink
Run build script
Browse files Browse the repository at this point in the history
(oops i forgot)
  • Loading branch information
xShadowBlade committed Aug 17, 2024
1 parent 026c3a8 commit 655359b
Show file tree
Hide file tree
Showing 12 changed files with 653 additions and 226 deletions.
157 changes: 113 additions & 44 deletions dist/game/eMath.game.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/game/eMath.game.min.js

Large diffs are not rendered by default.

157 changes: 113 additions & 44 deletions dist/game/eMath.game.mjs

Large diffs are not rendered by default.

157 changes: 119 additions & 38 deletions dist/main/eMath.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/main/eMath.min.js

Large diffs are not rendered by default.

157 changes: 119 additions & 38 deletions dist/main/eMath.mjs

Large diffs are not rendered by default.

113 changes: 88 additions & 25 deletions dist/presets/eMath.presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ function decimalFormatGenerator(Decimal2) {
format(value) {
value = new Decimal2(value);
const step = Decimal2.floor(value.div(1e3));
const omegaAmount = Decimal2.floor(step.div(FORMATS2.omega.config.greek.length));
const omegaAmount = Decimal2.floor(
step.div(FORMATS2.omega.config.greek.length)
);
let lastLetter = FORMATS2.omega.config.greek[step.toNumber() % FORMATS2.omega.config.greek.length] + toSubscript(value.toNumber() % 1e3);
const beyondGreekArrayBounds = FORMATS2.omega.config.greek[step.toNumber() % FORMATS2.omega.config.greek.length] === void 0;
if (beyondGreekArrayBounds || step.toNumber() > Number.MAX_SAFE_INTEGER) {
Expand Down Expand Up @@ -228,7 +230,9 @@ function decimalFormatGenerator(Decimal2) {
format(value) {
value = new Decimal2(value);
const step = Decimal2.floor(value.div(1e3));
const omegaAmount = Decimal2.floor(step.div(FORMATS2.omega_short.config.greek.length));
const omegaAmount = Decimal2.floor(
step.div(FORMATS2.omega_short.config.greek.length)
);
let lastLetter = FORMATS2.omega_short.config.greek[step.toNumber() % FORMATS2.omega_short.config.greek.length] + toSubscript(value.toNumber() % 1e3);
const beyondGreekArrayBounds = FORMATS2.omega_short.config.greek[step.toNumber() % FORMATS2.omega_short.config.greek.length] === void 0;
if (beyondGreekArrayBounds || step.toNumber() > Number.MAX_SAFE_INTEGER) {
Expand All @@ -254,6 +258,7 @@ function decimalFormatGenerator(Decimal2) {
elemental: {
config: {
/** The list of elements */
/* eslint-disable prettier/prettier */
element_lists: [
["H"],
["He", "Li", "Be", "B", "C", "N", "O", "F"],
Expand Down Expand Up @@ -368,6 +373,7 @@ function decimalFormatGenerator(Decimal2) {
],
["Og"]
]
/* eslint-enable prettier/prettier */
},
getOffset(group) {
if (group == 1) return 1;
Expand Down Expand Up @@ -399,11 +405,20 @@ function decimalFormatGenerator(Decimal2) {
getAbbreviationAndValue(x) {
const abbreviationListUnfloored = x.log(118).toNumber();
const abbreviationListIndex = Math.floor(abbreviationListUnfloored) + 1;
const abbreviationLength = FORMATS2.elemental.abbreviationLength(abbreviationListIndex);
const abbreviationLength = FORMATS2.elemental.abbreviationLength(
abbreviationListIndex
);
const abbreviationProgress = abbreviationListUnfloored - abbreviationListIndex + 1;
const abbreviationIndex = Math.floor(abbreviationProgress * abbreviationLength);
const abbreviation = FORMATS2.elemental.getAbbreviation(abbreviationListIndex, abbreviationProgress);
const value = new Decimal2(118).pow(abbreviationListIndex + abbreviationIndex / abbreviationLength - 1);
const abbreviationIndex = Math.floor(
abbreviationProgress * abbreviationLength
);
const abbreviation = FORMATS2.elemental.getAbbreviation(
abbreviationListIndex,
abbreviationProgress
);
const value = new Decimal2(118).pow(
abbreviationListIndex + abbreviationIndex / abbreviationLength - 1
);
return [abbreviation, value];
},
formatElementalPart(abbreviation, n) {
Expand All @@ -413,7 +428,12 @@ function decimalFormatGenerator(Decimal2) {
return `${n.toString()} ${abbreviation}`;
},
format(value, acc = 2) {
if (value.gt(new Decimal2(118).pow(new Decimal2(118).pow(new Decimal2(118).pow(4))))) return "e" + FORMATS2.elemental.format(value.log10(), acc);
if (value.gt(
new Decimal2(118).pow(
new Decimal2(118).pow(new Decimal2(118).pow(4))
)
))
return "e" + FORMATS2.elemental.format(value.log10(), acc);
let log = value.log(118);
const slog = log.log(118);
const sslog = slog.log(118).toNumber();
Expand All @@ -426,7 +446,12 @@ function decimalFormatGenerator(Decimal2) {
parts.unshift([abbreviation, n]);
}
if (parts.length >= max) {
return parts.map((x) => FORMATS2.elemental.formatElementalPart(x[0], x[1])).join(" + ");
return parts.map(
(x) => (
// @ts-expect-error - x has both string and decimal for some reason
FORMATS2.elemental.formatElementalPart(x[0], x[1])
)
).join(" + ");
}
const formattedMantissa = new Decimal2(118).pow(log).toFixed(parts.length === 1 ? 3 : acc);
if (parts.length === 0) {
Expand Down Expand Up @@ -488,7 +513,9 @@ function decimalFormatGenerator(Decimal2) {
return (slog.gte(1e9) ? "" : Decimal2.dTen.pow(slog.sub(slog.floor())).toFixed(4)) + "F" + FORMATS2.eng.format(slog.floor(), 0);
}
const m = ex.div(new Decimal2(1e3).pow(e.div(3).floor()));
return (e.log10().gte(9) ? "" : m.toFixed(new Decimal2(4).sub(e.sub(e.div(3).floor().mul(3))).toNumber())) + "e" + FORMATS2.eng.format(e.div(3).floor().mul(3), 0);
return (e.log10().gte(9) ? "" : m.toFixed(
new Decimal2(4).sub(e.sub(e.div(3).floor().mul(3))).toNumber()
)) + "e" + FORMATS2.eng.format(e.div(3).floor().mul(3), 0);
}
}
},
Expand All @@ -513,12 +540,25 @@ function decimalFormatGenerator(Decimal2) {
},
/** Layer format */
layer: {
layers: ["infinity", "eternity", "reality", "equality", "affinity", "celerity", "identity", "vitality", "immunity", "atrocity"],
layers: [
"infinity",
"eternity",
"reality",
"equality",
"affinity",
"celerity",
"identity",
"vitality",
"immunity",
"atrocity"
],
format(ex, acc = 2, max) {
ex = new Decimal2(ex);
const layer = ex.max(1).log10().max(1).log(INFINITY_NUM.log10()).floor();
if (layer.lte(0)) return format(ex, acc, max, "sc");
ex = Decimal2.dTen.pow(ex.max(1).log10().div(INFINITY_NUM.log10().pow(layer)).sub(layer.gte(1) ? 1 : 0));
ex = Decimal2.dTen.pow(
ex.max(1).log10().div(INFINITY_NUM.log10().pow(layer)).sub(layer.gte(1) ? 1 : 0)
);
const meta = layer.div(10).floor();
const layer_id = layer.toNumber() % 10 - 1;
return format(ex, Math.max(4, acc), max, "sc") + " " + (meta.gte(1) ? "meta" + (meta.gte(2) ? "^" + format(meta, 0, max, "sc") : "") + "-" : "") + (isNaN(layer_id) ? "nanity" : FORMATS2.layer.layers[layer_id]);
Expand Down Expand Up @@ -564,8 +604,10 @@ function decimalFormatGenerator(Decimal2) {
meta++;
}
if (meta == 0) return format(ex, acc, max, "sc");
if (ex.gte(3)) return symbols2[meta] + symbols[meta] + "\u03C9^" + format(ex.sub(1), acc, max, "sc");
if (ex.gte(2)) return symbols2[meta] + "\u03C9" + symbols[meta] + "-" + format(inf.pow(ex.sub(2)), acc, max, "sc");
if (ex.gte(3))
return symbols2[meta] + symbols[meta] + "\u03C9^" + format(ex.sub(1), acc, max, "sc");
if (ex.gte(2))
return symbols2[meta] + "\u03C9" + symbols[meta] + "-" + format(inf.pow(ex.sub(2)), acc, max, "sc");
return symbols2[meta] + symbols[meta] + "-" + format(inf.pow(ex.sub(1)), acc, max, "sc");
}
},
Expand Down Expand Up @@ -610,7 +652,10 @@ function decimalFormatGenerator(Decimal2) {
} else {
const trunc = numLetters.sub(abbStart).add(1);
const truncExponent = exponent.div(Decimal2.pow(alphabetLength + 1, trunc.sub(1))).floor();
const truncLetters = convertToLetters(truncExponent, new Decimal2(abbStart));
const truncLetters = convertToLetters(
truncExponent,
new Decimal2(abbStart)
);
letters = `${truncLetters}(${trunc.gt("1e9") ? trunc.format() : trunc.format(0)})`;
}
return letters;
Expand All @@ -632,7 +677,12 @@ function decimalFormatGenerator(Decimal2) {
ex = new Decimal2(ex);
start = new Decimal2(start).div(1e3);
if (ex.lt(start.mul(1e3))) return format(ex, acc, max, type);
const letters = FORMATS2.alphabet.getAbbreviation(ex, start, startDouble, abbStart);
const letters = FORMATS2.alphabet.getAbbreviation(
ex,
start,
startDouble,
abbStart
);
const mantissa = ex.div(Decimal2.pow(1e3, ex.log(1e3).floor()));
const isAbbreviation = letters.length > (abbStart ?? 9) + 2;
return `${!isAbbreviation ? mantissa.toFixed(acc) + " " : ""}${letters}`;
Expand All @@ -646,7 +696,9 @@ function decimalFormatGenerator(Decimal2) {
return value.toFixed(0).split("").map((x) => x === "-" ? "\u208B" : SUBSCRIPT_NUMBERS[parseInt(x, 10)]).join("");
}
function toSuperscript(value) {
return value.toFixed(0).split("").map((x) => x === "-" ? "\u208B" : SUPERSCRIPT_NUMBERS[parseInt(x, 10)]).join("");
return value.toFixed(0).split("").map(
(x) => x === "-" ? "\u208B" : SUPERSCRIPT_NUMBERS[parseInt(x, 10)]
).join("");
}
function formatST(ex, acc = 2, max = 9, type = "st") {
return format(ex, acc, max, type);
Expand All @@ -664,7 +716,9 @@ function decimalFormatGenerator(Decimal2) {
case "scientific": {
if (ex.log10().lt(Math.min(-acc, 0)) && acc > 1) {
const e2 = ex.log10().ceil();
const m = ex.div(e2.eq(-1) ? new Decimal2(0.1) : Decimal2.dTen.pow(e2));
const m = ex.div(
e2.eq(-1) ? new Decimal2(0.1) : Decimal2.dTen.pow(e2)
);
const be = e2.mul(-1).max(1).log10().gte(9);
return neg + (be ? "" : m.toFixed(2)) + "e" + format(e2, 0, max, "mixed_sc");
} else if (e.lt(max)) {
Expand All @@ -684,13 +738,16 @@ function decimalFormatGenerator(Decimal2) {
case "standard": {
let e3 = ex.log(1e3).floor();
if (e3.lt(1)) {
return neg + ex.toFixed(Math.max(Math.min(acc - e.toNumber(), acc), 0));
return neg + ex.toFixed(
Math.max(Math.min(acc - e.toNumber(), acc), 0)
);
}
const e3_mul = e3.mul(3);
const ee = e3.log10().floor();
if (ee.gte(3e3)) return "e" + format(e, acc, max, "st");
let final = "";
if (e3.lt(4)) final = ["", "K", "M", "B"][Math.round(e3.toNumber())];
if (e3.lt(4))
final = ["", "K", "M", "B"][Math.round(e3.toNumber())];
else {
let ee3 = Math.floor(e3.log(1e3).toNumber());
if (ee3 < 100) ee3 = Math.max(ee3 - 1, 0);
Expand All @@ -700,8 +757,10 @@ function decimalFormatGenerator(Decimal2) {
const mod1000 = e3.sub(div1000.mul(1e3)).floor().toNumber();
if (mod1000 > 0) {
if (mod1000 == 1 && !ee3) final = "U";
if (ee3) final = FORMATS2.standard.tier2(ee3) + (final ? "-" + final : "");
if (mod1000 > 1) final = FORMATS2.standard.tier1(mod1000) + final;
if (ee3)
final = FORMATS2.standard.tier2(ee3) + (final ? "-" + final : "");
if (mod1000 > 1)
final = FORMATS2.standard.tier1(mod1000) + final;
}
e3 = div1000;
ee3++;
Expand All @@ -712,7 +771,8 @@ function decimalFormatGenerator(Decimal2) {
return neg + (ee.gte(10) ? "" : m.toFixed(fixedAmt) + " ") + final;
}
default:
if (!FORMATS2[type]) console.error(`Invalid format type "`, type, `"`);
if (!FORMATS2[type])
console.error(`Invalid format type "`, type, `"`);
return neg + FORMATS2[type].format(ex, acc, max);
}
}
Expand All @@ -730,9 +790,12 @@ function decimalFormatGenerator(Decimal2) {
}
function formatTime(ex, acc = 2, type = "s") {
ex = new Decimal2(ex);
if (ex.gte(86400)) return format(ex.div(86400).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(86400), acc, "d");
if (ex.gte(3600) || type == "d") return (ex.div(3600).gte(10) || type != "d" ? "" : "0") + format(ex.div(3600).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(3600), acc, "h");
if (ex.gte(60) || type == "h") return (ex.div(60).gte(10) || type != "h" ? "" : "0") + format(ex.div(60).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(60), acc, "m");
if (ex.gte(86400))
return format(ex.div(86400).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(86400), acc, "d");
if (ex.gte(3600) || type == "d")
return (ex.div(3600).gte(10) || type != "d" ? "" : "0") + format(ex.div(3600).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(3600), acc, "h");
if (ex.gte(60) || type == "h")
return (ex.div(60).gte(10) || type != "h" ? "" : "0") + format(ex.div(60).floor(), 0, 12, "sc") + ":" + formatTime(ex.mod(60), acc, "m");
return (ex.gte(10) || type != "m" ? "" : "0") + format(ex, acc, 12, "sc");
}
function formatTimeLong(ex, ms = false, acc = 0, max = 9, type = "mixed_sc") {
Expand Down
Loading

0 comments on commit 655359b

Please sign in to comment.