Skip to content

Commit 25c8bd0

Browse files
authored
feat: Convert event_processor_config_validator to TS (#565)
* Convert event_processor_config_validator to TS * Use default export object to avoid issues with stubbing
1 parent 70203de commit 25c8bd0

File tree

1 file changed

+17
-11
lines changed
  • packages/optimizely-sdk/lib/utils/event_processor_config_validator

1 file changed

+17
-11
lines changed

packages/optimizely-sdk/lib/utils/event_processor_config_validator/index.js renamed to packages/optimizely-sdk/lib/utils/event_processor_config_validator/index.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,29 @@ import { isSafeInteger } from '../fns';
1717

1818
/**
1919
* Return true if the argument is a valid event batch size, false otherwise
20-
* @param {*} eventBatchSize
21-
* @returns boolean
20+
* @param {unknown} eventBatchSize
21+
* @returns {boolean}
2222
*/
23-
export var validateEventBatchSize = function(eventBatchSize) {
24-
return isSafeInteger(eventBatchSize) && eventBatchSize >= 1;
25-
};
23+
const validateEventBatchSize = function(eventBatchSize: unknown): boolean {
24+
if (typeof eventBatchSize === 'number' && isSafeInteger(eventBatchSize)) {
25+
return eventBatchSize >= 1;
26+
}
27+
return false;
28+
}
2629

2730
/**
2831
* Return true if the argument is a valid event flush interval, false otherwise
29-
* @param {*} eventFlushInterval
30-
* @returns boolean
32+
* @param {unknown} eventFlushInterval
33+
* @returns {boolean}
3134
*/
32-
export var validateEventFlushInterval = function(eventFlushInterval) {
33-
return isSafeInteger(eventFlushInterval) && eventFlushInterval > 0;
34-
};
35+
const validateEventFlushInterval = function(eventFlushInterval: unknown): boolean {
36+
if (typeof eventFlushInterval === 'number' && isSafeInteger(eventFlushInterval)) {
37+
return eventFlushInterval > 0;
38+
}
39+
return false;
40+
}
3541

3642
export default {
3743
validateEventBatchSize: validateEventBatchSize,
3844
validateEventFlushInterval: validateEventFlushInterval,
39-
};
45+
}

0 commit comments

Comments
 (0)