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

disrequire

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

disrequire

undo a require

  • 1.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
83
increased by45.61%
Maintainers
1
Weekly downloads
 
Created
Source

disrequire

Build Status Coverage Status

Same as qmock.unrequire, but available standalone.

This package exports a function to undo the side-effects of a require(). All cached copies of an external nodejs module loaded with require will be discarded. Built-in modules such as http do not have separate cached copies, and are not unloaded.

const disrequire = require('disrequire');
disrequire('config');

Api

disrequire( packageName )

Unload the named package from all require caches. The package is removed from require.cache and from every module.children[] in which it occurs. Built-in modules like http are not unloaded.

const disrequire = require('disrequire');
disrequire('config');

disrequire.quick( packageName )

Shallow unload a single copy of the named package from the require caches. The package is removed from require.cache and from the module that loaded it, ie require.cache[require.resove(packageName)].parent.children[].

If it is known that only one module loaded the package, it is much faster to not have to walk the module tree searching for other locations.

const disrequire = require('disrequire');   // now you see it
disrequire.quick('disrequire');             // now you dont

Changelog

  • 1.1.4 - fix broken stack trace capture under node v0.1x
  • 1.1.3 - fix to work under node-v0.6 which broke with 1.1.2
  • 1.1.2 - fix for use with source maps
  • 1.1.1 - fix global leak of name stack
  • 1.1.0 - new disrequire.quick() shallow unload
  • 1.0.5 - speed up disrequire() with many cross-linked modules
  • 1.0.4 - fix resolveOrSelf for anonymous functions
  • 1.0.3 - make tests create the test module, remove node_modules from repo
  • 1.0.2 - fix typo in exported resolveOrSelv
  • 1.0.1 - split out of qmock
  • qmock - various useful mocks and stubs, including mocks for node system functions

Keywords

FAQs

Package last updated on 09 Jan 2023

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