var Leaf;
(function (Leaf) {
    var Property = (function () {
        function Property() {
        }
        Property.define = function (who, name, def) {
            var cache = {};
            if (def.value)
                cache.value = def.value;
            var getFn = function (cache) {
                return cache.value;
            };
            var setFn = function (value, cache) {
                cache.value = value;
                return cache.value;
            };
            var getIt = def.get || getFn;
            var setIt = def.set || setFn;
            Object.defineProperty(who, name, {
                get: function () {
                    return getIt(cache);
                },
                set: function (v) {
                    return setIt(v, cache);
                }
            });
            return def.value || null;
        };
        Property.with = function (who) {
            return new WithProperty(who);
        };
        return Property;
    }());
    Leaf.Property = Property;
    var WithProperty = (function () {
        function WithProperty(who) {
            this.who = who;
        }
        WithProperty.prototype.define = function (name, def) {
            Property.define(this.who, name, def);
            return this;
        };
        return WithProperty;
    }());
    Leaf.WithProperty = WithProperty;
})(Leaf || (Leaf = {}));
//# sourceMappingURL=property.js.map