Skip to content

Instantly share code, notes, and snippets.

@bryanforbes
Created May 2, 2015 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryanforbes/f274930aed6bf3cd900c to your computer and use it in GitHub Desktop.
Save bryanforbes/f274930aed6bf3cd900c to your computer and use it in GitHub Desktop.
export function hidden(target: Object, key: string): void {
// Define a non-enumerable property on the prototype
Object.defineProperty(target, key, {
enumerable: false,
set: function (value) {
// The first time the property is set on an instance, define a non-enumerable property on the instance
Object.defineProperty(this, key, {
enumerable: false,
writable: true,
value: value
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment