* Copied from src/util/number.ts
(x, precision, returnStr)
| 3241 | * Copied from src/util/number.ts |
| 3242 | */ |
| 3243 | function round(x, precision, returnStr) { |
| 3244 | if (precision == null) { |
| 3245 | precision = 10; |
| 3246 | } |
| 3247 | // Avoid range error |
| 3248 | precision = Math.min(Math.max(0, precision), ROUND_SUPPORTED_PRECISION_MAX); |
| 3249 | // PENDING: 1.005.toFixed(2) is '1.00' rather than '1.01' |
| 3250 | x = (+x).toFixed(precision); |
| 3251 | return (returnStr ? x : +x); |
| 3252 | } |
| 3253 | // Although chrome already enlarge this number to 100 for `toFixed`, but |
| 3254 | // we sill follow the spec for compatibility. |
| 3255 | var ROUND_SUPPORTED_PRECISION_MAX = 20; |
no test coverage detected
searching dependent graphs…