-
Notifications
You must be signed in to change notification settings - Fork 113
Open
Labels
5.xNext major of the libraryNext major of the library
Description
In much of this library, we use functions as constructors and add methods to the prototype, using util.inherits
for inheritance
We should probably rework this to use classes now that they're widely available.
For example:
Lines 307 to 318 in cc58a4b
function TestAgent(app) { | |
if (!(this instanceof TestAgent)) return new TestAgent(app); | |
if (typeof app === 'function') app = http.createServer(app); | |
(Agent || Request).call(this); | |
this.app = app; | |
if (typeof app !== 'string' && app && app.listen && app.address && !app.address()) { | |
this.app = app.listen(0) | |
} | |
} | |
util.inherits(TestAgent, Agent || Request); | |
TestAgent.prototype.close = function close(callback) { |
Could be:
class TestAgent extends (Agent || Request) {
constructor(app) {
super();
if (typeof app === 'function') app = http.createServer(app);
this.app = app;
if (typeof app !== 'string' && app && app.listen && app.address && !app.address()) {
this.app = app.listen(0)
}
}
close(callback) {
// ...
}
}
Trickfilm400
Metadata
Metadata
Assignees
Labels
5.xNext major of the libraryNext major of the library