@danielsimonjr/mathts-expression 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -8
- package/dist/index.js +53 -376
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { NumberTypeConfig } from '@danielsimonjr/mathts-core/internal';
|
|
2
|
+
|
|
1
3
|
type TypedFunction$1 = ((...args: unknown[]) => unknown) & {
|
|
2
4
|
signatures: Record<string, (...args: unknown[]) => unknown>;
|
|
3
5
|
};
|
|
@@ -96,14 +98,6 @@ interface FactoryMeta {
|
|
|
96
98
|
[key: string]: unknown;
|
|
97
99
|
}
|
|
98
100
|
|
|
99
|
-
/**
|
|
100
|
-
* Configuration for number type handling
|
|
101
|
-
*/
|
|
102
|
-
interface NumberTypeConfig {
|
|
103
|
-
number: 'number' | 'BigNumber' | 'bigint' | 'Fraction';
|
|
104
|
-
numberFallback: 'number' | 'BigNumber';
|
|
105
|
-
}
|
|
106
|
-
|
|
107
101
|
type Scope$1 = Map<string, unknown>;
|
|
108
102
|
interface CompiledExpression$1 {
|
|
109
103
|
evaluate: (scope?: Record<string, unknown>) => unknown;
|
package/dist/index.js
CHANGED
|
@@ -100,6 +100,25 @@ var require_dist = __commonJS({
|
|
|
100
100
|
// src/keywords.ts
|
|
101
101
|
var keywords = /* @__PURE__ */ new Set(["end"]);
|
|
102
102
|
|
|
103
|
+
// src/utils/object.ts
|
|
104
|
+
import {
|
|
105
|
+
canDefineProperty,
|
|
106
|
+
clone,
|
|
107
|
+
deepExtend,
|
|
108
|
+
deepFlatten,
|
|
109
|
+
deepStrictEqual,
|
|
110
|
+
extend,
|
|
111
|
+
get,
|
|
112
|
+
hasOwnProperty,
|
|
113
|
+
isLegacyFactory,
|
|
114
|
+
lazy,
|
|
115
|
+
mapObject,
|
|
116
|
+
pick,
|
|
117
|
+
pickShallow,
|
|
118
|
+
set,
|
|
119
|
+
traverse
|
|
120
|
+
} from "@danielsimonjr/mathts-core/internal";
|
|
121
|
+
|
|
103
122
|
// src/utils/is.ts
|
|
104
123
|
function isNumber(x) {
|
|
105
124
|
return typeof x === "number";
|
|
@@ -228,90 +247,6 @@ function typeOf(x) {
|
|
|
228
247
|
return t;
|
|
229
248
|
}
|
|
230
249
|
|
|
231
|
-
// src/utils/object.ts
|
|
232
|
-
function clone(x) {
|
|
233
|
-
const type = typeof x;
|
|
234
|
-
if (type === "number" || type === "bigint" || type === "string" || type === "boolean" || x === null || x === void 0) {
|
|
235
|
-
return x;
|
|
236
|
-
}
|
|
237
|
-
const cloneable = x;
|
|
238
|
-
if (typeof cloneable.clone === "function") {
|
|
239
|
-
return cloneable.clone();
|
|
240
|
-
}
|
|
241
|
-
if (Array.isArray(x)) {
|
|
242
|
-
return x.map((value) => clone(value));
|
|
243
|
-
}
|
|
244
|
-
if (x instanceof Date) return new Date(x.valueOf());
|
|
245
|
-
if (isBigNumber(x)) return x;
|
|
246
|
-
if (isObject(x)) {
|
|
247
|
-
return mapObject(x, clone);
|
|
248
|
-
}
|
|
249
|
-
if (type === "function") {
|
|
250
|
-
return x;
|
|
251
|
-
}
|
|
252
|
-
throw new TypeError(`Cannot clone: unknown type of value (value: ${x})`);
|
|
253
|
-
}
|
|
254
|
-
function mapObject(object, callback) {
|
|
255
|
-
const clone2 = {};
|
|
256
|
-
for (const key in object) {
|
|
257
|
-
if (hasOwnProperty(object, key)) {
|
|
258
|
-
clone2[key] = callback(object[key]);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
return clone2;
|
|
262
|
-
}
|
|
263
|
-
function deepStrictEqual(a, b) {
|
|
264
|
-
if (Array.isArray(a)) {
|
|
265
|
-
if (!Array.isArray(b)) {
|
|
266
|
-
return false;
|
|
267
|
-
}
|
|
268
|
-
if (a.length !== b.length) {
|
|
269
|
-
return false;
|
|
270
|
-
}
|
|
271
|
-
for (let i = 0, len = a.length; i < len; i++) {
|
|
272
|
-
if (!deepStrictEqual(a[i], b[i])) {
|
|
273
|
-
return false;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
return true;
|
|
277
|
-
} else if (typeof a === "function") {
|
|
278
|
-
return a === b;
|
|
279
|
-
} else if (a instanceof Object) {
|
|
280
|
-
if (Array.isArray(b) || !(b instanceof Object)) {
|
|
281
|
-
return false;
|
|
282
|
-
}
|
|
283
|
-
const objA = a;
|
|
284
|
-
const objB = b;
|
|
285
|
-
for (const prop in objA) {
|
|
286
|
-
if (!(prop in objB) || !deepStrictEqual(objA[prop], objB[prop])) {
|
|
287
|
-
return false;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
for (const prop in objB) {
|
|
291
|
-
if (!(prop in objA)) {
|
|
292
|
-
return false;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
return true;
|
|
296
|
-
} else {
|
|
297
|
-
return a === b;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
function hasOwnProperty(object, property) {
|
|
301
|
-
return !!object && Object.hasOwnProperty.call(object, property);
|
|
302
|
-
}
|
|
303
|
-
function pickShallow(object, properties2) {
|
|
304
|
-
const copy = {};
|
|
305
|
-
for (let i = 0; i < properties2.length; i++) {
|
|
306
|
-
const key = properties2[i];
|
|
307
|
-
const value = object[key];
|
|
308
|
-
if (value !== void 0) {
|
|
309
|
-
copy[key] = value;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
return copy;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
250
|
// src/operators.ts
|
|
316
251
|
var properties = [
|
|
317
252
|
{
|
|
@@ -756,291 +691,33 @@ var IndexError = class _IndexError extends RangeError {
|
|
|
756
691
|
};
|
|
757
692
|
|
|
758
693
|
// src/utils/number.ts
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
if (n > 2 ** (size - 1) - 1 || n < -(2 ** (size - 1))) {
|
|
787
|
-
throw new Error(`Value must be in range [-2^${size - 1}, 2^${size - 1}-1]`);
|
|
788
|
-
}
|
|
789
|
-
if (!isInteger(n)) {
|
|
790
|
-
throw new Error("Value must be an integer");
|
|
791
|
-
}
|
|
792
|
-
if (n < 0) {
|
|
793
|
-
n = n + 2 ** size;
|
|
794
|
-
}
|
|
795
|
-
suffix = `i${size}`;
|
|
796
|
-
}
|
|
797
|
-
let sign = "";
|
|
798
|
-
if (n < 0) {
|
|
799
|
-
n = -n;
|
|
800
|
-
sign = "-";
|
|
801
|
-
}
|
|
802
|
-
return `${sign}${prefix}${n.toString(base)}${suffix}`;
|
|
803
|
-
}
|
|
804
|
-
function format(value, options) {
|
|
805
|
-
if (typeof options === "function") {
|
|
806
|
-
return options(value);
|
|
807
|
-
}
|
|
808
|
-
if (value === Infinity) {
|
|
809
|
-
return "Infinity";
|
|
810
|
-
} else if (value === -Infinity) {
|
|
811
|
-
return "-Infinity";
|
|
812
|
-
} else if (isNaN(value)) {
|
|
813
|
-
return "NaN";
|
|
814
|
-
}
|
|
815
|
-
const { notation, precision, wordSize } = normalizeFormatOptions(options);
|
|
816
|
-
switch (notation) {
|
|
817
|
-
case "fixed":
|
|
818
|
-
return toFixed(value, precision);
|
|
819
|
-
case "exponential":
|
|
820
|
-
return toExponential(value, precision);
|
|
821
|
-
case "engineering":
|
|
822
|
-
return toEngineering(value, precision);
|
|
823
|
-
case "bin":
|
|
824
|
-
return formatNumberToBase(value, 2, wordSize);
|
|
825
|
-
case "oct":
|
|
826
|
-
return formatNumberToBase(value, 8, wordSize);
|
|
827
|
-
case "hex":
|
|
828
|
-
return formatNumberToBase(value, 16, wordSize);
|
|
829
|
-
case "auto":
|
|
830
|
-
return toPrecision(value, precision, options).replace(
|
|
831
|
-
/((\.\d*?)(0+))($|e)/,
|
|
832
|
-
function(_match, _g1, digits, _g3, e) {
|
|
833
|
-
return digits !== "." ? digits + e : e;
|
|
834
|
-
}
|
|
835
|
-
);
|
|
836
|
-
default:
|
|
837
|
-
throw new Error(
|
|
838
|
-
'Unknown notation "' + notation + '". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.'
|
|
839
|
-
);
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
function normalizeFormatOptions(options) {
|
|
843
|
-
let notation = "auto";
|
|
844
|
-
let precision;
|
|
845
|
-
let wordSize;
|
|
846
|
-
if (options !== void 0) {
|
|
847
|
-
if (isNumber(options)) {
|
|
848
|
-
precision = options;
|
|
849
|
-
} else if (isBigNumber(options)) {
|
|
850
|
-
precision = options.toNumber();
|
|
851
|
-
} else if (isObject(options)) {
|
|
852
|
-
if (options.precision !== void 0) {
|
|
853
|
-
precision = _toNumberOrThrow(options.precision, () => {
|
|
854
|
-
throw new Error('Option "precision" must be a number or BigNumber');
|
|
855
|
-
});
|
|
856
|
-
}
|
|
857
|
-
if (options.wordSize !== void 0) {
|
|
858
|
-
wordSize = _toNumberOrThrow(options.wordSize, () => {
|
|
859
|
-
throw new Error('Option "wordSize" must be a number or BigNumber');
|
|
860
|
-
});
|
|
861
|
-
}
|
|
862
|
-
if (options.notation) {
|
|
863
|
-
notation = options.notation;
|
|
864
|
-
}
|
|
865
|
-
} else {
|
|
866
|
-
throw new Error("Unsupported type of options, number, BigNumber, or object expected");
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
return { notation, precision, wordSize };
|
|
870
|
-
}
|
|
871
|
-
function splitNumber(value) {
|
|
872
|
-
const match = String(value).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);
|
|
873
|
-
if (!match) {
|
|
874
|
-
throw new SyntaxError("Invalid number " + value);
|
|
875
|
-
}
|
|
876
|
-
const sign = match[1];
|
|
877
|
-
const digits = match[2];
|
|
878
|
-
let exponent = parseFloat(match[4] || "0");
|
|
879
|
-
const dot = digits.indexOf(".");
|
|
880
|
-
exponent += dot !== -1 ? dot - 1 : digits.length - 1;
|
|
881
|
-
const coefficients = digits.replace(".", "").replace(/^0*/, function(zeros2) {
|
|
882
|
-
exponent -= zeros2.length;
|
|
883
|
-
return "";
|
|
884
|
-
}).replace(/0*$/, "").split("").map(function(d) {
|
|
885
|
-
return parseInt(d);
|
|
886
|
-
});
|
|
887
|
-
if (coefficients.length === 0) {
|
|
888
|
-
coefficients.push(0);
|
|
889
|
-
exponent++;
|
|
890
|
-
}
|
|
891
|
-
return { sign, coefficients, exponent };
|
|
892
|
-
}
|
|
893
|
-
function toEngineering(value, precision) {
|
|
894
|
-
if (isNaN(value) || !isFinite(value)) {
|
|
895
|
-
return String(value);
|
|
896
|
-
}
|
|
897
|
-
const split = splitNumber(value);
|
|
898
|
-
const rounded = roundDigits(split, precision);
|
|
899
|
-
const e = rounded.exponent;
|
|
900
|
-
const c = rounded.coefficients;
|
|
901
|
-
const newExp = e % 3 === 0 ? e : e < 0 ? e - 3 - e % 3 : e - e % 3;
|
|
902
|
-
if (isNumber(precision)) {
|
|
903
|
-
while (precision > c.length || e - newExp + 1 > c.length) {
|
|
904
|
-
c.push(0);
|
|
905
|
-
}
|
|
906
|
-
} else {
|
|
907
|
-
const missingZeros = Math.abs(e - newExp) - (c.length - 1);
|
|
908
|
-
for (let i = 0; i < missingZeros; i++) {
|
|
909
|
-
c.push(0);
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
let expDiff = Math.abs(e - newExp);
|
|
913
|
-
let decimalIdx = 1;
|
|
914
|
-
while (expDiff > 0) {
|
|
915
|
-
decimalIdx++;
|
|
916
|
-
expDiff--;
|
|
917
|
-
}
|
|
918
|
-
const decimals = c.slice(decimalIdx).join("");
|
|
919
|
-
const decimalVal = isNumber(precision) && decimals.length || decimals.match(/[1-9]/) ? "." + decimals : "";
|
|
920
|
-
const str = c.slice(0, decimalIdx).join("") + decimalVal + "e" + (e >= 0 ? "+" : "") + newExp.toString();
|
|
921
|
-
return rounded.sign + str;
|
|
922
|
-
}
|
|
923
|
-
function toFixed(value, precision) {
|
|
924
|
-
if (isNaN(value) || !isFinite(value)) {
|
|
925
|
-
return String(value);
|
|
926
|
-
}
|
|
927
|
-
const splitValue = splitNumber(value);
|
|
928
|
-
const rounded = typeof precision === "number" ? roundDigits(splitValue, splitValue.exponent + 1 + precision) : splitValue;
|
|
929
|
-
let c = rounded.coefficients;
|
|
930
|
-
let p = rounded.exponent + 1;
|
|
931
|
-
const pp = p + (precision || 0);
|
|
932
|
-
if (c.length < pp) {
|
|
933
|
-
c = c.concat(zeros(pp - c.length));
|
|
934
|
-
}
|
|
935
|
-
if (p < 0) {
|
|
936
|
-
c = zeros(-p + 1).concat(c);
|
|
937
|
-
p = 1;
|
|
938
|
-
}
|
|
939
|
-
if (p < c.length) {
|
|
940
|
-
c.splice(p, 0, p === 0 ? "0." : ".");
|
|
941
|
-
}
|
|
942
|
-
return rounded.sign + c.join("");
|
|
943
|
-
}
|
|
944
|
-
function toExponential(value, precision) {
|
|
945
|
-
if (isNaN(value) || !isFinite(value)) {
|
|
946
|
-
return String(value);
|
|
947
|
-
}
|
|
948
|
-
const split = splitNumber(value);
|
|
949
|
-
const rounded = precision ? roundDigits(split, precision) : split;
|
|
950
|
-
let c = rounded.coefficients;
|
|
951
|
-
const e = rounded.exponent;
|
|
952
|
-
if (precision && c.length < precision) {
|
|
953
|
-
c = c.concat(zeros(precision - c.length));
|
|
954
|
-
}
|
|
955
|
-
const first = c.shift();
|
|
956
|
-
return rounded.sign + first + (c.length > 0 ? "." + c.join("") : "") + "e" + (e >= 0 ? "+" : "") + e;
|
|
957
|
-
}
|
|
958
|
-
function toPrecision(value, precision, options) {
|
|
959
|
-
if (isNaN(value) || !isFinite(value)) {
|
|
960
|
-
return String(value);
|
|
961
|
-
}
|
|
962
|
-
const lowerExp = _toNumberOrDefault(options?.lowerExp, -3);
|
|
963
|
-
const upperExp = _toNumberOrDefault(options?.upperExp, 5);
|
|
964
|
-
const split = splitNumber(value);
|
|
965
|
-
const rounded = precision ? roundDigits(split, precision) : split;
|
|
966
|
-
if (rounded.exponent < lowerExp || rounded.exponent >= upperExp) {
|
|
967
|
-
return toExponential(value, precision);
|
|
968
|
-
} else {
|
|
969
|
-
let c = rounded.coefficients;
|
|
970
|
-
const e = rounded.exponent;
|
|
971
|
-
if (precision && c.length < precision) {
|
|
972
|
-
c = c.concat(zeros(precision - c.length));
|
|
973
|
-
}
|
|
974
|
-
c = c.concat(
|
|
975
|
-
zeros(e - c.length + 1 + (precision && c.length < precision ? precision - c.length : 0))
|
|
976
|
-
);
|
|
977
|
-
c = zeros(-e).concat(c);
|
|
978
|
-
const dot = e > 0 ? e : 0;
|
|
979
|
-
if (dot < c.length - 1) {
|
|
980
|
-
c.splice(dot + 1, 0, ".");
|
|
981
|
-
}
|
|
982
|
-
return rounded.sign + c.join("");
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
function roundDigits(split, precision) {
|
|
986
|
-
const rounded = {
|
|
987
|
-
sign: split.sign,
|
|
988
|
-
coefficients: split.coefficients.slice(),
|
|
989
|
-
exponent: split.exponent
|
|
990
|
-
};
|
|
991
|
-
const c = rounded.coefficients;
|
|
992
|
-
if (precision !== void 0) {
|
|
993
|
-
while (precision <= 0) {
|
|
994
|
-
c.unshift(0);
|
|
995
|
-
rounded.exponent++;
|
|
996
|
-
precision++;
|
|
997
|
-
}
|
|
998
|
-
if (c.length > precision) {
|
|
999
|
-
const removed = c.splice(precision, c.length - precision);
|
|
1000
|
-
if (removed[0] >= 5) {
|
|
1001
|
-
let i = precision - 1;
|
|
1002
|
-
c[i]++;
|
|
1003
|
-
while (c[i] === 10) {
|
|
1004
|
-
c.pop();
|
|
1005
|
-
if (i === 0) {
|
|
1006
|
-
c.unshift(0);
|
|
1007
|
-
rounded.exponent++;
|
|
1008
|
-
i++;
|
|
1009
|
-
}
|
|
1010
|
-
i--;
|
|
1011
|
-
c[i]++;
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
return rounded;
|
|
1017
|
-
}
|
|
1018
|
-
function zeros(length) {
|
|
1019
|
-
const arr = [];
|
|
1020
|
-
for (let i = 0; i < length; i++) {
|
|
1021
|
-
arr.push(0);
|
|
1022
|
-
}
|
|
1023
|
-
return arr;
|
|
1024
|
-
}
|
|
1025
|
-
function _toNumberOrThrow(value, onError) {
|
|
1026
|
-
if (isNumber(value)) {
|
|
1027
|
-
return value;
|
|
1028
|
-
} else if (isBigNumber(value)) {
|
|
1029
|
-
return value.toNumber();
|
|
1030
|
-
} else {
|
|
1031
|
-
onError();
|
|
1032
|
-
return 0;
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
function _toNumberOrDefault(value, defaultValue) {
|
|
1036
|
-
if (isNumber(value)) {
|
|
1037
|
-
return value;
|
|
1038
|
-
} else if (isBigNumber(value)) {
|
|
1039
|
-
return value.toNumber();
|
|
1040
|
-
} else {
|
|
1041
|
-
return defaultValue;
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
694
|
+
import {
|
|
695
|
+
acosh,
|
|
696
|
+
asinh,
|
|
697
|
+
atanh,
|
|
698
|
+
cbrt,
|
|
699
|
+
copysign,
|
|
700
|
+
cosh,
|
|
701
|
+
digits,
|
|
702
|
+
expm1,
|
|
703
|
+
format,
|
|
704
|
+
isInteger,
|
|
705
|
+
log10,
|
|
706
|
+
log1p,
|
|
707
|
+
log2,
|
|
708
|
+
nearlyEqual,
|
|
709
|
+
normalizeFormatOptions,
|
|
710
|
+
roundDigits,
|
|
711
|
+
safeNumberType,
|
|
712
|
+
sign,
|
|
713
|
+
sinh,
|
|
714
|
+
splitNumber,
|
|
715
|
+
tanh,
|
|
716
|
+
toEngineering,
|
|
717
|
+
toExponential,
|
|
718
|
+
toFixed,
|
|
719
|
+
toPrecision
|
|
720
|
+
} from "@danielsimonjr/mathts-core/internal";
|
|
1044
721
|
|
|
1045
722
|
// src/utils/bignumber/formatter.ts
|
|
1046
723
|
function formatBigNumberToBase(n, base, size) {
|
|
@@ -1099,8 +776,8 @@ function format2(value, options) {
|
|
|
1099
776
|
return formatBigNumberToBase(value, 16, wordSize);
|
|
1100
777
|
case "auto": {
|
|
1101
778
|
const optionsObject = typeof options === "object" ? options : void 0;
|
|
1102
|
-
const lowerExp =
|
|
1103
|
-
const upperExp =
|
|
779
|
+
const lowerExp = _toNumberOrDefault(optionsObject?.lowerExp, -3);
|
|
780
|
+
const upperExp = _toNumberOrDefault(optionsObject?.upperExp, 5);
|
|
1104
781
|
if (value.isZero()) return "0";
|
|
1105
782
|
let str;
|
|
1106
783
|
const rounded = value.toSignificantDigits(precision);
|
|
@@ -1112,8 +789,8 @@ function format2(value, options) {
|
|
|
1112
789
|
}
|
|
1113
790
|
return str.replace(
|
|
1114
791
|
/((\.\d*?)(0+))($|e)/,
|
|
1115
|
-
function(_match, _g1,
|
|
1116
|
-
return
|
|
792
|
+
function(_match, _g1, digits2, _g3, e) {
|
|
793
|
+
return digits2 !== "." ? digits2 + e : e;
|
|
1117
794
|
}
|
|
1118
795
|
);
|
|
1119
796
|
}
|
|
@@ -1144,7 +821,7 @@ function toExponential2(value, precision) {
|
|
|
1144
821
|
function toFixed2(value, precision) {
|
|
1145
822
|
return value.toFixed(precision);
|
|
1146
823
|
}
|
|
1147
|
-
function
|
|
824
|
+
function _toNumberOrDefault(value, defaultValue) {
|
|
1148
825
|
if (isNumber(value)) {
|
|
1149
826
|
return value;
|
|
1150
827
|
} else if (isBigNumber(value)) {
|
|
@@ -7146,9 +6823,9 @@ function numberToMathML(value) {
|
|
|
7146
6823
|
const s = String(value);
|
|
7147
6824
|
const sci = /^(-?)(\d+(?:\.\d+)?)[eE]([+-]?\d+)$/.exec(s);
|
|
7148
6825
|
if (sci) {
|
|
7149
|
-
const
|
|
6826
|
+
const sign2 = sci[1] ? "<mo>-</mo>" : "";
|
|
7150
6827
|
const exp = String(parseInt(sci[3], 10));
|
|
7151
|
-
return `<mrow>${
|
|
6828
|
+
return `<mrow>${sign2}<mn>${sci[2]}</mn><mo>×</mo><msup><mn>10</mn><mn>${exp}</mn></msup></mrow>`;
|
|
7152
6829
|
}
|
|
7153
6830
|
if (value < 0) return `<mrow><mo>-</mo><mn>${escapeMathML(String(-value))}</mn></mrow>`;
|
|
7154
6831
|
return `<mn>${escapeMathML(s)}</mn>`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielsimonjr/mathts-expression",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "Expression parser and evaluator for MathTS",
|
|
5
5
|
"author": "Daniel Simon Jr.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"build:prod": "tsup src/index.ts --format esm --dts --clean --minify --treeshake"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@danielsimonjr/mathts-core": "^0.
|
|
34
|
+
"@danielsimonjr/mathts-core": "^0.4.1",
|
|
35
35
|
"typed-function": "^4.0.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|