sindresorhus / clear-module

Clear a module from the cache
MIT License
182 stars 25 forks source link

Add regex based clear #2

Closed mrchief closed 7 years ago

mrchief commented 7 years ago

Allows you to clear only a few specific modules from cache in cases where calling clear one by one is not an option or purging the whole cache is not what you want to do.

E.g. clearing all moment and its locales

clear.match(/moment[\\/]/);

// clears 

// /path/to/node_modules/moment
// /path/to/node_modules/moment/locale/...