| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,14 +1,12 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | - ArrayBuffer, | ||
| 5 | 4 | ArrayFrom, | |
| 6 | 5 | MathMax, | |
| 7 | 6 | MathMin, | |
| 8 | 7 | ObjectDefineProperties, | |
| 9 | 8 | ObjectDefineProperty, | |
| 10 | 9 | PromiseReject, | |
| 11 | - PromiseResolve, | ||
| 12 | 10 | ReflectConstruct, | |
| 13 | 11 | RegExpPrototypeExec, | |
| 14 | 12 | RegExpPrototypeSymbolReplace, | |
@@ -266,10 +264,6 @@ class Blob { | |||
| 266 | 264 | if (!isBlob(this)) | |
| 267 | 265 | return PromiseReject(new ERR_INVALID_THIS('Blob')); | |
| 268 | 266 | ||
| 269 | - if (this.size === 0) { | ||
| 270 | - return PromiseResolve(new ArrayBuffer(0)); | ||
| 271 | - } | ||
| 272 | - | ||
| 273 | 267 | const { promise, resolve, reject } = createDeferredPromise(); | |
| 274 | 268 | const reader = this[kHandle].getReader(); | |
| 275 | 269 | const buffers = []; | |
@@ -316,12 +310,6 @@ class Blob { | |||
| 316 | 310 | if (!isBlob(this)) | |
| 317 | 311 | throw new ERR_INVALID_THIS('Blob'); | |
| 318 | 312 | ||
| 319 | - if (this.size === 0) { | ||
| 320 | - return new lazyReadableStream({ | ||
| 321 | - start(c) { c.close(); }, | ||
| 322 | - }); | ||
| 323 | - } | ||
| 324 | - | ||
| 325 | 313 | const reader = this[kHandle].getReader(); | |
| 326 | 314 | return new lazyReadableStream({ | |
| 327 | 315 | start(c) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,12 +20,14 @@ const { Blob } = require('buffer'); | |||
| 20 | 20 | const tmpdir = require('../common/tmpdir'); | |
| 21 | 21 | const testfile = path.join(tmpdir.path, 'test-file-backed-blob.txt'); | |
| 22 | 22 | const testfile2 = path.join(tmpdir.path, 'test-file-backed-blob2.txt'); | |
| 23 | + const testfile3 = path.join(tmpdir.path, 'test-file-backed-blob3.txt'); | ||
| 23 | 24 | tmpdir.refresh(); | |
| 24 | 25 | ||
| 25 | 26 | const data = `${'a'.repeat(1000)}${'b'.repeat(2000)}`; | |
| 26 | 27 | ||
| 27 | 28 | writeFileSync(testfile, data); | |
| 28 | 29 | writeFileSync(testfile2, data.repeat(100)); | |
| 30 | + writeFileSync(testfile3, ''); | ||
| 29 | 31 | ||
| 30 | 32 | (async () => { | |
| 31 | 33 | const blob = await openAsBlob(testfile); | |
@@ -79,3 +81,21 @@ writeFileSync(testfile2, data.repeat(100)); | |||
| 79 | 81 | ||
| 80 | 82 | await unlink(testfile2); | |
| 81 | 83 | })().then(common.mustCall()); | |
| 84 | + | ||
| 85 | + (async () => { | ||
| 86 | + const blob = await openAsBlob(testfile3); | ||
| 87 | + strictEqual(blob.size, 0); | ||
| 88 | + strictEqual(await blob.text(), ''); | ||
| 89 | + writeFileSync(testfile3, 'abc'); | ||
| 90 | + await rejects(blob.text(), { name: 'NotReadableError' }); | ||
| 91 | + await unlink(testfile3); | ||
| 92 | + })().then(common.mustCall()); | ||
| 93 | + | ||
| 94 | + (async () => { | ||
| 95 | + const blob = await openAsBlob(testfile3); | ||
| 96 | + strictEqual(blob.size, 0); | ||
| 97 | + writeFileSync(testfile3, 'abc'); | ||
| 98 | + const stream = blob.stream(); | ||
| 99 | + const reader = stream.getReader(); | ||
| 100 | + await rejects(() => reader.read(), { name: 'NotReadableError' }); | ||
| 101 | + })().then(common.mustCall()); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments