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 4ca4b54

Browse filesBrowse files
ZYSzystargos
authored andcommitted
test: remove util.inherits() usage
PR-URL: #25245 Refs: #24755 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 1be566b commit 4ca4b54
Copy full SHA for 4ca4b54
Expand file treeCollapse file tree

13 files changed

+38
-31
lines changed
Open diff view settings
Collapse file

‎test/common/arraystream.js‎

Copy file name to clipboardExpand all lines: test/common/arraystream.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
'use strict';
33

44
const { Stream } = require('stream');
5-
const { inherits } = require('util');
65
function noop() {}
76

87
// A stream to push an array into a REPL
@@ -14,7 +13,8 @@ function ArrayStream() {
1413
};
1514
}
1615

17-
inherits(ArrayStream, Stream);
16+
Object.setPrototypeOf(ArrayStream.prototype, Stream.prototype);
17+
Object.setPrototypeOf(ArrayStream, Stream);
1818
ArrayStream.prototype.readable = true;
1919
ArrayStream.prototype.writable = true;
2020
ArrayStream.prototype.pause = noop;
Collapse file

‎test/fixtures/repl-tab-completion-nested-repls.js‎

Copy file name to clipboardExpand all lines: test/fixtures/repl-tab-completion-nested-repls.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
'use strict';
88

99
const { Stream } = require('stream');
10-
const { inherits } = require('util');
1110
function noop() {}
1211

1312
// A stream to push an array into a REPL
@@ -19,7 +18,8 @@ function ArrayStream() {
1918
};
2019
}
2120

22-
inherits(ArrayStream, Stream);
21+
Object.setPrototypeOf(ArrayStream.prototype, Stream.prototype);
22+
Object.setPrototypeOf(ArrayStream, Stream);
2323
ArrayStream.prototype.readable = true;
2424
ArrayStream.prototype.writable = true;
2525
ArrayStream.prototype.pause = noop;
@@ -47,4 +47,4 @@ putIn.run([
4747
]);
4848

4949
// In Node.js 10.11.0, this next line will terminate the repl silently...
50-
testMe.complete('inner.o', () => { throw new Error('fhqwhgads'); });
50+
testMe.complete('inner.o', () => { throw new Error('fhqwhgads'); });
Collapse file

‎test/parallel/test-event-emitter-prepend.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-event-emitter-prepend.js
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,22 @@ common.expectsError(() => {
3131

3232
// Test fallback if prependListener is undefined.
3333
const stream = require('stream');
34-
const util = require('util');
3534

3635
delete EventEmitter.prototype.prependListener;
3736

3837
function Writable() {
3938
this.writable = true;
4039
stream.Stream.call(this);
4140
}
42-
util.inherits(Writable, stream.Stream);
41+
Object.setPrototypeOf(Writable.prototype, stream.Stream.prototype);
42+
Object.setPrototypeOf(Writable, stream.Stream);
4343

4444
function Readable() {
4545
this.readable = true;
4646
stream.Stream.call(this);
4747
}
48-
util.inherits(Readable, stream.Stream);
48+
Object.setPrototypeOf(Readable.prototype, stream.Stream.prototype);
49+
Object.setPrototypeOf(Readable, stream.Stream);
4950

5051
const w = new Writable();
5152
const r = new Readable();
Collapse file

‎test/parallel/test-event-emitter-subclass.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-event-emitter-subclass.js
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
const common = require('../common');
2424
const assert = require('assert');
2525
const EventEmitter = require('events').EventEmitter;
26-
const util = require('util');
2726

28-
util.inherits(MyEE, EventEmitter);
27+
Object.setPrototypeOf(MyEE.prototype, EventEmitter.prototype);
28+
Object.setPrototypeOf(MyEE, EventEmitter);
2929

3030
function MyEE(cb) {
3131
this.once(1, cb);
@@ -38,7 +38,8 @@ const myee = new MyEE(common.mustCall());
3838

3939
myee.hasOwnProperty('usingDomains');
4040

41-
util.inherits(ErrorEE, EventEmitter);
41+
Object.setPrototypeOf(ErrorEE.prototype, EventEmitter.prototype);
42+
Object.setPrototypeOf(ErrorEE, EventEmitter);
4243
function ErrorEE() {
4344
this.emit('error', new Error('blerg'));
4445
}
Collapse file

‎test/parallel/test-http-upgrade-server.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-upgrade-server.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
require('../common');
2525
const assert = require('assert');
2626

27-
const util = require('util');
2827
const net = require('net');
2928
const http = require('http');
3029

@@ -69,7 +68,8 @@ function testServer() {
6968
});
7069
}
7170

72-
util.inherits(testServer, http.Server);
71+
Object.setPrototypeOf(testServer.prototype, http.Server.prototype);
72+
Object.setPrototypeOf(testServer, http.Server);
7373

7474

7575
function writeReq(socket, data, encoding) {
Collapse file

‎test/parallel/test-stream-duplex-destroy.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-duplex-destroy.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
const common = require('../common');
44
const { Duplex } = require('stream');
55
const assert = require('assert');
6-
const { inherits } = require('util');
76

87
{
98
const duplex = new Duplex({
@@ -190,7 +189,8 @@ const { inherits } = require('util');
190189
Duplex.call(this);
191190
}
192191

193-
inherits(MyDuplex, Duplex);
192+
Object.setPrototypeOf(MyDuplex.prototype, Duplex.prototype);
193+
Object.setPrototypeOf(MyDuplex, Duplex);
194194

195195
new MyDuplex();
196196
}
Collapse file

‎test/parallel/test-stream-pipe-cleanup.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-pipe-cleanup.js
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
require('../common');
2626
const stream = require('stream');
2727
const assert = require('assert');
28-
const util = require('util');
2928

3029
function Writable() {
3130
this.writable = true;
3231
this.endCalls = 0;
3332
stream.Stream.call(this);
3433
}
35-
util.inherits(Writable, stream.Stream);
34+
Object.setPrototypeOf(Writable.prototype, stream.Stream.prototype);
35+
Object.setPrototypeOf(Writable, stream.Stream);
3636
Writable.prototype.end = function() {
3737
this.endCalls++;
3838
};
@@ -45,13 +45,15 @@ function Readable() {
4545
this.readable = true;
4646
stream.Stream.call(this);
4747
}
48-
util.inherits(Readable, stream.Stream);
48+
Object.setPrototypeOf(Readable.prototype, stream.Stream.prototype);
49+
Object.setPrototypeOf(Readable, stream.Stream);
4950

5051
function Duplex() {
5152
this.readable = true;
5253
Writable.call(this);
5354
}
54-
util.inherits(Duplex, Writable);
55+
Object.setPrototypeOf(Duplex.prototype, Writable.prototype);
56+
Object.setPrototypeOf(Duplex, Writable);
5557

5658
let i = 0;
5759
const limit = 100;
Collapse file

‎test/parallel/test-stream-pipe-event.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-pipe-event.js
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,20 @@
2323
require('../common');
2424
const stream = require('stream');
2525
const assert = require('assert');
26-
const util = require('util');
2726

2827
function Writable() {
2928
this.writable = true;
3029
stream.Stream.call(this);
3130
}
32-
util.inherits(Writable, stream.Stream);
31+
Object.setPrototypeOf(Writable.prototype, stream.Stream.prototype);
32+
Object.setPrototypeOf(Writable, stream.Stream);
3333

3434
function Readable() {
3535
this.readable = true;
3636
stream.Stream.call(this);
3737
}
38-
util.inherits(Readable, stream.Stream);
38+
Object.setPrototypeOf(Readable.prototype, stream.Stream.prototype);
39+
Object.setPrototypeOf(Readable, stream.Stream);
3940

4041
let passed = false;
4142

Collapse file

‎test/parallel/test-stream-readable-destroy.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-readable-destroy.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
const common = require('../common');
44
const { Readable } = require('stream');
55
const assert = require('assert');
6-
const { inherits } = require('util');
76

87
{
98
const read = new Readable({
@@ -160,7 +159,8 @@ const { inherits } = require('util');
160159
Readable.call(this);
161160
}
162161

163-
inherits(MyReadable, Readable);
162+
Object.setPrototypeOf(MyReadable.prototype, Readable.prototype);
163+
Object.setPrototypeOf(MyReadable, Readable);
164164

165165
new MyReadable();
166166
}
Collapse file

‎test/parallel/test-stream-writable-destroy.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-writable-destroy.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
const common = require('../common');
44
const { Writable } = require('stream');
55
const assert = require('assert');
6-
const { inherits } = require('util');
76

87
{
98
const write = new Writable({
@@ -173,7 +172,8 @@ const { inherits } = require('util');
173172
Writable.call(this);
174173
}
175174

176-
inherits(MyWritable, Writable);
175+
Object.setPrototypeOf(MyWritable.prototype, Writable.prototype);
176+
Object.setPrototypeOf(MyWritable, Writable);
177177

178178
new MyWritable();
179179
}

0 commit comments

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