Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: linting errors in example code
  • Loading branch information
dicearr committed Oct 24, 2017
commit 0acc2a38993645721eec0068045c62f9bf2a8d62
28 changes: 14 additions & 14 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -1519,26 +1519,26 @@ regressions. The following is an example of how to achieve that extending
[Writable][].

```js
const { Writable } = require('stream')
const { StringDecoder } = require('string_decoder')
const { Writable } = require('stream');
const { StringDecoder } = require('string_decoder');

class StringWritable extends Writable {
constructor (options) {
super(options)
const state = this._writableState
this._decoder = new StringDecoder(state.defaultEncoding)
this._data = ''
constructor(options) {
super(options);
const state = this._writableState;
this._decoder = new StringDecoder(state.defaultEncoding);
this._data = '';
}
_write (chunk, encoding, callback) {
_write(chunk, encoding, callback) {
if (encoding === 'buffer') {
chunk = this._decoder.write(chunk)
chunk = this._decoder.write(chunk);
}
this._data += chunk
callback()
this._data += chunk;
callback();
}
_final (callback) {
this._data += this._decoder.end()
callback()
_final(callback) {
this._data += this._decoder.end();
callback();
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be good to add a quick example on how to use this.

```
Expand Down