Files
babel/src/babel/traversal/path/conversion.js
2015-06-21 23:59:14 +01:00

33 lines
500 B
JavaScript

import * as t from "../../types";
/**
* Description
*/
export function toComputedKey(): Object {
var node = this.node;
var key;
if (this.isMemberExpression()) {
key = node.property;
} else if (this.isProperty()) {
key = node.key;
} else {
throw new ReferenceError("todo");
}
if (!node.computed) {
if (t.isIdentifier(key)) key = t.literal(key.name);
}
return key;
}
/**
* Description
*/
export function ensureBlock() {
return t.ensureBlock(this.node);
}