33 lines
500 B
JavaScript
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);
|
|
}
|