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-writable.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-writable.js')
-rw-r--r-- | test/parallel/test-stream2-writable.js | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/test/parallel/test-stream2-writable.js b/test/parallel/test-stream2-writable.js index 2af3f683a2..712440368c 100644 --- a/test/parallel/test-stream2-writable.js +++ b/test/parallel/test-stream2-writable.js @@ -26,24 +26,23 @@ const W = require('_stream_writable'); const D = require('_stream_duplex'); const assert = require('assert'); -const util = require('util'); -util.inherits(TestWriter, W); - -function TestWriter() { - W.apply(this, arguments); - this.buffer = []; - this.written = 0; +class TestWriter extends W { + constructor(opts) { + super(opts); + this.buffer = []; + this.written = 0; + } + + _write(chunk, encoding, cb) { + // simulate a small unpredictable latency + setTimeout(() => { + this.buffer.push(chunk.toString()); + this.written += chunk.length; + cb(); + }, Math.floor(Math.random() * 10)); + } } -TestWriter.prototype._write = function(chunk, encoding, cb) { - // simulate a small unpredictable latency - setTimeout(function() { - this.buffer.push(chunk.toString()); - this.written += chunk.length; - cb(); - }.bind(this), Math.floor(Math.random() * 10)); -}; - const chunks = new Array(50); for (let i = 0; i < chunks.length; i++) { chunks[i] = 'x'.repeat(i); |