You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/string/format/README.md
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,9 @@ var out = format( str, 'world', 'Bob' );
48
48
49
49
The format string is a string literal containing zero or more conversion specifications, each of which results in a string value being inserted to the output string. A conversion specification consists of a percent sign (`%`) followed by one or more of the following flags, width, precision, and conversion type characters. It thus takes the following form:
50
50
51
-
%[flags][width][.precision]specifier
51
+
```text
52
+
%[flags][width][.precision]specifier
53
+
```
52
54
53
55
Arguments following the format string are used to replace the placeholders in the format string. The number of arguments following the format string should be equal to the number of placeholders in the format string.
54
56
@@ -60,7 +62,9 @@ var out = format( str, 'Hello', 'World' );
60
62
61
63
To supply arguments in a different order than they appear in the format string, positional placeholders as indicated by a `$` character in the format string are used. In this case, the conversion specification takes the form:
62
64
63
-
%[pos$][flags][width][.precision]specifier
65
+
```text
66
+
%[pos$][flags][width][.precision]specifier
67
+
```
64
68
65
69
```javascript
66
70
var str ='%3$s %2$s %1$s';
@@ -176,7 +180,7 @@ out = format( str, 5, 2 );
176
180
The `precision` may be specified as a decimal integer or as an asterisk character (`*`), in which case the argument preceding the conversion specification is used as the precision value. The behavior of the `precision` differs depending on the conversion type:
177
181
178
182
- For `s` specifiers, the `precision` specifies the maximum number of characters to be written to the output.
179
-
- For floating point specifiers (`f`, `F`, `e`, `E`), the `precision` specifies the number of digits after the decimal point to be written to the output (by default, this is `6).
183
+
- For floating point specifiers (`f`, `F`, `e`, `E`), the `precision` specifies the number of digits after the decimal point to be written to the output (by default, this is `6`).
180
184
- For `g` and `G` specifiers, the `precision` specifies the maximum number of significant digits to be written to the output.
181
185
- For integer specifiers (`d`, `i`, `u`, `b`, `o`, `x`, `X`), the `precision` specifies the minimum number of digits to be written to the output. If the value to be written is shorter than this number, the result is padded with zeros on the left. The value is not truncated even if the result is longer. For
0 commit comments