Skip to content

Commit

Permalink
Updating documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Walton committed Aug 29, 2020
1 parent 78fa991 commit 3779906
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,25 @@ require('./foo')();

## API

### clearModule(moduleId, callback)
### clearModule(moduleId, options)

#### moduleId

Type: `string`

What you would use with `require()`.

#### callback
#### options

Type: `function`
Type: `object`

Optional callback to filter with, must return false to not clear.
Passes in the full path to the module.
Will not process child modules of modules that are filtered out.
##### options.filter

Optional callback to filter with, must return false to not clear. Passes in the full path to the module. Will not process child modules of modules that are filtered out.

Use case

This allows you to prevent specific submodules from being unloaded, i.e. aws-sdk, if used in main code, but you have it in modules that are being cleared out, this could adversely affect code that is not being cleared. You could also, prevent anything from node_modules from being unloaded as well, fp => !fp.match(/node_modules/). For users, this will only unload user code and not package code.

### clearModule.all()

Expand Down

0 comments on commit 3779906

Please sign in to comment.