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

sleuth

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

sleuth

Discover the variable names chosen for each of a file's top-level required modules

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.6K
increased by133.93%
Maintainers
1
Weekly downloads
 
Created
Source

sleuth Flattr this!experimental

Discover the variable names chosen for each of a file's top-level required modules.

Won't pick up nested requires in if/for statements or inside functions, but is intended for detecting the names of variables to replace e.g. when creating inlining transforms such as brfs.

Usage

sleuth

requires = sleuth(ast)

Accepts an esprima-like ast object.

Returns an object whose keys represent the variable names used to require a module, and whose values are the required module strings detected.

Example

var esprima = require('esprima')
var walkers = require('astw')
var files = require('fs')

var src = files.readFileSync(__filename, 'utf8')
var ast = esprima.parse(src)

// Walk the generated AST
var result = sleuth(ast)
console.log(result)

// Or you can try it this way:
var result = sleuth(walkers(src))
console.log(result)

Which should give you back something like this:

{
  esprima: 'esprima',
  walkers: 'astw',
  files: 'fs'
}

License

MIT. See LICENSE.md for details.

Keywords

FAQs

Package last updated on 29 Jun 2014

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