Socket
Socket
Sign inDemoInstall

amdetective

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amdetective

Like node-detective, but for AMD/r.js files


Version published
Maintainers
1
Created
Source

amdetective

Find all calls to require() in AMD modules.

This module uses code extracted from r.js rather than trying to write it's own version of r.js parsing. It depends on esprima (but not r.js).

Install

npm install amdetective

example

simple.js

require(['module1', 'path/to/module2'], function(a, b){
  // ...
});

simple2.js

define(function(require) {
  var a = require('some/file'),
      b = require('json!foo/bar');
  // ...
});

detect.js

This example file accepts a target path from command line so you can use it to inspect your own files as well:

var fs = require('fs'),
    amdetective = require('amdetective');

console.log('Reading file from first argument: ' + process.argv[2]);
console.log(amdetective(fs.readFileSync(process.argv[2]).toString()));

Running: node detect.js simple.js

Output:

Reading file from first argument: simple.js
[ 'module1', 'path/to/module2' ]

Running: node detect.js simple2.js

Output:

Reading file from first argument: simple2.js
[ 'require', 'some/file', 'json!foo/bar' ]

Methods

amdetective(src, opts)

Given some source body src, return an array of all the require() call arguments detected by AMD/r.js.

The options parameter opts is passed along to parse.recurse().

License

BSD

FAQs

Package last updated on 17 Jan 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