Skip to content

Commit

Permalink
Merge pull request #3 from blakeembrey/patch-1
Browse files Browse the repository at this point in the history
Remove `boundListener`
  • Loading branch information
pimterry authored Oct 2, 2024
2 parents 8f726e1 + c2fc699 commit caa5c6e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ export class Server extends net.Server {

// We bind the request listener, so 'this' always refers to us, not each subserver.
// This means 'this' is consistent (and this.close() works).
const boundListener = requestListener.bind(this);
// Use `Function.prototype.bind` directly as frameworks like Express generate
// methods from `http.METHODS`, and `BIND` is an included HTTP method.
const boundListener = Function.prototype.bind.call(requestListener, this);

// Create subservers for each supported protocol:
this._httpServer = new http.Server(boundListener);
Expand Down

0 comments on commit caa5c6e

Please sign in to comment.