From ee58b46194ca56126c541d4a2b5705a4f5cc6239 Mon Sep 17 00:00:00 2001 From: Alexis Georges Date: Tue, 25 Oct 2016 18:50:59 -0700 Subject: [PATCH] check flags exists before reading --- src/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index b864cb34..fa134587 100644 --- a/src/index.js +++ b/src/index.js @@ -87,8 +87,8 @@ function identify(user, hash, onDone) { function variation(key, defaultValue) { var value; - - if (flags.hasOwnProperty(key)) { + + if (flags && flags.hasOwnProperty(key)) { value = flags[key] === null ? defaultValue : flags[key]; } else { value = defaultValue; @@ -101,6 +101,9 @@ function variation(key, defaultValue) { function allFlags() { var results = {}; + + if (!flags) { return results; } + for (var key in flags) { if (flags.hasOwnProperty(key)) { results[key] = variation(key, null);