File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 1
1
const { statSync, createReadStream} = require ( 'fs' ) ;
2
- const Blob = require ( '.' ) ;
2
+ const Blob = require ( './index.js ' ) ;
3
3
const DOMException = require ( 'domexception' ) ;
4
4
5
+ // eslint-disable-next-line unicorn/import-index
6
+ const Blob = require ( './index.js' ) ;
7
+
5
8
/**
6
9
* @param {string } path filepath on the disk
7
10
* @returns {Blob }
Original file line number Diff line number Diff line change @@ -160,6 +160,7 @@ class Blob {
160
160
161
161
static [ Symbol . hasInstance ] ( object ) {
162
162
return (
163
+ object &&
163
164
typeof object === 'object' &&
164
165
typeof object . stream === 'function' &&
165
166
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 => {
160
160
const error = await blob . text ( ) . catch ( error => error ) ;
161
161
t . is ( error . name , 'NotReadableError' ) ;
162
162
} ) ;
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