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

babel-plugin-transform-pattern-matching

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-pattern-matching - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

2

package.json
{
"name": "babel-plugin-transform-pattern-matching",
"version": "0.0.9",
"version": "0.0.10",
"description": "transform pattern mathing",

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

@@ -146,2 +146,11 @@ 'use strict';

function reducer4(a, action, b) {
(0, _expr.babelPatternMatch)(action, {
addMultiple: function addMultiple(a, action, b) {
return a;
}
});
return a;
}
var reducer3 = new Reducer3();

@@ -151,4 +160,5 @@ exports.default = {

reducer2: Reducer2.reduce,
reducer3: reducer3.reduce.bind(reducer3)
reducer3: reducer3.reduce.bind(reducer3),
reducer4: reducer4
};
//# sourceMappingURL=ExampleReducer.js.map

@@ -173,2 +173,19 @@ 'use strict';

var _reducer = {
addMultiple: function addMultiple(a, action, b) {
return a;
}
};
function reducer4(a, action, b) {
switch (action.constructor) {
case TodoAddMultipleAction:
return _reducer.addMultiple(a, action, b);
default:
break;
}
return a;
}
var reducer3 = new Reducer3();

@@ -178,4 +195,5 @@ exports.default = {

reducer2: Reducer2.reduce,
reducer3: reducer3.reduce.bind(reducer3)
reducer3: reducer3.reduce.bind(reducer3),
reducer4: reducer4
};
//# sourceMappingURL=ExampleReducerTranspiled.js.map

@@ -6,3 +6,3 @@ 'use strict';

});
var findReducerExpressionVisitor = {
var findReducerExpressionVisitor = exports.findReducerExpressionVisitor = {
ExpressionStatement: function ExpressionStatement(path, state) {

@@ -18,3 +18,3 @@ var expr = path.node.expression;

var findReducerPropertyVisitor = {
'ClassMethod|ObjectMethod': function ClassMethodObjectMethod(path, state) {
'ClassMethod|ObjectMethod|FunctionDeclaration': function ClassMethodObjectMethodFunctionDeclaration(path, state) {
var propState = {

@@ -25,8 +25,5 @@ reducerLabel: state.reducerLabel,

};
if (!path.node) {
return;
}
path.traverse(findReducerExpressionVisitor, propState);
if (propState.expression) {
state.prop = path.node;
state.prop = path;
state.expressionParentPath = propState.expressionParentPath;

@@ -33,0 +30,0 @@ state.expression = propState.expression;

@@ -29,5 +29,3 @@ 'use strict';

visitor: {
'ClassDeclaration|ObjectExpression': function ClassDeclarationObjectExpression(path) {
var node = path.node;
'ClassDeclaration|ObjectExpression|Program': function ClassDeclarationObjectExpressionProgram(path) {
var state = {

@@ -40,12 +38,15 @@ reducerLabel: 'babelPatternMatch',

path.traverse(_findReducerPropertyVisitor2.default, state);
if (!state.prop || !state.expression) {
if (!state.expression) {
return;
}
var prop = state.prop;
var expression = state.expression;
var _state$expression$arg = _slicedToArray(state.expression.arguments, 2);
var args = prop.node.params;
var switchArg = _state$expression$arg[0];
var thisRef = _state$expression$arg[1];
var _expression$arguments = _slicedToArray(expression.arguments, 2);
var args = state.prop.params;
var switchArg = _expression$arguments[0];
var container = _expression$arguments[1];
var argNum = args.findIndex(function (_ref2) {

@@ -55,16 +56,21 @@ var name = _ref2.name;

});
var typesState = {
types: [],
skipProp: state.prop,
skipProp: prop.node,
argNum: argNum
};
path.traverse(_getTypesFromClassMethodsVisitor2.default, typesState);
var detectedThis = undefined;
if (path.isObjectExpression()) {
detectedThis = path.parent.id;
if (path.isProgram()) {
prop.traverse(_getTypesFromClassMethodsVisitor2.default, typesState);
} else {
detectedThis = state.prop.static ? node.id : t.thisExpression();
path.traverse(_getTypesFromClassMethodsVisitor2.default, typesState);
}
var thisRef = undefined;
if (path.isProgram()) {
thisRef = path.scope.generateUidIdentifier(prop.node.id.name);
prop.insertBefore(t.variableDeclaration('const', [t.variableDeclarator(thisRef, container)]));
} else if (path.isObjectExpression()) {
thisRef = container || path.parent.id;
} else if (path.isClassDeclaration()) {
thisRef = container || (prop.node.static ? path.node.id : t.thisExpression());
}

@@ -75,3 +81,3 @@ var switchCase = (0, _generateSwitchCase2.default)({

t: t,
thisRef: thisRef || detectedThis,
thisRef: thisRef,
typesMap: typesState.types

@@ -78,0 +84,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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