Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
detective-es6
Advanced tools
The detective-es6 npm package is designed to analyze JavaScript files to find and extract import/require statements. This is particularly useful for tools that need to understand dependencies between modules in ES6, CommonJS, or similar module systems. It can be used for tasks such as bundling, dependency analysis, and refactoring.
Extract import statements from ES6 modules
This feature allows you to extract all import statements from a string of ES6 module code. It's useful for analyzing module dependencies.
const detective = require('detective-es6');
const src = `import { foo } from 'my-module';`;
const dependencies = detective(src);
console.log(dependencies); // Outputs: ['my-module']
Extract require statements from CommonJS modules
This feature enables the extraction of require statements from CommonJS module code, helping in the analysis of dependencies in a Node.js environment.
const detective = require('detective-es6');
const src = `const foo = require('my-module');`;
const dependencies = detective(src);
console.log(dependencies); // Outputs: ['my-module']
Precinct is a tool similar to detective-es6 that inspects files to determine their dependencies. It supports a wider range of file types including TypeScript, AMD, and CSS. Compared to detective-es6, Precinct offers a more comprehensive solution for dependency detection across different module systems and file types.
Madge is a more comprehensive tool that builds on the functionality provided by detective-es6. It not only finds dependencies but also creates visual graphs of module dependencies. While detective-es6 focuses on the extraction of import/require statements, Madge provides a higher-level overview of project structure and dependencies.
Get the dependencies of an ES6 module
npm install detective-es6
var detective = require('detective-es6');
var mySourceCode = fs.readFileSync('myfile.js', 'utf8');
// Pass in a file's content or an AST
var dependencies = detective(mySourceCode);
MIT
FAQs
Get the dependencies of an ES6 module
The npm package detective-es6 receives a total of 994,512 weekly downloads. As such, detective-es6 popularity was classified as popular.
We found that detective-es6 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
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.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.