New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

change-require

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

change-require

Auto Require JS Files when changed

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

Auto Require JS Files when changed! No App restart required!

How about overcoming small hurdles of server restart whenever a minor change is included in a file? This module does exactly that! It watches for file changes and auto requires them once any change is made!

var cRequire = require('change-require');
// Require and ask for manipulation
var myModule = cRequire(myModule);

// Call myModule function as:
myModule.myFunction(...);

Note: DON'T save a reference to myFunction and call directly as:

    var myModule = cRequire(myModule),
    myFunction = myModule.myFunction;
    myFunction() // ❌ Incorrect. Will not be auto applied when myModule file changes!

Correct way:

    myModule.myFunction() // ✔️ Correct way to call! Any changes will be auto applied.

Also, the global require can be overridden as:

    require('change-require').globalise();

Limitations:

This is applicable when either an object ({}) or a function is exported. In case anything else such as a number or string is exported from a file, this will not be applied.

Also, won't be applied on inbuilt modules!

FAQs

Package last updated on 05 Jul 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