Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clear-require

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clear-require

Clear a module from the `require` cache

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

clear-require Build Status

Clear a module from the require cache

Useful for testing purposes when you need to freshly require a module.

Install

$ npm install --save clear-require

Usage

// foo.js
let i = 0;
module.exports = () => ++i;
const clearRequire = require('clear-require');

require('./foo')();
//=> 1

require('./foo')();
//=> 2

clearRequire('./foo');

require('./foo')();
//=> 1

API

clearRequire(moduleId)

moduleId

Type: string

What you would use with require().

clearRequire.all()

Clear all modules from the require cache.

clearRequire.match(regex)

Clear all matching modules from the require cache.

regex

Type: RegExp

Regex to match against the module ID's.

  • require-uncached - Require a module bypassing the cache

License

MIT © Sindre Sorhus

Keywords

FAQs

Package last updated on 08 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc