Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var MODULE_NAME = 'AUDIENCE_EVALUATOR';
* @constructor
*/
function AudienceEvaluator(UNSTABLE_conditionEvaluators) {
this.typeToEvaluatorMap = fns.assignIn({}, UNSTABLE_conditionEvaluators, {
this.typeToEvaluatorMap = fns.assign({}, UNSTABLE_conditionEvaluators, {
'custom_attribute': customAttributeConditionEvaluator
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/optimizely-sdk/lib/core/decision_service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ DecisionService.prototype.__resolveExperimentBucketMap = function(userId, attrib
attributes = attributes || {}
var userProfile = this.__getUserProfile(userId) || {};
var attributeExperimentBucketMap = attributes[enums.CONTROL_ATTRIBUTES.STICKY_BUCKETING_KEY];
return fns.assignIn({}, userProfile.experiment_bucket_map, attributeExperimentBucketMap);
return fns.assign({}, userProfile.experiment_bucket_map, attributeExperimentBucketMap);
};


Expand Down
4 changes: 2 additions & 2 deletions packages/optimizely-sdk/lib/core/project_config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = {
fns.forEach(projectConfig.groupIdMap, function(group, Id) {
experiments = fns.cloneDeep(group.experiments);
fns.forEach(experiments, function(experiment) {
projectConfig.experiments.push(fns.assignIn(experiment, {groupId: Id}));
projectConfig.experiments.push(fns.assign(experiment, {groupId: Id}));
});
});

Expand All @@ -78,7 +78,7 @@ module.exports = {
experiment.variationKeyMap = fns.keyBy(experiment.variations, 'key');

// Creates { <variationId>: { key: <variationKey>, id: <variationId> } } mapping for quick lookup
fns.assignIn(projectConfig.variationIdMap, fns.keyBy(experiment.variations, 'id'));
fns.assign(projectConfig.variationIdMap, fns.keyBy(experiment.variations, 'id'));

fns.forOwn(experiment.variationKeyMap, function(variation) {
if (variation.variables) {
Expand Down
2 changes: 1 addition & 1 deletion packages/optimizely-sdk/lib/index.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ module.exports = {
eventDispatcher = config.eventDispatcher;
}

config = fns.assignIn(
config = fns.assign(
{
clientEngine: enums.JAVASCRIPT_CLIENT_ENGINE,
eventBatchSize: DEFAULT_EVENT_BATCH_SIZE,
Expand Down
2 changes: 1 addition & 1 deletion packages/optimizely-sdk/lib/index.react_native.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module.exports = {
config.skipJSONValidation = true;
}

config = fns.assignIn(
config = fns.assign(
{
clientEngine: enums.JAVASCRIPT_CLIENT_ENGINE,
eventBatchSize: DEFAULT_EVENT_BATCH_SIZE,
Expand Down
24 changes: 22 additions & 2 deletions packages/optimizely-sdk/lib/utils/fns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,28 @@ var keyBy = require('@optimizely/js-sdk-utils').keyBy;
var MAX_NUMBER_LIMIT = Math.pow(2, 53);

module.exports = {
assign: require('lodash/assign'),
assignIn: require('lodash/assignIn'),
assign: function (target) {
if (!target) {
return {};
}
if (typeof Object.assign === 'function') {
return Object.assign.apply(Object, arguments);
} else {
var to = Object(target);
for (var index = 1; index < arguments.length; index++) {
var nextSource = arguments[index];
if (nextSource !== null && nextSource !== undefined) {
for (var nextKey in nextSource) {
// Avoid bugs when hasOwnProperty is shadowed
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
to[nextKey] = nextSource[nextKey];
}
}
}
}
return to;
}
},
cloneDeep: require('lodash/cloneDeep'),
currentTimestamp: function() {
return Math.round(new Date().getTime());
Expand Down