Improve Math.Trunc code emit on JS, had weird whitespaces and indents (#12549)

This commit is contained in:
Juan Carlos 2019-10-30 10:12:17 -03:00 • committed by Andreas Rumpf
commit b5bb581642

View file

@ -758,13 +758,13 @@ else:
# Workaround for IE, IE up to version 11 lacks 'Math.trunc'. We produce # Workaround for IE, IE up to version 11 lacks 'Math.trunc'. We produce
# 'Math.trunc' for Nim's ``div`` and ``mod`` operators: # 'Math.trunc' for Nim's ``div`` and ``mod`` operators:
when not defined(nodejs): const jsMathTrunc = """
{.emit: """ if (!Math.trunc) {
if (!Math.trunc) { Math.trunc = function(v) {
Math.trunc = function(v) { v = +v;
v = +v; if (!isFinite(v)) return v;
if (!isFinite(v)) return v; return (v - v % 1) || (v < 0 ? -0 : v === 0 ? v : 0);
};
return (v - v % 1) || (v < 0 ? -0 : v === 0 ? v : 0); }
}; """
}""".} when not defined(nodejs): {.emit: jsMathTrunc .}