Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 32cb7bf

Browse files
refactor: Convert lib/core to ES module (Part 1/2) (optimizely#449)
Summary: This converts these folders inside lib/core to ESModule. lib/core/ audience_evaluator, bucketer, condition_tree_evaluator, custom_attribute_condition_evaluator, decision_service Test plan: All unit test and Full stack compatibility suite tests pass. Co-authored-by: Zeeshan Ashraf <zashraf@folio3.com> Co-authored-by: zashraf1985 <35262377+zashraf1985@users.noreply.github.com>
1 parent e423ec3 commit 32cb7bf

File tree

10 files changed

+272
-262
lines changed

10 files changed

+272
-262
lines changed

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016, 2018-2019 Optimizely
2+
* Copyright 2016, 2018-2020, Optimizely
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,17 +13,19 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
var conditionTreeEvaluator = require('../condition_tree_evaluator');
17-
var customAttributeConditionEvaluator = require('../custom_attribute_condition_evaluator');
18-
var enums = require('../../utils/enums');
19-
var fns = require('../../utils/fns');
20-
var sprintf = require('@optimizely/js-sdk-utils').sprintf;
21-
var logging = require('@optimizely/js-sdk-logging');
22-
var logger = logging.getLogger();
16+
import { sprintf } from '@optimizely/js-sdk-utils';
17+
import { getLogger } from '@optimizely/js-sdk-logging';
2318

24-
var ERROR_MESSAGES = enums.ERROR_MESSAGES;
25-
var LOG_LEVEL = enums.LOG_LEVEL;
26-
var LOG_MESSAGES = enums.LOG_MESSAGES;
19+
import fns from '../../utils/fns';
20+
import {
21+
LOG_LEVEL,
22+
LOG_MESSAGES,
23+
ERROR_MESSAGES,
24+
} from '../../utils/enums';
25+
import conditionTreeEvaluator from '../condition_tree_evaluator';
26+
import customAttributeConditionEvaluator from '../custom_attribute_condition_evaluator';
27+
28+
var logger = getLogger();
2729
var MODULE_NAME = 'AUDIENCE_EVALUATOR';
2830

2931
/**
@@ -108,4 +110,4 @@ AudienceEvaluator.prototype.evaluateConditionWithUserAttributes = function(userA
108110
return null;
109111
};
110112

111-
module.exports = AudienceEvaluator;
113+
export default AudienceEvaluator;

packages/optimizely-sdk/lib/core/audience_evaluator/index.tests.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2016, 2018-2019 Optimizely
2+
* Copyright 2016, 2018-2020, Optimizely
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,16 +13,15 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
var AudienceEvaluator = require('./');
17-
var chai = require('chai');
18-
var conditionTreeEvaluator = require('../condition_tree_evaluator');
19-
var customAttributeConditionEvaluator = require('../custom_attribute_condition_evaluator');
20-
var sinon = require('sinon');
21-
var assert = chai.assert;
22-
var logging = require('@optimizely/js-sdk-logging');
23-
var mockLogger = logging.getLogger();
24-
var enums = require('../../utils/enums');
25-
var LOG_LEVEL = enums.LOG_LEVEL;
16+
import sinon from 'sinon';
17+
import { assert } from 'chai';
18+
import { getLogger } from '@optimizely/js-sdk-logging';
19+
20+
import AudienceEvaluator from './index';
21+
import conditionTreeEvaluator from '../condition_tree_evaluator';
22+
import customAttributeConditionEvaluator from '../custom_attribute_condition_evaluator';
23+
24+
var mockLogger = getLogger();
2625

2726
var chromeUserAudience = {
2827
conditions: [

0 commit comments

Comments
 (0)