MCPcopy Index your code
hub / github.com/adaltas/node-printf / Formatter

Function Formatter

lib/printf.js:38–42  ·  view source on GitHub ↗
(/*String*/ format)

Source from the content-addressed store, hash-verified

36};
37
38var Formatter = function(/*String*/ format){
39 this._mapped = false;
40 this._format = format;
41 this._tokens = tokenize(format, this._re, this._parseDelim, this);
42};
43
44// The old regexp `/\%(?:\(([\w_.]+)\)|([1-9]\d*)\$)?([0 +\-\#]*)(\*|\d+)?(\.)?(\*|\d+)?[hlL]?([\%bscdeEfFgGioOuxX])/` has a cubic worst-case time complexity behavior due to overlapping capture groups `([0 +\-\#]*)(\*|\d+)?(\.)?(\*|\d+)?`. And a pump string of 0 can be consumed by `([0 +\-\#]*), (\*|\d+)?, or (\*|\d+)?`.
45// The solution replace the sub-regexp (\*|\d+)?(\.)?(\*|\d+)? with the sub-regexp `(\*|\d+)?(?:(\.)(\*|\d+)?)?`, see the figure in [#32](https://github.com/adaltas/node-printf/pull/32)

Callers

nothing calls this directly

Calls 1

tokenizeFunction · 0.85

Tested by

no test coverage detected