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.0.0
to
4.1.0
+9
-0
index.d.ts

@@ -41,4 +41,13 @@ declare const clear: {

match(regex: RegExp): void;
/**
Clear a single module from the cache non-recursively. No parent or children modules will be affected.
This is mostly only useful if you use singletons, where you would want to clear a specific module without causing any side effects.
@param moduleId - What you would use with `require()`.
*/
single(moduleId: string): void;
};
export = clear;
+9
-3

@@ -9,5 +9,3 @@ 'use strict';

return resolveFrom(path.dirname(parentModule(__filename)), moduleId);
} catch (error) {
return undefined;
}
} catch (_) {}
};

@@ -64,2 +62,10 @@

clear.single = moduleId => {
if (typeof moduleId !== 'string') {
throw new TypeError(`Expected a \`string\`, got \`${typeof moduleId}\``);
}
delete require.cache[resolve(moduleId)];
};
module.exports = clear;
{
"name": "clear-module",
"version": "4.0.0",
"version": "4.1.0",
"description": "Clear a module from the cache",
"license": "MIT",
"repository": "sindresorhus/clear-module",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},

@@ -12,0 +13,0 @@ "engines": {

@@ -7,3 +7,2 @@ # clear-module [![Build Status](https://travis-ci.org/sindresorhus/clear-module.svg?branch=master)](https://travis-ci.org/sindresorhus/clear-module)

## Install

@@ -15,3 +14,2 @@

## Usage

@@ -40,3 +38,2 @@

## API

@@ -66,3 +63,14 @@

### clearModule.single(moduleId)
Clear a single module from the cache non-recursively. No parent or children modules will be affected.
This is mostly only useful if you use singletons, where you would want to clear a specific module without causing any side effects.
#### moduleId
Type: `string`
What you would use with `require()`.
## Related

@@ -69,0 +77,0 @@

Sorry, the diff of this file is not supported yet