| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 314b04d commit 3686687
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,42 +1,26 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - require('../common'); | ||
| 3 | - var assert = require('assert'); | ||
| 4 | - var net = require('net'); | ||
| 5 | - var revivals = 0; | ||
| 6 | - var deaths = 0; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const net = require('net'); | ||
| 7 | 4 | ||
| 8 | - process.on('beforeExit', function() { deaths++; }); | ||
| 9 | - | ||
| 10 | - process.once('beforeExit', tryImmediate); | ||
| 5 | + process.once('beforeExit', common.mustCall(tryImmediate)); | ||
| 11 | 6 | ||
| 12 | 7 | function tryImmediate() { | |
| 13 | - console.log('set immediate'); | ||
| 14 | - setImmediate(function() { | ||
| 15 | - revivals++; | ||
| 16 | - process.once('beforeExit', tryTimer); | ||
| 17 | - }); | ||
| 8 | + setImmediate(common.mustCall(() => { | ||
| 9 | + process.once('beforeExit', common.mustCall(tryTimer)); | ||
| 10 | + })); | ||
| 18 | 11 | } | |
| 19 | 12 | ||
| 20 | 13 | function tryTimer() { | |
| 21 | - console.log('set a timeout'); | ||
| 22 | - setTimeout(function() { | ||
| 23 | - console.log('timeout cb, do another once beforeExit'); | ||
| 24 | - revivals++; | ||
| 25 | - process.once('beforeExit', tryListen); | ||
| 26 | - }, 1); | ||
| 14 | + setTimeout(common.mustCall(() => { | ||
| 15 | + process.once('beforeExit', common.mustCall(tryListen)); | ||
| 16 | + }), 1); | ||
| 27 | 17 | } | |
| 28 | 18 | ||
| 29 | 19 | function tryListen() { | |
| 30 | - console.log('create a server'); | ||
| 31 | 20 | net.createServer() | |
| 32 | 21 | .listen(0) | |
| 33 | - .on('listening', function() { | ||
| 34 | - revivals++; | ||
| 22 | + .on('listening', common.mustCall(function() { | ||
| 35 | 23 | this.close(); | |
| 36 | - }); | ||
| 24 | + process.on('beforeExit', common.mustCall(() => {})); | ||
| 25 | + })); | ||
| 37 | 26 | } | |
| 38 | - | ||
| 39 | - process.on('exit', function() { | ||
| 40 | - assert.strictEqual(4, deaths); | ||
| 41 | - assert.strictEqual(3, revivals); | ||
| 42 | - }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments