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

detective-cjs

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detective-cjs

Get the dependencies of a CommonJS module by traversing its AST

  • 6.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.1M
decreased by-7.4%
Maintainers
3
Weekly downloads
 
Created

What is detective-cjs?

The detective-cjs package is a tool designed for analyzing JavaScript files to extract their CommonJS (require) dependencies. It parses the source code of a JavaScript file and identifies the modules that the file depends on by looking for 'require' statements. This can be particularly useful for tasks such as bundling, dependency analysis, and refactoring.

What are detective-cjs's main functionalities?

Extracting dependencies from a file

This feature allows you to pass JavaScript source code as a string to the detective function, which returns an array of strings representing the dependencies found in the source code. It's useful for identifying which modules a particular file is dependent on.

const detective = require('detective-cjs');
const src = `const foo = require('foo');
const bar = require('./bar.js');`;
const dependencies = detective(src);
console.log(dependencies); // ['foo', './bar.js']

Other packages similar to detective-cjs

Keywords

FAQs

Package last updated on 14 Apr 2024

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