Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Walton committed Aug 29, 2020
1 parent 4c6a393 commit aa050f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ declare const clear: {
//=> 1
```
*/
(moduleId: string, callback?: (filePath: string) => boolean | undefined): void;
(moduleId: string, callback?: (moduleId: string, filePath: string) => boolean | undefined): void;

/**
Clear all modules from the cache.
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const clear = (moduleId, callback) => {
return;
}

if (typeof callback === 'function' && (callback(filePath) === false)) {
if (typeof callback === 'function' && (callback(moduleId, filePath) === false)) {
return;
}

Expand Down
10 changes: 9 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,22 @@ require('./foo')();

## API

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

#### moduleId

Type: `string`

What you would use with `require()`.

#### callback

Type: `function`

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

### clearModule.all()

Clear all modules from the cache.
Expand Down

0 comments on commit aa050f7

Please sign in to comment.