mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-27 17:53:58 +00:00
Improve Math.Trunc code emit on JS, had weird whitespaces and indents (#12549)
This commit is contained in:
committed by
Andreas Rumpf
parent
34dbc5699e
commit
b5bb581642
@@ -758,13 +758,13 @@ else:
|
||||
|
||||
# Workaround for IE, IE up to version 11 lacks 'Math.trunc'. We produce
|
||||
# 'Math.trunc' for Nim's ``div`` and ``mod`` operators:
|
||||
when not defined(nodejs):
|
||||
{.emit: """
|
||||
if (!Math.trunc) {
|
||||
Math.trunc = function(v) {
|
||||
v = +v;
|
||||
if (!isFinite(v)) return v;
|
||||
|
||||
return (v - v % 1) || (v < 0 ? -0 : v === 0 ? v : 0);
|
||||
};
|
||||
}""".}
|
||||
const jsMathTrunc = """
|
||||
if (!Math.trunc) {
|
||||
Math.trunc = function(v) {
|
||||
v = +v;
|
||||
if (!isFinite(v)) return v;
|
||||
return (v - v % 1) || (v < 0 ? -0 : v === 0 ? v : 0);
|
||||
};
|
||||
}
|
||||
"""
|
||||
when not defined(nodejs): {.emit: jsMathTrunc .}
|
||||
|
||||
Reference in New Issue
Block a user