npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hot-module-require

v4.0.3

Published

Detect module's update recursively on nodejs.

Downloads

111

Readme

hot-module-require

NPM version NPM Downloads

Detect module's update recursively on nodejs.

Usage

// module.js
module.exports = require('./foo') + require('./bar')
const makeHotRequire = require('hot-module-require')
const hotRequire = makeHotRequire(__dirname)

let mExports = require('./module')

hotRequire.accept(['./module'], (oldModule, path) => {
  // Do something here 
  // when './module' module or submodules('./foo', './bar'') be detected changed.
  let newExports = require('./module') 
})


// Or use it like follows
const hotModuleGetter = hotRequire('./module')
hotModuleGetter() // Returns the already updated `require('./module')``

hotModuleGetter.remove() // Calls `remove` for interrupting detect updated 

Express Example

npm run example

API

makeHotRequireFunction

index.js:52-373

make a hot require instance

Parameters

  • dirname (optional, default '')
  • presetOpts {{}} (optional, default {})
    • presetOpts.recursive {boolean} Analysis file recursively (optional, default true)

Returns HotRequire

HotRequire

index.js:173-184

resolve

index.js:256-256

Resolve file name

Parameters

  • name {string}

watcher

index.js:263-263

file Watcher

emitter

index.js:269-269

The event emitter

dependent

index.js:276-276

The map about dependent relations

Type: Map

dependence

index.js:283-283

The map about dependence relations

Type: Map

getDependenceTree

index.js:293-293

Get dependence tree of which file

Parameters

  • modulePath {string}
  • opts

Returns {}

addDependencies

index.js:303-303

Add Dependencies

Parameters

  • modulePath {string}
  • deps {string[]}

removeDependencies

index.js:311-311

Remove Dependencies

Parameters

  • modulePath {string}
  • deps {string[]}

accept

index.js:320-331

Watch file with callback and make dependence(dependent) relations

Parameters

  • deps {string[]}
  • callback {function}

refuse

index.js:339-361

Watch file with callback and make dependence(dependent) relations

Parameters

  • deps {string[]}
  • callback {function}

close

index.js:368-370

Close file watcher

Returns any void

Related