Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: modernize and fix code examples in util.md #13298

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,6 @@ ES6 example using `class` and `extends`
const EventEmitter = require('events');

class MyStream extends EventEmitter {
constructor() {
super();
}
write(data) {
this.emit('data', data);
}
Expand Down Expand Up @@ -329,8 +326,8 @@ class Box {
// Five space padding because that's the size of "Box< ".
const padding = ' '.repeat(5);
const inner = util.inspect(this.value, newOptions)
.replace(/\n/g, '\n' + padding);
return options.stylize('Box', 'special') + '< ' + inner + ' >';
.replace(/\n/g, `\n${padding}`);
return `${options.stylize('Box', 'special')}< ${inner} >`;
}
}

Expand Down Expand Up @@ -392,7 +389,7 @@ option properties directly is also supported.

```js
const util = require('util');
const arr = Array(101);
const arr = Array(101).fill(0);

console.log(arr); // logs the truncated array
util.inspect.defaultOptions.maxArrayLength = null;
Expand Down