use ast-types instead of using a template

This commit is contained in:
Sebastian McKenzie
2014-10-13 14:25:00 +11:00
parent 0ce6f21a14
commit 8bc182fdb5
2 changed files with 14 additions and 11 deletions

View File

@@ -47,11 +47,15 @@ exports.ObjectExpression = function (node, parent, file) {
containerCallee._aliasFunction = "arrows";
_.each(computed, function (prop) {
containerBody.unshift(util.template("obj-key-set", {
OBJECT_KEY: objId,
KEY: prop.key,
VALUE: prop.value
}, true));
containerBody.unshift(
b.expressionStatement(
b.assignmentExpression(
"=",
b.memberExpression(objId, prop.key, true),
prop.value
)
)
);
});
return container;

View File

@@ -49,14 +49,13 @@ var pushArrayPattern = function (kind, nodes, pattern, parentId) {
var pushPattern = function (kind, nodes, pattern, parentId, file) {
if (parentId.type !== "MemberExpression" && parentId.type !== "Identifier") {
var key = file.generateUid("ref");
var key = b.identifier(file.generateUid("ref"));
nodes.push(util.template("variable-assign", {
KEY: key,
VALUE: parentId
}, true));
nodes.push(b.variableDeclaration("var", [
b.variableDeclarator(key, parentId)
]));
parentId = b.identifier(key);
parentId = key;
}
push(kind, nodes, pattern, parentId);