Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3531043

Browse filesBrowse files
vipinmenongibfahn
authored andcommitted
stream: use arrow fns for 'this' in readable
PR-URL: #16927 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 4d85687 commit 3531043
Copy full SHA for 3531043

File tree

Expand file treeCollapse file tree

1 file changed

+8
-9
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-9
lines changed
Open diff view settings
Collapse file

‎lib/_stream_readable.js‎

Copy file name to clipboardExpand all lines: lib/_stream_readable.js
+8-9Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -853,19 +853,18 @@ Readable.prototype.wrap = function(stream) {
853853
var state = this._readableState;
854854
var paused = false;
855855

856-
var self = this;
857-
stream.on('end', function() {
856+
stream.on('end', () => {
858857
debug('wrapped end');
859858
if (state.decoder && !state.ended) {
860859
var chunk = state.decoder.end();
861860
if (chunk && chunk.length)
862-
self.push(chunk);
861+
this.push(chunk);
863862
}
864863

865-
self.push(null);
864+
this.push(null);
866865
});
867866

868-
stream.on('data', function(chunk) {
867+
stream.on('data', (chunk) => {
869868
debug('wrapped data');
870869
if (state.decoder)
871870
chunk = state.decoder.write(chunk);
@@ -876,7 +875,7 @@ Readable.prototype.wrap = function(stream) {
876875
else if (!state.objectMode && (!chunk || !chunk.length))
877876
return;
878877

879-
var ret = self.push(chunk);
878+
var ret = this.push(chunk);
880879
if (!ret) {
881880
paused = true;
882881
stream.pause();
@@ -897,20 +896,20 @@ Readable.prototype.wrap = function(stream) {
897896

898897
// proxy certain important events.
899898
for (var n = 0; n < kProxyEvents.length; n++) {
900-
stream.on(kProxyEvents[n], self.emit.bind(self, kProxyEvents[n]));
899+
stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
901900
}
902901

903902
// when we try to consume some more bytes, simply unpause the
904903
// underlying stream.
905-
self._read = function(n) {
904+
this._read = (n) => {
906905
debug('wrapped _read', n);
907906
if (paused) {
908907
paused = false;
909908
stream.resume();
910909
}
911910
};
912911

913-
return self;
912+
return this;
914913
};
915914

916915

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.