@@ -350,7 +350,7 @@ class CacheBackend {
350
350
}
351
351
352
352
/**
353
- * @param {string | string[] | Set<string> } [what] what to purge
353
+ * @param {string | Buffer | URL | number | ( string | URL | Buffer | number) [] | Set<string | URL | Buffer | number > } [what] what to purge
354
354
*/
355
355
purge ( what ) {
356
356
if ( ! what ) {
@@ -361,9 +361,15 @@ class CacheBackend {
361
361
}
362
362
this . _enterIdleMode ( ) ;
363
363
}
364
- } else if ( typeof what === "string" ) {
364
+ } else if (
365
+ typeof what === "string" ||
366
+ Buffer . isBuffer ( what ) ||
367
+ what instanceof URL ||
368
+ typeof what === "number"
369
+ ) {
370
+ const strWhat = typeof what !== "string" ? what . toString ( ) : what ;
365
371
for ( let [ key , data ] of this . _data ) {
366
- if ( key . startsWith ( what ) ) {
372
+ if ( key . startsWith ( strWhat ) ) {
367
373
this . _data . delete ( key ) ;
368
374
data . level . delete ( key ) ;
369
375
}
@@ -374,7 +380,8 @@ class CacheBackend {
374
380
} else {
375
381
for ( let [ key , data ] of this . _data ) {
376
382
for ( const item of what ) {
377
- if ( key . startsWith ( item ) ) {
383
+ const strItem = typeof item !== "string" ? item . toString ( ) : item ;
384
+ if ( key . startsWith ( strItem ) ) {
378
385
this . _data . delete ( key ) ;
379
386
data . level . delete ( key ) ;
380
387
break ;
@@ -388,17 +395,24 @@ class CacheBackend {
388
395
}
389
396
390
397
/**
391
- * @param {string | string[] | Set<string> } [what] what to purge
398
+ * @param {string | Buffer | URL | number | ( string | URL | Buffer | number) [] | Set<string | URL | Buffer | number > } [what] what to purge
392
399
*/
393
400
purgeParent ( what ) {
394
401
if ( ! what ) {
395
402
this . purge ( ) ;
396
- } else if ( typeof what === "string" ) {
397
- this . purge ( dirname ( what ) ) ;
403
+ } else if (
404
+ typeof what === "string" ||
405
+ Buffer . isBuffer ( what ) ||
406
+ what instanceof URL ||
407
+ typeof what === "number"
408
+ ) {
409
+ const strWhat = typeof what !== "string" ? what . toString ( ) : what ;
410
+ this . purge ( dirname ( strWhat ) ) ;
398
411
} else {
399
412
const set = new Set ( ) ;
400
413
for ( const item of what ) {
401
- set . add ( dirname ( item ) ) ;
414
+ const strItem = typeof item !== "string" ? item . toString ( ) : item ;
415
+ set . add ( dirname ( strItem ) ) ;
402
416
}
403
417
this . purge ( set ) ;
404
418
}
@@ -636,7 +650,7 @@ module.exports = class CachedInputFileSystem {
636
650
}
637
651
638
652
/**
639
- * @param {string| string[]| Set<string> } [what] what to purge
653
+ * @param {string | Buffer | URL | number | ( string | URL | Buffer | number)[] | Set<string | URL | Buffer | number > } [what] what to purge
640
654
*/
641
655
purge ( what ) {
642
656
this . _statBackend . purge ( what ) ;
0 commit comments