Improve Math.Trunc code emit on JS, had weird whitespaces and indents (#12549)
This commit is contained in:
parent
34dbc5699e
commit
b5bb581642
1 changed files with 10 additions and 10 deletions
|
|
@ -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 .}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue