generator: add support for method properties and computed keys and shorthand

This commit is contained in:
Sebastian McKenzie 2014-10-31 21:21:50 +11:00
parent 0def62b918
commit 5c5348537d

View File

@ -22,7 +22,7 @@ exports.ObjectPattern = function (node, print) {
this.push(" ");
} else {
this.newline();
this.printJoin(print, props, ",\n", true);
this.printJoin(print, props, ",\n", { indent: true });
this.newline();
}
@ -34,9 +34,17 @@ exports.ObjectPattern = function (node, print) {
exports.Property = function (node, print) {
if (node.method || node.kind === "get" || node.kind === "set") {
throw new Error("Property");
this._method(node, print);
} else {
print(node.key);
if (node.computed) {
this.push("[");
print(node.key);
this.push("]");
} else {
print(node.key);
if (node.shorthand) return;
}
this.push(": ");
print(node.value);
}