Remove Blob#close per spec change

See https://github.com/w3c/FileAPI/pull/68.
This commit is contained in:
Timothy Gu 2018-01-27 11:50:29 -08:00
parent 8c7c179fef
commit bc6f0da3ac
No known key found for this signature in database
GPG Key ID: 7FE6B095B582B0D4
2 changed files with 1 additions and 22 deletions

View File

@ -3,7 +3,6 @@
export const BUFFER = Symbol('buffer');
const TYPE = Symbol('type');
const CLOSED = Symbol('closed');
export default class Blob {
constructor() {
@ -14,7 +13,6 @@ export default class Blob {
configurable: true
});
this[CLOSED] = false;
this[TYPE] = '';
const blobParts = arguments[0];
@ -51,14 +49,11 @@ export default class Blob {
}
}
get size() {
return this[CLOSED] ? 0 : this[BUFFER].length;
return this[BUFFER].length;
}
get type() {
return this[TYPE];
}
get isClosed() {
return this[CLOSED];
}
slice() {
const size = this.size;
@ -88,12 +83,8 @@ export default class Blob {
);
const blob = new Blob([], { type: arguments[2] });
blob[BUFFER] = slicedBuffer;
blob[CLOSED] = this[CLOSED];
return blob;
}
close() {
this[CLOSED] = true;
}
}
Object.defineProperty(Blob.prototype, Symbol.toStringTag, {

View File

@ -1615,14 +1615,8 @@ describe('node-fetch', () => {
});
return res.blob().then(function(result) {
expect(result).to.be.an.instanceOf(Blob);
expect(result.isClosed).to.be.false;
expect(result.size).to.equal(3);
expect(result.type).to.equal('text/plain');
result.close();
expect(result.isClosed).to.be.true;
expect(result.size).to.equal(0);
expect(result.type).to.equal('text/plain');
});
});
@ -1768,14 +1762,8 @@ describe('node-fetch', () => {
expect(req.url).to.equal(url);
return req.blob().then(function(result) {
expect(result).to.be.an.instanceOf(Blob);
expect(result.isClosed).to.be.false;
expect(result.size).to.equal(3);
expect(result.type).to.equal('');
result.close();
expect(result.isClosed).to.be.true;
expect(result.size).to.equal(0);
expect(result.type).to.equal('');
});
});