Socket
Socket
Sign inDemoInstall

amdextract

Package Overview
Dependencies
2
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.10 to 2.1.11

54

index.js

@@ -151,44 +151,48 @@ /*

start = 0,
firstPath,
firstDependency;
regEx = /[\s,]/;
modules.forEach(function(module) {
if (module.paths) { firstPath = module.paths[0]; }
if (module.dependencies) { firstDependency = module.dependencies[0]; }
module.unusedPaths.concat(module.unusedDependencies).forEach(function(item) {
var isFirstElem = item === firstPath || item === firstDependency;
var range = [];
range[0] = item.range[0];
range[1] = item.range[1];
if (item.leadingComments) {
item.leadingComments.forEach(function(comment) {
comment.range.isForFirstElem = isFirstElem;
rangesToRemove.push(comment.range);
});
range[0] = item.leadingComments[0].range[0];
}
item.range.isForFirstElem = isFirstElem;
rangesToRemove.push(item.range);
if (item.trailingComments) {
item.trailingComments.forEach(function(comment) {
comment.range.isForFirstElem = isFirstElem;
rangesToRemove.push(comment.range);
});
range[1] = item.trailingComments[item.trailingComments.length - 1].range[1];
}
rangesToRemove.push(range);
});
});
rangesToRemove.forEach(function(range) {
range = extendRange(range, content);
rangesToRemove.forEach(function(range, index) {
var rangeStart = range[0] - 1,
rangeEnd = range[1],
commaVisited = false;
if (range[0] > start) {
var tmp = content.substring(start, range[0]);
if (/[[(]/.test(output[output.length - 1])) {
tmp = tmp.replace(/^[,\s]*/, '');
if (index === 0 || range[0] > rangesToRemove[index - 1][1]) {
for (var char = content[rangeStart]; regEx.test(char); char = content[--rangeStart]) {
if (char === ',') {
commaVisited = true;
}
}
}
output += tmp;
if (!commaVisited) {
for (var char = content[rangeEnd]; regEx.test(char); char = content[++rangeEnd])
;
}
range[0] = rangeStart + 1;
range[1] = rangeEnd;
if (range[0] > start) {
output += content.substring(start, range[0]);
}
start = range[1];

@@ -195,0 +199,0 @@ });

{
"name": "amdextract",
"version": "2.1.10",
"version": "2.1.11",
"description": "Uses AST to extract AMD modules, their parts and an optimized output without unused dependencies while keeping the original format.",

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

@@ -130,2 +130,3 @@ # amdextract [![Build Status](https://travis-ci.org/mehdishojaei/amdextract.png)](https://travis-ci.org/mehdishojaei/amdextract)

## Release History
* 2015-12-26   v2.1.11   Fixed a bug in "optimizedContent" property.
* 2015-07-25   v2.1.10   Update travis CI.

@@ -132,0 +133,0 @@ * 2015-07-25   v2.1.9   Update dependencies.

@@ -74,3 +74,3 @@ var amdextract = require('..');

var output = amdextract.parse(
"define('name', ['p1', 'p2'], function(a, b) { return b; })",
"define('name', ['p1', 'p2', 'p3'], function(a, b, c) { return c; })",
{ removeUnusedDependencies: true }

@@ -80,8 +80,8 @@ );

it('.moduleId', function() { should(result.moduleId).equal('name'); });
it('.paths', function() { result.paths.should.be.eql(['p1', 'p2']); });
it('.dependencies', function() { result.dependencies.should.be.eql(['a', 'b']); });
it('.unusedPaths', function() { result.unusedPaths.should.be.eql(['p1']); });
it('.unusedDependencies', function() { result.unusedDependencies.should.be.eql(['a']); });
it('.paths', function() { result.paths.should.be.eql(['p1', 'p2', 'p3']); });
it('.dependencies', function() { result.dependencies.should.be.eql(['a', 'b', 'c']); });
it('.unusedPaths', function() { result.unusedPaths.should.be.eql(['p1', 'p2']); });
it('.unusedDependencies', function() { result.unusedDependencies.should.be.eql(['a', 'b']); });
it('.optimizedContent', function() { should(output.optimizedContent).be.equal(
"define('name', ['p2'], function(b) { return b; })"
"define('name', ['p3'], function(c) { return c; })"
); });

@@ -88,0 +88,0 @@ });

Sorry, the diff of this file is not supported yet

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