| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8fae9d4 commit 55377db
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,33 +1,30 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - require('../common'); | ||
| 3 | - var assert = require('assert'); | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | 4 | ||
| 5 | - var stream = require('stream'); | ||
| 6 | - var PassThrough = stream.PassThrough; | ||
| 5 | + const stream = require('stream'); | ||
| 6 | + const PassThrough = stream.PassThrough; | ||
| 7 | 7 | ||
| 8 | - var src = new PassThrough({ objectMode: true }); | ||
| 9 | - var tx = new PassThrough({ objectMode: true }); | ||
| 10 | - var dest = new PassThrough({ objectMode: true }); | ||
| 8 | + const src = new PassThrough({ objectMode: true }); | ||
| 9 | + const tx = new PassThrough({ objectMode: true }); | ||
| 10 | + const dest = new PassThrough({ objectMode: true }); | ||
| 11 | 11 | ||
| 12 | - var expect = [ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; | ||
| 13 | - var results = []; | ||
| 14 | - process.on('exit', function() { | ||
| 15 | - assert.deepStrictEqual(results, expect); | ||
| 16 | - console.log('ok'); | ||
| 17 | - }); | ||
| 12 | + const expect = [ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; | ||
| 13 | + const results = []; | ||
| 18 | 14 | ||
| 19 | - dest.on('data', function(x) { | ||
| 15 | + dest.on('data', common.mustCall(function(x) { | ||
| 20 | 16 | results.push(x); | |
| 21 | - }); | ||
| 17 | + }, expect.length)); | ||
| 22 | 18 | ||
| 23 | 19 | src.pipe(tx).pipe(dest); | |
| 24 | 20 | ||
| 25 | - var i = -1; | ||
| 26 | - var int = setInterval(function() { | ||
| 27 | - if (i > 10) { | ||
| 21 | + let i = -1; | ||
| 22 | + const int = setInterval(common.mustCall(function() { | ||
| 23 | + if (results.length === expect.length) { | ||
| 28 | 24 | src.end(); | |
| 29 | 25 | clearInterval(int); | |
| 26 | + assert.deepStrictEqual(results, expect); | ||
| 30 | 27 | } else { | |
| 31 | 28 | src.write(i++); | |
| 32 | 29 | } | |
| 33 | - }); | ||
| 30 | + }, expect.length + 1), 1); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments