simplify define property by using a helper in playground object getter memoization
This commit is contained in:
@@ -3,7 +3,7 @@ var util = require("../../util");
|
||||
var t = require("../../types");
|
||||
|
||||
exports.Property =
|
||||
exports.MethodDefinition = function (node) {
|
||||
exports.MethodDefinition = function (node, parent, file) {
|
||||
if (node.kind !== "memo") return;
|
||||
node.kind = "get";
|
||||
|
||||
@@ -21,10 +21,11 @@ exports.MethodDefinition = function (node) {
|
||||
if (t.isFunction(node)) return;
|
||||
|
||||
if (t.isReturnStatement(node) && node.argument) {
|
||||
node.argument = t.memberExpression(util.template("object-getter-memoization", {
|
||||
KEY: key,
|
||||
VALUE: node.argument
|
||||
}), key, true);
|
||||
node.argument = t.memberExpression(t.callExpression(file.addDeclaration("define-property"), [
|
||||
t.thisExpression(),
|
||||
key,
|
||||
node.argument
|
||||
]), key, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user