We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b8f5a2b commit afbe4d8Copy full SHA for afbe4d8
doc/api/util.md
@@ -165,6 +165,30 @@ stream.on('data', (data) => {
165
stream.write('It works!'); // Received data: "It works!"
166
```
167
168
+ES6 example using `class` and `extends`
169
+
170
+```js
171
+const util = require('util');
172
+const EventEmitter = require('events');
173
174
+class MyStream extends EventEmitter {
175
+ constructor() {
176
+ super();
177
+ }
178
+ write(data) {
179
+ this.emit('data', data);
180
181
+}
182
183
+const stream = new MyStream();
184
185
+stream.on('data', (data) => {
186
+ console.log(`Received data: "${data}"`);
187
+});
188
+stream.write('With ES6');
189
190
+```
191
192
## util.inspect(object[, options])
193
194
* `object` {any} Any JavaScript primitive or Object.
0 commit comments