Remove Blob#close per spec change
See https://github.com/w3c/FileAPI/pull/68.
This commit is contained in:
parent
8c7c179fef
commit
bc6f0da3ac
11
src/blob.js
11
src/blob.js
|
@ -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, {
|
||||
|
|
12
test/test.js
12
test/test.js
|
@ -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('');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue