@@ -8,26 +8,26 @@ import { SwitcherResult } from './result.js';
88 *
99 * @param {SnapshotData } data - The snapshot data containing domain and group information.
1010 * @param {SwitcherRequest } switcher - The switcher request to be evaluated.
11- * @returns {Promise< SwitcherResult> } - The result of the switcher evaluation.
11+ * @returns {SwitcherResult } - The result of the switcher evaluation.
1212 */
13- async function resolveCriteria ( data , switcher ) {
13+ function resolveCriteria ( data , switcher ) {
1414 if ( ! data . domain . activated ) {
1515 return SwitcherResult . disabled ( 'Domain disabled' ) ;
1616 }
1717
1818 const { group } = data . domain ;
19- return await checkGroup ( group , switcher ) ;
19+ return checkGroup ( group , switcher ) ;
2020}
2121
2222/**
2323 * Checks if a switcher is valid within a specific group of the domain.
2424 *
2525 * @param {Group[] } groups - The list of groups to check against.
2626 * @param {SwitcherRequest } switcher - The switcher request to be evaluated.
27- * @returns {Promise< SwitcherResult> } - The result of the switcher evaluation.
27+ * @returns {SwitcherResult } - The result of the switcher evaluation.
2828 * @throws {Error } - If the switcher key is not found in any group.
2929 */
30- async function checkGroup ( groups , switcher ) {
30+ function checkGroup ( groups , switcher ) {
3131 const key = util . get ( switcher . key , '' ) ;
3232
3333 for ( const group of groups ) {
@@ -39,7 +39,7 @@ async function checkGroup(groups, switcher) {
3939 return SwitcherResult . disabled ( 'Group disabled' ) ;
4040 }
4141
42- return await checkConfig ( configFound [ 0 ] , switcher ) ;
42+ return checkConfig ( configFound [ 0 ] , switcher ) ;
4343 }
4444 }
4545
@@ -53,9 +53,9 @@ async function checkGroup(groups, switcher) {
5353 *
5454 * @param {Config } config Configuration to check
5555 * @param {SwitcherRequest } switcher - The switcher request to be evaluated.
56- * @return {Promise< SwitcherResult> } - The result of the switcher evaluation.
56+ * @return {SwitcherResult } - The result of the switcher evaluation.
5757 */
58- async function checkConfig ( config , switcher ) {
58+ function checkConfig ( config , switcher ) {
5959 if ( ! config . activated ) {
6060 return SwitcherResult . disabled ( 'Config disabled' ) ;
6161 }
@@ -65,7 +65,7 @@ async function checkConfig(config, switcher) {
6565 }
6666
6767 if ( config . strategies ) {
68- return await checkStrategy ( config , switcher . input ) ;
68+ return checkStrategy ( config , switcher . input ) ;
6969 }
7070
7171 return SwitcherResult . enabled ( ) ;
@@ -76,9 +76,9 @@ async function checkConfig(config, switcher) {
7676 *
7777 * @param {Config } config - The configuration containing strategies.
7878 * @param {string[][] } [input] - The input data to be evaluated against the strategies.
79- * @returns {Promise< SwitcherResult> } - The result of the strategy evaluation.
79+ * @returns {SwitcherResult } - The result of the strategy evaluation.
8080 */
81- async function checkStrategy ( config , input ) {
81+ function checkStrategy ( config , input ) {
8282 const { strategies } = config ;
8383 const entry = getEntry ( util . get ( input , [ ] ) ) ;
8484
@@ -87,7 +87,7 @@ async function checkStrategy(config, input) {
8787 continue ;
8888 }
8989
90- const strategyResult = await checkStrategyConfig ( strategyConfig , entry ) ;
90+ const strategyResult = checkStrategyConfig ( strategyConfig , entry ) ;
9191 if ( strategyResult ) {
9292 return strategyResult ;
9393 }
@@ -101,15 +101,15 @@ async function checkStrategy(config, input) {
101101 *
102102 * @param {Strategy } strategyConfig - The strategy configuration to be checked.
103103 * @param {Entry[] } [entry] - The entry data to be evaluated against the strategy.
104- * @returns {Promise< SwitcherResult | undefined> } - The result of the strategy evaluation or undefined if valid.
104+ * @returns {SwitcherResult | undefined } - The result of the strategy evaluation or undefined if valid.
105105 */
106- async function checkStrategyConfig ( strategyConfig , entry ) {
106+ function checkStrategyConfig ( strategyConfig , entry ) {
107107 if ( ! entry ?. length ) {
108108 return SwitcherResult . disabled ( `Strategy '${ strategyConfig . strategy } ' did not receive any input` ) ;
109109 }
110110
111111 const strategyEntry = entry . filter ( ( e ) => e . strategy === strategyConfig . strategy ) ;
112- if ( await isStrategyFulfilled ( strategyEntry , strategyConfig ) ) {
112+ if ( isStrategyFulfilled ( strategyEntry , strategyConfig ) ) {
113113 return SwitcherResult . disabled ( `Strategy '${ strategyConfig . strategy } ' does not agree` ) ;
114114 }
115115
@@ -120,20 +120,19 @@ function hasRelayEnabled(config) {
120120 return config . relay ?. activated ;
121121}
122122
123- async function isStrategyFulfilled ( strategyEntry , strategyConfig ) {
124- return strategyEntry . length == 0 ||
125- ! ( await processOperation ( strategyConfig , strategyEntry [ 0 ] . input ) ) ;
123+ function isStrategyFulfilled ( strategyEntry , strategyConfig ) {
124+ return strategyEntry . length == 0 || ! processOperation ( strategyConfig , strategyEntry [ 0 ] . input ) ;
126125}
127126
128127/**
129128 * Checks the criteria for a switcher request against the local snapshot.
130129 *
131130 * @param {Snapshot | undefined } snapshot - The snapshot containing the data to check against.
132131 * @param {SwitcherRequest } switcher - The switcher request to be evaluated.
133- * @returns {Promise< SwitcherResult> } - The result of the switcher evaluation.
132+ * @returns {SwitcherResult } - The result of the switcher evaluation.
134133 * @throws {Error } - If the snapshot is not loaded.
135134 */
136- export default async function checkCriteriaLocal ( snapshot , switcher ) {
135+ export default function checkCriteriaLocal ( snapshot , switcher ) {
137136 if ( ! snapshot ) {
138137 throw new Error ( 'Snapshot not loaded. Try to use \'Client.loadSnapshot()\'' ) ;
139138 }
0 commit comments