Socket
Socket
Sign inDemoInstall

detective-cjs

Package Overview
Dependencies
3
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    detective-cjs

Get the dependencies of a CommonJS module by traversing its AST


Version published
Weekly downloads
1.1M
decreased by-8.83%
Maintainers
3
Install size
1.82 MB
Created
Weekly downloads
 

Readme

Source

detective-cjs

CI npm version npm downloads

Get the dependencies of a CommonJS module by traversing its AST

npm install detective-cjs

But dude, substack already built this: node-detective. Yes, but I needed the capability to reuse an AST and this was unlikely to be merged timely. I can also support jsx and other syntactic constructs faster.

Usage

const fs = require('fs');
const detective = require('detective-cjs');

const mySourceCode = fs.readFileSync('myfile.js', 'utf8');

// Pass in a file's content or an AST
const dependencies = detective(mySourceCode);
  • Supports JSX, ES7, and any other features that node-source-walk supports.

License

MIT

Keywords

FAQs

Last updated on 14 Apr 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc