| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d0b9be2 commit 837ddcb
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,42 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + // Context: https://github.com/nodejs/node/issues/45992 | ||
| 4 | + | ||
| 5 | + require('../common'); | ||
| 6 | + | ||
| 7 | + const assert = require('assert'); | ||
| 8 | + const fs = require('fs'); | ||
| 9 | + const readline = require('readline'); | ||
| 10 | + | ||
| 11 | + const tmpdir = require('../common/tmpdir'); | ||
| 12 | + | ||
| 13 | + tmpdir.refresh(); | ||
| 14 | + fs.mkdtempSync(`${tmpdir.path}/`); | ||
| 15 | + const path = `${tmpdir.path}/foo`; | ||
| 16 | + const writeStream = fs.createWriteStream(path); | ||
| 17 | + | ||
| 18 | + function write(iteration, callback) { | ||
| 19 | + for (; iteration < 16384; iteration += 1) { | ||
| 20 | + if (!writeStream.write('foo\r\n')) { | ||
| 21 | + writeStream.once('drain', () => write(iteration + 1, callback)); | ||
| 22 | + return; | ||
| 23 | + } | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + writeStream.end(); | ||
| 27 | + callback(); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + write(0, () => { | ||
| 31 | + const input = fs.createReadStream(path); | ||
| 32 | + const rl = readline.createInterface({ input, crlfDelay: Infinity }); | ||
| 33 | + let carriageReturns = 0; | ||
| 34 | + | ||
| 35 | + rl.on('line', (x) => { | ||
| 36 | + if (x.includes('\r')) carriageReturns += 1; | ||
| 37 | + }); | ||
| 38 | + | ||
| 39 | + rl.on('close', () => { | ||
| 40 | + assert.strictEqual(carriageReturns, 0); | ||
| 41 | + }); | ||
| 42 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments