babel-plugin-idx
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -49,2 +49,10 @@ /** | ||
}, { | ||
key: 'appendMethodCall', | ||
value: function appendMethodCall(args) { | ||
var uid = this.generateUid('ref').name; | ||
var callExpression = t.CallExpression(t.Identifier(uid), args || []); | ||
this.addLevel(callExpression, uid); | ||
this.uids.push(uid); | ||
} | ||
}, { | ||
key: 'appendPropertyAccess', | ||
@@ -83,3 +91,5 @@ value: function appendPropertyAccess(property, computed) { | ||
function getExpressionChainBase(node) { | ||
if (t.isMemberExpression(node)) { | ||
if (t.isCallExpression(node)) { | ||
return getExpressionChainBase(node.callee); | ||
} else if (t.isMemberExpression(node)) { | ||
return getExpressionChainBase(node.object); | ||
@@ -96,6 +106,10 @@ } else { | ||
function constructTernary(base, node, generateUid) { | ||
if (t.isMemberExpression(node)) { | ||
var transformedObject = constructTernary(base, node.object, generateUid); | ||
transformedObject.appendPropertyAccess(node.property, node.computed); | ||
if (t.isCallExpression(node)) { | ||
var transformedObject = constructTernary(base, node.callee, generateUid); | ||
transformedObject.appendMethodCall(node.arguments); | ||
return transformedObject; | ||
} else if (t.isMemberExpression(node)) { | ||
var _transformedObject = constructTernary(base, node.object, generateUid); | ||
_transformedObject.appendPropertyAccess(node.property, node.computed); | ||
return _transformedObject; | ||
} else { | ||
@@ -102,0 +116,0 @@ return new TransformedTernary(base, generateUid); |
{ | ||
"name": "babel-plugin-idx", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Babel plugin for transforming the idx utility function.", | ||
@@ -5,0 +5,0 @@ "main": "lib/babel-plugin-idx.js", |
7584
119