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

detective

Package Overview
Dependencies
Maintainers
39
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detective

find all require() calls by walking the AST

  • 5.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.3M
increased by33.56%
Maintainers
39
Weekly downloads
 
Created

What is detective?

The 'detective' npm package is a module dependency analysis tool that helps developers to find out which modules are required in a given JavaScript file. It parses the file, extracts the 'require' statements, and returns a list of dependencies. This is particularly useful for tasks like bundling, minification, and understanding code dependencies.

What are detective's main functionalities?

Detect CommonJS dependencies

This feature allows you to extract all CommonJS dependencies (i.e., modules loaded via 'require') from a JavaScript file. The code reads a JavaScript file, uses detective to parse the file and logs the list of dependencies.

const detective = require('detective');
const fs = require('fs');
const content = fs.readFileSync('/path/to/js/file.js', 'utf8');
const dependencies = detective(content);
console.log(dependencies);

Detect ES6 module dependencies

Using 'detective-es6', a variant of detective tailored for ES6 modules, this feature parses files containing ES6 import statements to determine dependencies. The process involves reading the file, parsing it with detective-es6, and logging the dependencies.

const detective = require('detective-es6');
const fs = require('fs');
const content = fs.readFileSync('/path/to/es6/file.js', 'utf8');
const dependencies = detective(content);
console.log(dependencies);

Other packages similar to detective

Keywords

FAQs

Package last updated on 28 Feb 2018

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