| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6cb3088 commit 4960a3e
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,50 +1,51 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - var common = require('../common'); | ||
| 3 | - var assert = require('assert'); | ||
| 4 | - var fork = require('child_process').fork; | ||
| 5 | - var net = require('net'); | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const fork = require('child_process').fork; | ||
| 5 | + const net = require('net'); | ||
| 6 | 6 | ||
| 7 | 7 | if (process.argv[2] !== 'child') { | |
| 8 | 8 | console.error('[%d] master', process.pid); | |
| 9 | 9 | ||
| 10 | - var worker = fork(__filename, ['child']); | ||
| 11 | - var called = false; | ||
| 10 | + const worker = fork(__filename, ['child']); | ||
| 11 | + let called = false; | ||
| 12 | 12 | ||
| 13 | - worker.once('message', function(msg, handle) { | ||
| 14 | - assert.equal(msg, 'handle'); | ||
| 13 | + worker.once('message', common.mustCall(function(msg, handle) { | ||
| 14 | + assert.strictEqual(msg, 'handle'); | ||
| 15 | 15 | assert.ok(handle); | |
| 16 | 16 | worker.send('got'); | |
| 17 | 17 | ||
| 18 | 18 | handle.on('data', function(data) { | |
| 19 | 19 | called = true; | |
| 20 | - assert.equal(data.toString(), 'hello'); | ||
| 20 | + assert.strictEqual(data.toString(), 'hello'); | ||
| 21 | 21 | }); | |
| 22 | 22 | ||
| 23 | 23 | handle.on('end', function() { | |
| 24 | 24 | worker.kill(); | |
| 25 | 25 | }); | |
| 26 | - }); | ||
| 26 | + })); | ||
| 27 | 27 | ||
| 28 | 28 | process.once('exit', function() { | |
| 29 | 29 | assert.ok(called); | |
| 30 | 30 | }); | |
| 31 | 31 | } else { | |
| 32 | 32 | console.error('[%d] worker', process.pid); | |
| 33 | 33 | ||
| 34 | - var socket; | ||
| 35 | - var cbcalls = 0; | ||
| 34 | + let socket; | ||
| 35 | + let cbcalls = 0; | ||
| 36 | 36 | function socketConnected() { | |
| 37 | 37 | if (++cbcalls === 2) | |
| 38 | 38 | process.send('handle', socket); | |
| 39 | 39 | } | |
| 40 | 40 | ||
| 41 | - var server = net.createServer(function(c) { | ||
| 42 | - process.once('message', function(msg) { | ||
| 43 | - assert.equal(msg, 'got'); | ||
| 41 | + const server = net.createServer(function(c) { | ||
| 42 | + process.once('message', common.mustCall(function(msg) { | ||
| 43 | + assert.strictEqual(msg, 'got'); | ||
| 44 | 44 | c.end('hello'); | |
| 45 | - }); | ||
| 45 | + })); | ||
| 46 | 46 | socketConnected(); | |
| 47 | 47 | }); | |
| 48 | + | ||
| 48 | 49 | server.listen(common.PORT, function() { | |
| 49 | 50 | socket = net.connect(common.PORT, '127.0.0.1', socketConnected); | |
| 50 | 51 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments