Compare commits

...

4 Commits

Author SHA1 Message Date
90d019f92a bump 2024-04-07 12:33:48 +03:00
6fb31be12c fix(debugger): handle all errors when generating description 2024-04-07 12:33:26 +03:00
d6ede0b404 fix: incorrect toFixed behavior 2024-04-03 15:52:01 +03:00
71b40240c0 feat: add Number.toFixed 2024-04-03 15:09:01 +03:00
3 changed files with 13 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
project_group = me.topchetoeu
project_name = jscript
project_version = 0.9.27-beta
project_version = 0.9.38-beta
main_class = me.topchetoeu.jscript.utils.JScriptRepl

View File

@@ -1,5 +1,7 @@
package me.topchetoeu.jscript.lib;
import java.text.NumberFormat;
import me.topchetoeu.jscript.runtime.values.ObjectValue;
import me.topchetoeu.jscript.runtime.values.Values;
import me.topchetoeu.jscript.utils.interop.Arguments;
@@ -85,6 +87,15 @@ public class NumberLib {
@Expose public static String __toString(Arguments args) {
return Values.toString(args.ctx, args.self);
}
@Expose public static String __toFixed(Arguments args) {
var digits = args.getInt(0, 0);
var nf = NumberFormat.getNumberInstance();
nf.setMinimumFractionDigits(digits);
nf.setMaximumFractionDigits(digits);
return nf.format(args.getDouble(-1));
}
@Expose public static double __valueOf(Arguments args) {
if (Values.isWrapper(args.self, NumberLib.class)) return Values.wrapper(args.self, NumberLib.class).value;
else return Values.toNumber(args.ctx, args.self);

View File

@@ -397,7 +397,7 @@ public class SimpleDebugger implements Debugger {
catch (Exception e) { }
try { res.set("description", className + (defaultToString ? "" : " { " + Values.toString(ctx, obj) + " }")); }
catch (EngineException e) { }
catch (Exception e) { }
}