Skip to content

Commit 1631558

Browse files
committed
Handle symbols
1 parent 4b3656f commit 1631558

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/getFlagsProxy.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ function hasFlag(flags: LDFlagSet, flagKey: string) {
5656
function toFlagsProxy(ldClient: LDClient, flags: LDFlagSet, flagKeyMap: LDFlagKeyMap): LDFlagSet {
5757
return new Proxy(flags, {
5858
// trap for reading a flag value that refreshes its value with `LDClient#variation` to trigger an evaluation event
59-
get(target, flagKey: string, receiver) {
60-
const currentValue = Reflect.get(target, flagKey, receiver);
59+
get(target, prop, receiver) {
60+
const currentValue = Reflect.get(target, prop, receiver);
61+
if (typeof prop === 'symbol') {
62+
return currentValue;
63+
}
6164
if (currentValue === undefined) {
6265
return;
6366
}
64-
const originalFlagKey = hasFlag(flagKeyMap, flagKey) ? flagKeyMap[flagKey] : flagKey;
67+
const originalFlagKey = hasFlag(flagKeyMap, prop) ? flagKeyMap[prop] : prop;
6568
const nextValue = ldClient.variation(originalFlagKey, currentValue);
66-
Reflect.set(target, flagKey, nextValue, receiver);
69+
Reflect.set(target, prop, nextValue, receiver);
6770

6871
return nextValue;
6972
},

0 commit comments

Comments
 (0)