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.8 to 0.0.9

2

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

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

@@ -5,2 +5,6 @@ 'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
var _expr = require('../../../expr');

@@ -86,8 +90,23 @@

var ExampleReducer = (function () {
function ExampleReducer() {
_classCallCheck(this, ExampleReducer);
var Reducer1 = {
reduce: function reduce(a, action, b) {
(0, _expr.babelPatternMatch)(action);
return a;
},
addMultiple: function addMultiple(a, action, b) {
return a;
},
addError: function addError(a, _ref, b) {
var error = _ref.error;
return a;
}
};
_createClass(ExampleReducer, [{
var Reducer2 = (function () {
function Reducer2() {
_classCallCheck(this, Reducer2);
}
_createClass(Reducer2, null, [{
key: 'reduce',

@@ -103,13 +122,34 @@ value: function reduce(a, action, b) {

}
}, {
key: 'addError',
value: function addError(a, _ref, b) {
var error = _ref.error;
}]);
return Reducer2;
})();
var Reducer3 = (function () {
function Reducer3() {
_classCallCheck(this, Reducer3);
}
_createClass(Reducer3, [{
key: 'reduce',
value: function reduce(a, action, b) {
(0, _expr.babelPatternMatch)(action);
return a;
}
}, {
key: 'addMultiple',
value: function addMultiple(a, action, b) {
return a;
}
}]);
return ExampleReducer;
return Reducer3;
})();
var reducer3 = new Reducer3();
exports.default = {
reducer1: Reducer1.reduce,
reducer2: Reducer2.reduce,
reducer3: reducer3.reduce.bind(reducer3)
};
//# sourceMappingURL=ExampleReducer.js.map

@@ -5,2 +5,6 @@ 'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});
var _expr = require('../../../expr');

@@ -86,8 +90,36 @@

var ExampleReducer = (function () {
function ExampleReducer() {
_classCallCheck(this, ExampleReducer);
var Reducer1 = {
reduce: function reduce(a, action, b) {
switch (action.constructor) {
case TodoAddMultipleAction:
return Reducer1.addMultiple(a, action, b);
case TodoAddMultipleErrorAction:
case TodoAddErrorAction:
case TodoCompleteErrorAction:
case TodoDestroyErrorAction:
return Reducer1.addError(a, action, b);
default:
break;
}
return a;
},
addMultiple: function addMultiple(a, action, b) {
return a;
},
addError: function addError(a, _ref, b) {
var error = _ref.error;
return a;
}
};
_createClass(ExampleReducer, [{
var Reducer2 = (function () {
function Reducer2() {
_classCallCheck(this, Reducer2);
}
_createClass(Reducer2, null, [{
key: 'reduce',

@@ -97,10 +129,4 @@ value: function reduce(a, action, b) {

case TodoAddMultipleAction:
return this.addMultiple(a, action, b);
return Reducer2.addMultiple(a, action, b);
case TodoAddMultipleErrorAction:
case TodoAddErrorAction:
case TodoCompleteErrorAction:
case TodoDestroyErrorAction:
return this.addError(a, action, b);
default:

@@ -117,13 +143,41 @@ break;

}
}, {
key: 'addError',
value: function addError(a, _ref, b) {
var error = _ref.error;
}]);
return Reducer2;
})();
var Reducer3 = (function () {
function Reducer3() {
_classCallCheck(this, Reducer3);
}
_createClass(Reducer3, [{
key: 'reduce',
value: function reduce(a, action, b) {
switch (action.constructor) {
case TodoAddMultipleAction:
return this.addMultiple(a, action, b);
default:
break;
}
return a;
}
}, {
key: 'addMultiple',
value: function addMultiple(a, action, b) {
return a;
}
}]);
return ExampleReducer;
return Reducer3;
})();
var reducer3 = new Reducer3();
exports.default = {
reducer1: Reducer1.reduce,
reducer2: Reducer2.reduce,
reducer3: reducer3.reduce.bind(reducer3)
};
//# sourceMappingURL=ExampleReducerTranspiled.js.map

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

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

@@ -24,2 +24,5 @@ reducerLabel: state.reducerLabel,

};
if (!path.node) {
return;
}
path.traverse(findReducerExpressionVisitor, propState);

@@ -26,0 +29,0 @@ if (propState.expression) {

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

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

@@ -41,3 +40,2 @@ var state = {

path.traverse(_findReducerPropertyVisitor2.default, state);
if (!state.prop || !state.expression) {

@@ -64,2 +62,10 @@ return;

path.traverse(_getTypesFromClassMethodsVisitor2.default, typesState);
var detectedThis = undefined;
if (path.isObjectExpression()) {
detectedThis = path.parent.id;
} else {
detectedThis = state.prop.static ? node.id : t.thisExpression();
}
var switchCase = (0, _generateSwitchCase2.default)({

@@ -69,3 +75,3 @@ args: args,

t: t,
thisRef: thisRef || t.thisExpression(),
thisRef: thisRef || detectedThis,
typesMap: typesState.types

@@ -72,0 +78,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