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

amdextract

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amdextract - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

14

index.js

@@ -11,3 +11,3 @@ /*

var defineRegExp = /define\s*\(\s*(?:['"](.*)['"]\s*,\s*)?(?:\[\s*([^]*?)\s*\]\s*,)?\s*function\s*\(\s*([^]*?)\s*\)\s*\{/gm,
var defineRegExp = /(?:\/[\*\/]\s*exceptsPaths\s*\:\s*([^]+?)\s*(?:(?:\*\/)|(?:[\r\n]+)))?\s*define\s*\(\s*(?:['"](.*)['"]\s*,\s*)?(?:\[\s*([^]*?)\s*\]\s*,)?\s*function\s*\(\s*([^]*?)\s*\)\s*\{/gm,
commentRegExp = /(?:\/\*[^]*?\*\/)|(?:\/\/[^]*?$)/gm,

@@ -76,3 +76,3 @@ commaRegExp = /\s*,\s*/,

var output = content.replace(defineRegExp, function (match, moduleId, pathsStr, dependenciesStr, offset) {
var output = content.replace(defineRegExp, function (match, exceptsPathsStr, moduleId, pathsStr, dependenciesStr, offset) {
var text = content.substr(offset + match.length - 1), // Unprocessed

@@ -82,2 +82,4 @@ paths, dependencies, commentlessPathsStr, commentlessDependenciesStr,

unusedPaths = [],
exceptsPaths = [],
excepts = options.excepts,
body, // Module body with comments

@@ -87,2 +89,6 @@ source, // Module body without comments

if (exceptsPathsStr) {
exceptsPaths = options.exceptsPaths.concat(exceptsPathsStr.split(commaRegExp));
}
commentlessPathsStr = removeComments(pathsStr).source;

@@ -105,4 +111,4 @@ commentlessDependenciesStr = removeComments(dependenciesStr).source;

unusedDependencies = dependencies.filter(function (dependency) {
return !isException(options.excepts, dependency) &&
!isException(options.exceptsPaths, paths[dependencies.indexOf(dependency)]) &&
return !isException(excepts, dependency) &&
!isException(exceptsPaths, paths[dependencies.indexOf(dependency)]) &&
!findUseage(dependency, source);

@@ -109,0 +115,0 @@ });

{
"name": "amdextract",
"version": "0.1.0",
"version": "0.1.1",
"description": "Extracts AMD modules and their parts.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -9,7 +9,7 @@ # amdextract

``` js
define(["view/a", "view/b"], function (a, b) {
define("module1", ["view/a", "view/b"], function (a, b) {
var t = new a();
});
define(["view/a", "view/b", "view/c"], function (a, b, c) {
define("module2", ["view/a", "view/b", "view/c"], function (a, b, c) {
b.fetch();

@@ -76,2 +76,11 @@ });

NOTE: `exceptsPaths` can also be declared before each module definition as a comment of strings of module paths separated by commas. This only applies on the underlying module definition.
``` js
/* exceptsPaths: view/c */
define(["view/a", "view/b", "view/c"], function (a, b, c) {
b.fetch();
});
```
#### removeUnusedDependencies

@@ -105,6 +114,7 @@ Type: Boolean

Optimized `content` (original content without unused dependencies).
This property is available when option `removeUnusedDependencies` is true.
This property is available when the value of option `removeUnusedDependencies` is true.
## Release History
* 2014-01-20   v0.1.1   `exceptsPaths` can also be defined before each module definition.
* 2014-01-13   v0.1.0   Works on files with multiple modules. Can detect module id if provided. Can remove unused dependencies. Add the new `exceptsPaths` option. Options `excepts` and `exceptsPaths` can take RegExps.

Sorry, the diff of this file is not supported yet

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