MCPcopy Create free account
hub / github.com/d3/d3-format / formatSpecifier

Function formatSpecifier

src/formatSpecifier.js:4–19  ·  view source on GitHub ↗
(specifier)

Source from the content-addressed store, hash-verified

2var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
3
4export default function formatSpecifier(specifier) {
5 if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier);
6 var match;
7 return new FormatSpecifier({
8 fill: match[1],
9 align: match[2],
10 sign: match[3],
11 symbol: match[4],
12 zero: match[5],
13 width: match[6],
14 comma: match[7],
15 precision: match[8] && match[8].slice(1),
16 trim: match[9],
17 type: match[10]
18 });
19}
20
21formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof
22

Callers 3

newFormatFunction · 0.85
formatPrefixFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…