source: node_modules/d3-format/src/formatRounded.js@ a762898

Last change on this file since a762898 was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Prototype 1.1

  • Property mode set to 100644
File size: 473 bytes
Line 
1import {formatDecimalParts} from "./formatDecimal.js";
2
3export default function(x, p) {
4 var d = formatDecimalParts(x, p);
5 if (!d) return x + "";
6 var coefficient = d[0],
7 exponent = d[1];
8 return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient
9 : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1)
10 : coefficient + new Array(exponent - coefficient.length + 2).join("0");
11}
Note: See TracBrowser for help on using the repository browser.