File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 11const { statSync, createReadStream} = require ( 'fs' ) ;
2- const Blob = require ( './index.js' ) ;
32const DOMException = require ( 'domexception' ) ;
43
4+ // eslint-disable-next-line unicorn/import-index
5+ const Blob = require ( './index.js' ) ;
6+
57/**
68 * @param {string } path filepath on the disk
79 * @returns {Blob }
@@ -27,7 +29,7 @@ class BlobDataItem {
2729 this . mtime = options . mtime ;
2830 }
2931
30- // Slicing arguments is first validated and formated
32+ // Slicing arguments is first validated and formated
3133 // to not be out of range by Blob.prototype.slice
3234 slice ( start , end ) {
3335 return new BlobDataItem ( {
Original file line number Diff line number Diff line change @@ -160,6 +160,7 @@ class Blob {
160160
161161 static [ Symbol . hasInstance ] ( object ) {
162162 return (
163+ object &&
163164 typeof object === 'object' &&
164165 typeof object . stream === 'function' &&
165166 object . stream . length === 0 &&
Original file line number Diff line number Diff line change @@ -160,3 +160,19 @@ test('Reading after modified should fail', async t => {
160160 const error = await blob . text ( ) . catch ( error => error ) ;
161161 t . is ( error . name , 'NotReadableError' ) ;
162162} ) ;
163+
164+ test ( 'Blob-ish class is an instance of Blob' , t => {
165+ class File {
166+ stream ( ) { }
167+
168+ get [ Symbol . toStringTag ] ( ) {
169+ return 'File' ;
170+ }
171+ }
172+
173+ t . true ( new File ( ) instanceof Blob ) ;
174+ } ) ;
175+
176+ test ( 'Instanceof check returns false for nullish values' , t => {
177+ t . false ( null instanceof Blob ) ;
178+ } ) ;
You can’t perform that action at this time.
0 commit comments