Skip to content

Commit e78b60a

Browse files
authored
Merge branch 'master' into zeeshan/replace_lodash_values
2 parents 139cf4b + ee5a24d commit e78b60a

File tree

8 files changed

+12
-18
lines changed

8 files changed

+12
-18
lines changed

packages/optimizely-sdk/lib/core/decision_service/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ DecisionService.prototype.__checkIfExperimentIsActive = function(configObj, expe
144144
* @return {string|null} Forced variation if it exists for user ID, otherwise null
145145
*/
146146
DecisionService.prototype.__getWhitelistedVariation = function(experiment, userId) {
147-
if (!fns.isEmpty(experiment.forcedVariations) && experiment.forcedVariations.hasOwnProperty(userId)) {
147+
if (experiment.forcedVariations && experiment.forcedVariations.hasOwnProperty(userId)) {
148148
var forcedVariationKey = experiment.forcedVariations[userId];
149149
if (experiment.variationKeyMap.hasOwnProperty(forcedVariationKey)) {
150150
var forcedBucketingSucceededMessageLog = sprintf(LOG_MESSAGES.USER_FORCED_IN_VARIATION, MODULE_NAME, userId, forcedVariationKey);

packages/optimizely-sdk/lib/core/project_config/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ module.exports = {
122122
*/
123123
getExperimentId: function(projectConfig, experimentKey) {
124124
var experiment = projectConfig.experimentKeyMap[experimentKey];
125-
if (fns.isEmpty(experiment)) {
125+
if (!experiment) {
126126
throw new Error(sprintf(ERROR_MESSAGES.INVALID_EXPERIMENT_KEY, MODULE_NAME, experimentKey));
127127
}
128128
return experiment.id;
@@ -137,7 +137,7 @@ module.exports = {
137137
*/
138138
getLayerId: function(projectConfig, experimentId) {
139139
var experiment = projectConfig.experimentIdMap[experimentId];
140-
if (fns.isEmpty(experiment)) {
140+
if (!experiment) {
141141
throw new Error(sprintf(ERROR_MESSAGES.INVALID_EXPERIMENT_ID, MODULE_NAME, experimentId));
142142
}
143143
return experiment.layerId;
@@ -190,7 +190,7 @@ module.exports = {
190190
*/
191191
getExperimentStatus: function(projectConfig, experimentKey) {
192192
var experiment = projectConfig.experimentKeyMap[experimentKey];
193-
if (fns.isEmpty(experiment)) {
193+
if (!experiment) {
194194
throw new Error(sprintf(ERROR_MESSAGES.INVALID_EXPERIMENT_KEY, MODULE_NAME, experimentKey));
195195
}
196196
return experiment.status;
@@ -224,7 +224,7 @@ module.exports = {
224224
*/
225225
getExperimentAudienceConditions: function(projectConfig, experimentKey) {
226226
var experiment = projectConfig.experimentKeyMap[experimentKey];
227-
if (fns.isEmpty(experiment)) {
227+
if (!experiment) {
228228
throw new Error(sprintf(ERROR_MESSAGES.INVALID_EXPERIMENT_KEY, MODULE_NAME, experimentKey));
229229
}
230230

@@ -286,7 +286,7 @@ module.exports = {
286286
*/
287287
getTrafficAllocation: function(projectConfig, experimentKey) {
288288
var experiment = projectConfig.experimentKeyMap[experimentKey];
289-
if (fns.isEmpty(experiment)) {
289+
if (!experiment) {
290290
throw new Error(sprintf(ERROR_MESSAGES.INVALID_EXPERIMENT_KEY, MODULE_NAME, experimentKey));
291291
}
292292
return experiment.trafficAllocation;

packages/optimizely-sdk/lib/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ declare module "@optimizely/optimizely-sdk" {
115115
onReady(options?: {
116116
timeout?: number;
117117
}): Promise<{ success: boolean; reason?: string }>;
118-
close(): void;
118+
close(): Promise<{ success: boolean; reason?: string }>;
119119
}
120120

121121
// An event to be submitted to Optimizely, enabling tracking the reach and impact of

packages/optimizely-sdk/lib/optimizely/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ Optimizely.prototype.getVariation = function(experimentKey, userId, attributes)
375375
}
376376

377377
var experiment = configObj.experimentKeyMap[experimentKey];
378-
if (fns.isEmpty(experiment)) {
378+
if (!experiment) {
379379
this.logger.log(LOG_LEVEL.DEBUG, sprintf(ERROR_MESSAGES.INVALID_EXPERIMENT_KEY, MODULE_NAME, experimentKey));
380380
return null;
381381
}

packages/optimizely-sdk/lib/plugins/event_dispatcher/index.browser.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
var fns = require('../../utils/fns');
17-
1816
var POST_METHOD = 'POST';
1917
var GET_METHOD = 'GET';
2018
var READYSTATE_COMPLETE = 4;
@@ -68,7 +66,7 @@ module.exports = {
6866
};
6967

7068
var toQueryString = function(obj) {
71-
return fns.map(obj, function(v, k) {
72-
return encodeURIComponent(k) + '=' + encodeURIComponent(v);
69+
return Object.keys(obj).map(function(k) {
70+
return encodeURIComponent(k) + '=' + encodeURIComponent(obj[k]);
7371
}).join('&');
7472
};

packages/optimizely-sdk/lib/utils/fns/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,12 @@ module.exports = {
2525
currentTimestamp: function() {
2626
return Math.round(new Date().getTime());
2727
},
28-
isArray: require('lodash/isArray'),
29-
isEmpty: require('lodash/isEmpty'),
3028
isFinite: function(number) {
3129
return _isFinite(number) && Math.abs(number) <= MAX_NUMBER_LIMIT;
3230
},
3331
keyBy: require('lodash/keyBy'),
3432
forEach: require('lodash/forEach'),
3533
forOwn: require('lodash/forOwn'),
36-
map: require('lodash/map'),
3734
uuid: function() {
3835
return uuid.v4();
3936
},

packages/optimizely-sdk/lib/utils/fns/index.tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ describe('lib/utils/fns', function() {
3838
});
3939
});
4040
});
41-
});
41+
});

packages/optimizely-sdk/lib/utils/json_schema_validator/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
var fns = require('../fns');
1716
var validate = require('json-schema').validate;
1817
var sprintf = require('@optimizely/js-sdk-utils').sprintf;
1918

@@ -40,7 +39,7 @@ module.exports = {
4039
if (result.valid) {
4140
return true;
4241
} else {
43-
if (fns.isArray(result.errors)) {
42+
if (Array.isArray(result.errors)) {
4443
throw new Error(sprintf(ERROR_MESSAGES.INVALID_DATAFILE, MODULE_NAME, result.errors[0].property, result.errors[0].message));
4544
}
4645
throw new Error(sprintf(ERROR_MESSAGES.INVALID_JSON, MODULE_NAME));

0 commit comments

Comments
 (0)