Skip to content

Instantly share code, notes, and snippets.

@bryanforbes
Created April 29, 2015 18:11
Show Gist options
  • Save bryanforbes/ce23c275df6ba343c782 to your computer and use it in GitHub Desktop.
Save bryanforbes/ce23c275df6ba343c782 to your computer and use it in GitHub Desktop.
var __decorate = this.__decorate || function (decorators, target, key, desc) {
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc);
switch (arguments.length) {
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);
case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);
case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);
}
};
function enumerable(enumerable) {
if (enumerable === void 0) { enumerable = true; }
return function (target, propertyKey) {
Object.defineProperty(target, propertyKey, {
configurable: true,
writable: true,
enumerable: false
});
};
}
var MyClass = (function () {
function MyClass() {
this.property = 'initial value';
}
__decorate([
enumerable(false)
], MyClass.prototype, "property");
return MyClass;
})();
var mc = new MyClass();
for (var key in mc) {
console.log(key);
}
function enumerable(enumerable: boolean = true): PropertyDecorator {
return function (target: Object, propertyKey: string): void {
Object.defineProperty(target, propertyKey, {
configurable: true,
writable: true,
enumerable: false
});
};
}
class MyClass {
@enumerable(false)
property: string = 'initial value';
}
var mc = new MyClass();
for (var key in mc) {
console.log(key);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment