package jscompat
Import Path
github.com/d2lang/mathjax-go/internal/jscompat (on go.dev)
Dependency Relation
imports 4 packages, and imported by 4 packages
Involved Source Files
Package jscompat implements JavaScript numeric behavior that is observable
in MathJax 3.2.2's SVG output.
Package-Level Functions (total 7)
Fixed reproduces CommonOutputJax.fixed(): values close to zero collapse to
"0", and trailing fractional zeroes are removed.
NumberStep forces an intermediate float64 rounding point. It prevents the Go
compiler from fusing operations that JavaScript evaluates separately.
NumberString formats a float64 as ECMAScript String(Number) for the finite
and non-finite values observable in MathJax's serialization paths.
Round implements ECMAScript Math.round, including negative zero for values
in [-0.5, 0).
ToFixed implements Number.prototype.toFixed for 0 through 100 fraction
digits. Unlike strconv's fixed formatting, ECMAScript resolves an exact tie
toward the larger integer after operating on the Number's exact binary
value. That difference is visible for values such as 2.5.
TrimFixed removes the trailing zeroes and optional decimal point in a
toFixed result, as MathJax does with /\.?0+$/. It is exported for the SVG
output package's other fixed-precision helpers.
TruthyNumber reports JavaScript truthiness for a Number.
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |