| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent bb6f944 commit fabc489
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -162,19 +162,22 @@ const assert = require('assert'); | |||
| 162 | 162 | const http = require('http'); | |
| 163 | 163 | ||
| 164 | 164 | let request = 0; | |
| 165 | + let listening = 0; | ||
| 165 | 166 | let response = 0; | |
| 166 | - process.on('exit', function() { | ||
| 167 | + process.on('exit', () => { | ||
| 167 | 168 | assert.equal(request, 1, 'http server "request" callback was not called'); | |
| 169 | + assert.equal(listening, 1, 'http server "listening" callback was not called'); | ||
| 168 | 170 | assert.equal(response, 1, 'http request "response" callback was not called'); | |
| 169 | 171 | }); | |
| 170 | 172 | ||
| 171 | 173 | const server = http.createServer((req, res) => { | |
| 172 | 174 | request++; | |
| 173 | 175 | res.end(); | |
| 174 | - }).listen(0, function() { | ||
| 176 | + }).listen(0, () => { | ||
| 177 | + listening++; | ||
| 175 | 178 | const options = { | |
| 176 | 179 | agent: null, | |
| 177 | - port: this.address().port | ||
| 180 | + port: server.address().port | ||
| 178 | 181 | }; | |
| 179 | 182 | http.get(options, (res) => { | |
| 180 | 183 | response++; | |
@@ -193,16 +196,16 @@ const http = require('http'); | |||
| 193 | 196 | ||
| 194 | 197 | const server = http.createServer(common.mustCall((req, res) => { | |
| 195 | 198 | res.end(); | |
| 196 | - })).listen(0, function() { | ||
| 199 | + })).listen(0, common.mustCall(() => { | ||
| 197 | 200 | const options = { | |
| 198 | 201 | agent: null, | |
| 199 | - port: this.address().port | ||
| 202 | + port: server.address().port | ||
| 200 | 203 | }; | |
| 201 | 204 | http.get(options, common.mustCall((res) => { | |
| 202 | 205 | res.resume(); | |
| 203 | 206 | server.close(); | |
| 204 | 207 | })); | |
| 205 | - }); | ||
| 208 | + })); | ||
| 206 | 209 | ||
| 207 | 210 | ``` | |
| 208 | 211 | ||
@@ -216,7 +219,7 @@ shutting down an HTTP server after a specific number of requests). | |||
| 216 | 219 | ```javascript | |
| 217 | 220 | const Countdown = require('../common/countdown'); | |
| 218 | 221 | ||
| 219 | - const countdown = new Countdown(2, function() { | ||
| 222 | + const countdown = new Countdown(2, () => { | ||
| 220 | 223 | console.log('.'); | |
| 221 | 224 | }); | |
| 222 | 225 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments