Skip to content
This repository has been archived by the owner on Sep 29, 2020. It is now read-only.

Commit

Permalink
Use Symbol() for metaFor, if available
Browse files Browse the repository at this point in the history
  • Loading branch information
jayphelps committed Sep 29, 2015
1 parent c5791db commit a1ffa78
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "core-decorators",
"version": "0.4.2",
"version": "0.4.3",
"description": "Library of ES7 decorators inspired by languages that come with built-ins like @override, @deprecated, etc",
"main": "lib/core-decorators.js",
"files": [
Expand Down
10 changes: 7 additions & 3 deletions src/private/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,19 @@ class Meta {
debounceTimeoutIds = {};
}

const META_KEY = (typeof Symbol === 'function')
? Symbol('__core_decorators__')
: '__core_decorators__';

export function metaFor(obj) {
if (obj.hasOwnProperty('__core_decorators__') === false) {
defineProperty(obj, '__core_decorators__', {
if (obj.hasOwnProperty(META_KEY) === false) {
defineProperty(obj, META_KEY, {
// Defaults: NOT enumerable, configurable, or writable
value: new Meta()
});
}

return obj.__core_decorators__;
return obj[META_KEY];
}

const getOwnKeys = getOwnPropertySymbols
Expand Down

0 comments on commit a1ffa78

Please sign in to comment.