Skip to content

Commit 59e348c

Browse files
committed
fixup! util: add numericSeparator to util.inspect
Signed-off-by: Ruben Bridgewater <[email protected]>
1 parent fbf660a commit 59e348c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

doc/api/util.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,8 @@ changes:
610610
This might cause side effects depending on the getter function.
611611
**Default:** `false`.
612612
* `numericSeparator` {boolean} If set to `true`, an underscore is used to
613-
separate thousands in all bigints and numbers. **Default:** `false`.
613+
separate every three digits in all bigints and numbers.
614+
**Default:** `false`.
614615
* Returns: {string} The representation of `object`.
615616

616617
The `util.inspect()` method returns a string representation of `object` that is
@@ -759,6 +760,21 @@ assert.strict.equal(
759760
);
760761
```
761762

763+
The `numericSeparator` option adds an underscore every three digits to all
764+
numbers.
765+
766+
```js
767+
const { inspect } = require('util');
768+
769+
const thousand = 1_000;
770+
const million = 1_000_000;
771+
const bigNumber = 123_456_789n;
772+
const bigDecimal = 1_234.123_45
773+
774+
console.log(thousand, million, bigNumber, bigDecimal);
775+
// 1_000 1_000_000 123_456_789n 1_234.123_45
776+
```
777+
762778
`util.inspect()` is a synchronous method intended for debugging. Its maximum
763779
output length is approximately 128 MB. Inputs that result in longer output will
764780
be truncated.

0 commit comments

Comments
 (0)