| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,40 +33,43 @@ common.refreshTmpDir(); | |||
| 33 | 33 | ||
| 34 | 34 | fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) { | |
| 35 | 35 | assert.ifError(err); | |
| 36 | - console.log('open done'); | ||
| 37 | - fs.write(fd, '', 0, 'utf8', function(err, written) { | ||
| 38 | - assert.strictEqual(0, written); | ||
| 39 | - }); | ||
| 40 | - fs.write(fd, expected, 0, 'utf8', common.mustCall(function(err, written) { | ||
| 41 | - console.log('write done'); | ||
| 36 | + | ||
| 37 | + const done = common.mustCall(function(err, written) { | ||
| 42 | 38 | assert.ifError(err); | |
| 43 | 39 | assert.strictEqual(Buffer.byteLength(expected), written); | |
| 44 | 40 | fs.closeSync(fd); | |
| 45 | 41 | const found = fs.readFileSync(fn, 'utf8'); | |
| 46 | - console.log('expected: "%s"', expected); | ||
| 47 | - console.log('found: "%s"', found); | ||
| 48 | 42 | fs.unlinkSync(fn); | |
| 49 | 43 | assert.strictEqual(expected, found); | |
| 50 | - })); | ||
| 44 | + }); | ||
| 45 | + | ||
| 46 | + const written = common.mustCall(function(err, written) { | ||
| 47 | + assert.ifError(err); | ||
| 48 | + assert.strictEqual(0, written); | ||
| 49 | + }); | ||
| 50 | + | ||
| 51 | + fs.write(fd, '', 0, 'utf8', written); | ||
| 52 | + fs.write(fd, expected, 0, 'utf8', done); | ||
| 51 | 53 | })); | |
| 52 | 54 | ||
| 55 | + const args = constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC; | ||
| 56 | + fs.open(fn2, args, 0o644, common.mustCall((err, fd) => { | ||
| 57 | + assert.ifError(err); | ||
| 53 | 58 | ||
| 54 | - fs.open(fn2, constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC, 0o644, | ||
| 55 | - common.mustCall((err, fd) => { | ||
| 56 | - assert.ifError(err); | ||
| 57 | - console.log('open done'); | ||
| 58 | - fs.write(fd, '', 0, 'utf8', (err, written) => { | ||
| 59 | - assert.strictEqual(0, written); | ||
| 60 | - }); | ||
| 61 | - fs.write(fd, expected, 0, 'utf8', common.mustCall((err, written) => { | ||
| 62 | - console.log('write done'); | ||
| 63 | - assert.ifError(err); | ||
| 64 | - assert.strictEqual(Buffer.byteLength(expected), written); | ||
| 65 | - fs.closeSync(fd); | ||
| 66 | - const found = fs.readFileSync(fn2, 'utf8'); | ||
| 67 | - console.log('expected: "%s"', expected); | ||
| 68 | - console.log('found: "%s"', found); | ||
| 69 | - fs.unlinkSync(fn2); | ||
| 70 | - assert.strictEqual(expected, found); | ||
| 71 | - })); | ||
| 72 | - })); | ||
| 59 | + const done = common.mustCall((err, written) => { | ||
| 60 | + assert.ifError(err); | ||
| 61 | + assert.strictEqual(Buffer.byteLength(expected), written); | ||
| 62 | + fs.closeSync(fd); | ||
| 63 | + const found = fs.readFileSync(fn2, 'utf8'); | ||
| 64 | + fs.unlinkSync(fn2); | ||
| 65 | + assert.strictEqual(expected, found); | ||
| 66 | + }); | ||
| 67 | + | ||
| 68 | + const written = common.mustCall(function(err, written) { | ||
| 69 | + assert.ifError(err); | ||
| 70 | + assert.strictEqual(0, written); | ||
| 71 | + }); | ||
| 72 | + | ||
| 73 | + fs.write(fd, '', 0, 'utf8', written); | ||
| 74 | + fs.write(fd, expected, 0, 'utf8', done); | ||
| 75 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments