test: use arrow functions instead of bind
PR-URL: https://github.com/nodejs/node/pull/17070 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Lance Ball <lball@redhat.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Khaidi Chu <i@2333.moe>
This commit is contained in:
parent
bbd95554c0
commit
707cd3f615
@ -36,15 +36,15 @@ class MyStream extends Readable {
|
|||||||
case 0:
|
case 0:
|
||||||
return this.push(null);
|
return this.push(null);
|
||||||
case 1:
|
case 1:
|
||||||
return setTimeout(function() {
|
return setTimeout(() => {
|
||||||
this.push('last chunk');
|
this.push('last chunk');
|
||||||
}.bind(this), 100);
|
}, 100);
|
||||||
case 2:
|
case 2:
|
||||||
return this.push('second to last chunk');
|
return this.push('second to last chunk');
|
||||||
case 3:
|
case 3:
|
||||||
return process.nextTick(function() {
|
return process.nextTick(() => {
|
||||||
this.push('first chunk');
|
this.push('first chunk');
|
||||||
}.bind(this));
|
});
|
||||||
default:
|
default:
|
||||||
throw new Error('?');
|
throw new Error('?');
|
||||||
}
|
}
|
||||||
|
@ -211,14 +211,14 @@ const Transform = require('_stream_transform');
|
|||||||
if (!chunk)
|
if (!chunk)
|
||||||
chunk = '';
|
chunk = '';
|
||||||
const s = chunk.toString();
|
const s = chunk.toString();
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
this.state += s.charAt(0);
|
this.state += s.charAt(0);
|
||||||
if (this.state.length === 3) {
|
if (this.state.length === 3) {
|
||||||
pt.push(Buffer.from(this.state));
|
pt.push(Buffer.from(this.state));
|
||||||
this.state = '';
|
this.state = '';
|
||||||
}
|
}
|
||||||
cb();
|
cb();
|
||||||
}.bind(this), 10);
|
}, 10);
|
||||||
};
|
};
|
||||||
|
|
||||||
pt._flush = function(cb) {
|
pt._flush = function(cb) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user