add object getter memoization and this shorthand to playground

This commit is contained in:
Sebastian McKenzie
2014-12-06 19:37:23 +11:00
parent aa298b1e0a
commit a7a6ee80f2
5 changed files with 166 additions and 4 deletions

View File

@@ -0,0 +1,19 @@
class Foo {
memo bar() {
return complex();
}
memo [bar]() {
return complex();
}
}
var foo = {
memo bar() {
return complex();
},
memo [bar]() {
return complex();
}
};

View File

@@ -0,0 +1,53 @@
"use strict";
var _classProps = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var Foo = (function () {
var Foo = function Foo() {};
_classProps(Foo, null, (function (_ref) {
_ref[bar] = {
get: function () {
if (this._memoDone) return this._memo;
this._memoDone = true;
return this._memo = complex();
}
};
return _ref;
})({
bar: {
get: function () {
if (this._barDone) return this._bar;
this._barDone = true;
return this._bar = complex();
}
}
}));
return Foo;
})();
var foo = (function (_foo) {
_foo[bar] = function () {
if (this._memo2Done) return this._memo2;
this._memo2Done = true;
return this._memo2 = complex();
};
return _foo;
})((function (_ref2) {
Object.defineProperties(_ref2, {
bar: {
get: function () {
if (this._barDone) return this._bar;
this._barDone = true;
return this._bar = complex();
}
}
});
return _ref2;
})({}));