diff options
author | Tobias Nießen <tniessen@tnie.de> | 2017-11-10 19:18:12 +0100 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-11-12 10:29:45 -0800 |
commit | 3fe165ace6723b1446994574a5197bb70d9a6c72 (patch) | |
tree | bec4ec690231e7c71a3d5a9dacbf10ff9b7e189e /test/parallel/test-stream2-compatibility.js | |
parent | c5a49e148d3293eb9e8c17a15cb8c876977f76af (diff) | |
download | android-node-v8-3fe165ace6723b1446994574a5197bb70d9a6c72.tar.gz android-node-v8-3fe165ace6723b1446994574a5197bb70d9a6c72.tar.bz2 android-node-v8-3fe165ace6723b1446994574a5197bb70d9a6c72.zip |
test: use ES6 classes instead of util.inherits
PR-URL: https://github.com/nodejs/node/pull/16938
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Diffstat (limited to 'test/parallel/test-stream2-compatibility.js')
-rw-r--r-- | test/parallel/test-stream2-compatibility.js | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/test/parallel/test-stream2-compatibility.js b/test/parallel/test-stream2-compatibility.js index 45834ee99e..bd0314ec1a 100644 --- a/test/parallel/test-stream2-compatibility.js +++ b/test/parallel/test-stream2-compatibility.js @@ -25,25 +25,23 @@ const R = require('_stream_readable'); const W = require('_stream_writable'); const assert = require('assert'); -const util = require('util'); - let ondataCalled = 0; -function TestReader() { - R.apply(this); - this._buffer = Buffer.alloc(100, 'x'); - - this.on('data', function() { - ondataCalled++; - }); -} +class TestReader extends R { + constructor() { + super(); + this._buffer = Buffer.alloc(100, 'x'); -util.inherits(TestReader, R); + this.on('data', () => { + ondataCalled++; + }); + } -TestReader.prototype._read = function(n) { - this.push(this._buffer); - this._buffer = Buffer.alloc(0); -}; + _read(n) { + this.push(this._buffer); + this._buffer = Buffer.alloc(0); + } +} const reader = new TestReader(); setImmediate(function() { @@ -52,17 +50,17 @@ setImmediate(function() { reader.push(null); }); -function TestWriter() { - W.apply(this); - this.write('foo'); - this.end(); -} - -util.inherits(TestWriter, W); +class TestWriter extends W { + constructor() { + super(); + this.write('foo'); + this.end(); + } -TestWriter.prototype._write = function(chunk, enc, cb) { - cb(); -}; + _write(chunk, enc, cb) { + cb(); + } +} const writer = new TestWriter(); |