New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

inline-loops.macro

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inline-loops.macro - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

4

CHANGELOG.md
## CHANGELOG
# 2.0.4
- [#37](https://github.com/planttheidea/inline-loops.macro/pull/37/files) - Smarter IIFE wrapper determination logic
# 2.0.3

@@ -4,0 +8,0 @@

37

dist/utils.js

@@ -118,3 +118,3 @@ "use strict";

var t = _ref.types;
if (shouldWrapInClosure(path, local)) {
if (shouldWrapInClosure(path)) {
if (!t.isIdentifier(replacement, {

@@ -154,4 +154,3 @@ name: 'undefined'

}
function shouldWrapInClosure(path, local) {
var _functionParent$get;
function shouldWrapInClosure(path) {
var parentPath = path.parentPath;

@@ -161,27 +160,23 @@ if (!parentPath) {

}
var functionParent = path.getFunctionParent();
if (!functionParent) {
return isPossiblyDynamic(parentPath);
}
var grandparentPath = parentPath.parentPath;
if (parentPath.isPattern() || local.contents.length > 1) {
if (parentPath.isAssignmentPattern()) {
return true;
}
var contents = functionParent === null || functionParent === void 0 || (_functionParent$get = functionParent.get('body')) === null || _functionParent$get === void 0 ? void 0 : _functionParent$get.get('body');
if (Array.isArray(contents) && contents.length > 1) {
return contents.flat().some(function (content) {
return content.isVariableDeclaration();
});
if (parentPath.isArrayExpression() || parentPath.isAwaitExpression() || parentPath.isBinaryExpression() || parentPath.isJSXElement() || parentPath.isJSXExpressionContainer() || parentPath.isObjectExpression() || parentPath.isObjectProperty() || parentPath.isUnaryExpression()) {
return shouldWrapInClosure(parentPath);
}
if (!grandparentPath || !parentPath.isExpression()) {
return false;
}
var maybeNestedConditional = isPossiblyDynamic(grandparentPath);
if (parentPath.isLogicalExpression()) {
return !maybeNestedConditional && parentPath.get('right').node === path.node;
return !path.isCallExpression() || parentPath.get('right').node === path.node || shouldWrapInClosure(parentPath);
}
if (parentPath.isConditionalExpression()) {
return !maybeNestedConditional && parentPath.get('test').node !== path.node;
return !path.isCallExpression() || parentPath.get('test').node !== path.node || shouldWrapInClosure(parentPath);
}
return maybeNestedConditional;
var functionParent = path.getFunctionParent();
if (!functionParent || parentPath.node === functionParent.node || parentPath.parent === functionParent.node) {
return false;
}
if ((parentPath.isReturnStatement() || parentPath.isExpressionStatement()) && parentPath.parentPath.isBlockStatement() && parentPath.parentPath.parent === functionParent.node) {
var body = functionParent.get('body.body');
return !Array.isArray(body) || body.length > 1;
}
return true;
}

@@ -61,3 +61,3 @@ {

"typings": "./index.d.ts",
"version": "2.0.3"
"version": "2.0.4"
}
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