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

babel-plugin-closure-elimination

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-closure-elimination - npm Package Compare versions

Comparing version 1.1.12 to 1.1.13

22

lib/index.js

@@ -68,11 +68,9 @@ 'use strict';

function _getAttachmentPositio(bestParent, prevPath) {
var possibleSiblings = void 0;
if (bestParent.isFunction()) {
possibleSiblings = bestParent.get('body.body');
} else if (bestParent.isProgram() || bestParent.isBlockStatement()) {
possibleSiblings = bestParent.get('body');
var prevParents = prevPath.getAncestry(),
bestParentIdx = prevParents.indexOf(bestParent);
if (-1 === bestParentIdx) {
throw new Error('Possible parent not really in ancestry');
}
var prevParents = prevPath.getAncestry();
return possibleSiblings.find(function (x) {
return prevParents.indexOf(x) !== -1;
return prevParents.slice(1, bestParentIdx).reverse().find(function (path) {
return (path.parentPath.isBlockStatement() || path.parentPath.isProgram()) && path.parentPath.scope !== prevPath.parentPath.scope;
});

@@ -110,5 +108,7 @@ }

var attachPath = _getAttachmentPositio(bestParentScope.path, path);
// _logAllProgram(path, 'before');// debug
moveToNewPosition(path, attachPath);
// _logAllProgram(path, 'after');// debug
if (attachPath) {
// _logAllProgram(path, 'before');// debug
moveToNewPosition(path, attachPath);
// _logAllProgram(path, 'after');// debug
}
}

@@ -115,0 +115,0 @@ }

{
"name": "babel-plugin-closure-elimination",
"version": "1.1.12",
"version": "1.1.13",
"description": "Removes closures from your JavaScript in the name of performance.",

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

@@ -30,5 +30,7 @@ import 'babel-polyfill';

const attachPath = getAttachmentPosition(bestParentScope.path, path);
// _logAllProgram(path, 'before');// debug
moveToNewPosition(path, attachPath);
// _logAllProgram(path, 'after');// debug
if (attachPath) {
// _logAllProgram(path, 'before');// debug
moveToNewPosition(path, attachPath);
// _logAllProgram(path, 'after');// debug
}
}

@@ -94,10 +96,14 @@ }

function getAttachmentPosition(bestParent, prevPath) {
let possibleSiblings;
if (bestParent.isFunction()) {
possibleSiblings = bestParent.get('body.body');
} else if (bestParent.isProgram() || bestParent.isBlockStatement()) {
possibleSiblings = bestParent.get('body');
const prevParents = prevPath.getAncestry(),
bestParentIdx = prevParents.indexOf(bestParent);
if (-1 === bestParentIdx) {
throw new Error('Possible parent not really in ancestry');
}
const prevParents = prevPath.getAncestry();
return possibleSiblings.find(x => prevParents.indexOf(x) !== -1);
return prevParents
.slice(1, bestParentIdx)
.reverse()
.find(
path => (path.parentPath.isBlockStatement() || path.parentPath.isProgram()) &&
path.parentPath.scope !== prevPath.parentPath.scope
);
}

@@ -122,3 +128,3 @@

);
if(node.id && node.id.name) {
if (node.id && node.id.name) {
scope.rename(node.id.name, uid.name);

@@ -125,0 +131,0 @@ }

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