Sign In

clear-module

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clear-module - npm Package Compare versions

Comparing version
4.1.2
to
4.1.3
+17
-5
index.js

@@ -12,2 +12,4 @@ 'use strict';

const isNativeModule = filePath => path.extname(filePath) === '.node';
const clear = moduleId => {

@@ -24,2 +26,6 @@ if (typeof moduleId !== 'string') {

if (isNativeModule(filePath)) {
return;
}
// Delete itself from module parent

@@ -50,6 +56,6 @@ if (require.cache[filePath] && require.cache[filePath].parent) {

clear.all = () => {
const directory = path.dirname(parentModule(__filename));
for (const moduleId of Object.keys(require.cache)) {
delete require.cache[resolveFrom(directory, moduleId)];
for (const filePath of Object.keys(require.cache)) {
if (!isNativeModule(filePath)) {
delete require.cache[filePath];
}
}

@@ -71,5 +77,11 @@ };

delete require.cache[resolve(moduleId)];
const filePath = resolve(moduleId);
if (!filePath || isNativeModule(filePath)) {
return;
}
delete require.cache[filePath];
};
module.exports = clear;
{
"name": "clear-module",
"version": "4.1.2",
"version": "4.1.3",
"description": "Clear a module from the cache",

@@ -13,2 +13,3 @@ "license": "MIT",

},
"sideEffects": false,
"engines": {

@@ -18,3 +19,4 @@ "node": ">=8"

"scripts": {
"test": "xo && ava && tsd"
"//test": "xo && ava && tsd",
"test": "ava"
},

@@ -21,0 +23,0 @@ "files": [

@@ -9,5 +9,5 @@ # clear-module

```sh
npm install clear-module
```
$ npm install clear-module
```

@@ -14,0 +14,0 @@ ## Usage