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

cache-walk

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

cache-walk

Walk a require tree for a cached module

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status downloads npm Code Climate Test Coverage dependencies

cache-walk

Walk a require tree for a cached module.

Installation

npm install --save cache-walk

Summary

Requiring one file typically adds more than one file to the require cache, since that file (probably) requires other files, which potentially require other files. This module let's you walk through the entire require tree of a particular module as it is in the cache.

Usage

cache-walk exports three functions for interacting with a require tree: .get, .walk, and .delete. .get returns a list of module ids (absolute file paths), .walk calls a function for each module encountered, and .delete deletes an entire require tree from the cache.

.get
var foo = require('./foo');
var cache = require('cache-walk');

// requiredModules will contain ./foo
// plus everything required by ./foo and it's children
var requiredModules = cache.get('./foo');
.walk
var foo = require('./foo');
var cache = require('cache-walk');

// The callback will be called first with the ./foo module id
// and then with everything required by ./foo and it's children
cache.walk('./foo', function(mod) {
  console.log(mod);
});
.delete
var foo = require('./foo');
var cache = require('cache-walk');

// Delete ./foo from the cache along with it's children etc.
cache.delete('./foo');

These examples use relative paths, but absolute ones work as well.

Contributing

Please see the contribution guidelines.

Keywords

FAQs

Package last updated on 27 Dec 2016

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