-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Expand file tree
/
Copy pathsymbol.ts
More file actions
28 lines (22 loc) · 911 Bytes
/
symbol.ts
File metadata and controls
28 lines (22 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { DEBUG } from '@glimmer/env';
import { GUID_KEY } from './guid';
import intern from './intern';
const GENERATED_SYMBOLS: string[] = [];
export function isInternalSymbol(possibleSymbol: string) {
return GENERATED_SYMBOLS.indexOf(possibleSymbol) !== -1;
}
// Some legacy symbols still need to be enumerable for a variety of reasons.
// This code exists for that, and as a fallback in IE11. In general, prefer
// `symbol` below when creating a new symbol.
export function enumerableSymbol(debugName: string): string {
// TODO: Investigate using platform symbols, but we do not
// want to require non-enumerability for this API, which
// would introduce a large cost.
let id = GUID_KEY + Math.floor(Math.random() * Date.now()).toString();
let symbol = intern(`__${debugName}${id}__`);
if (DEBUG) {
GENERATED_SYMBOLS.push(symbol);
}
return symbol;
}
export const symbol = Symbol;