MCPcopy Create free account
hub / github.com/breck7/scroll / formatGroup

Function formatGroup

external/.d3.js:9507–9524  ·  view source on GitHub ↗
(grouping, thousands)

Source from the content-addressed store, hash-verified

9505}
9506
9507function formatGroup(grouping, thousands) {
9508 return function(value, width) {
9509 var i = value.length,
9510 t = [],
9511 j = 0,
9512 g = grouping[0],
9513 length = 0;
9514
9515 while (i > 0 && g > 0) {
9516 if (length + g + 1 > width) g = Math.max(1, width - length);
9517 t.push(value.substring(i -= g, i + g));
9518 if ((length += g + 1) > width) break;
9519 g = grouping[j = (j + 1) % grouping.length];
9520 }
9521
9522 return t.reverse().join(thousands);
9523 };
9524}
9525
9526function formatNumerals(numerals) {
9527 return function(value) {

Callers 1

formatLocale$1Function · 0.85

Calls 3

maxMethod · 0.80
reverseMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected