Skip to content

Commit

Permalink
chore: addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishmalik committed Feb 28, 2024
1 parent a7f2098 commit a0493a0
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/v0/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2204,21 +2204,20 @@ const combineBatchRequestsWithSameJobIds = (inputBatches) => {
/**
* This function validates the event and return it as string.
* @param {*} isMandatory The event is a required field.
* @param {*} converToLowercase The event should be converted to lower-case.
* @param {*} convertToLowerCase The event should be converted to lower-case.
* @returns {string} Event name converted to string.
*/
const validateEventAndLowerCaseConversion = (event, isMandatory, converToLowercase) => {
const validateEventAndLowerCaseConversion = (event, isMandatory, convertToLowerCase) => {
if (typeof event === 'object' || !isDefined(event)) {
throw new InstrumentationError('Event should not be a object, function or NaN and undefined');
}
if (!isMandatory) {
return converToLowercase ? event.toString().toLowerCase() : event.toString();
throw new InstrumentationError('Event should not be a object, function, NaN or undefined');

Check warning on line 2212 in src/v0/util/index.js

View check run for this annotation

Codecov / codecov/patch

src/v0/util/index.js#L2212

Added line #L2212 was not covered by tests
}

// handling 0 as it is a valid value
if (!event && event !== 0) {
if (isMandatory && !event && event !== 0) {
throw new InstrumentationError('Event is a required field');

Check warning on line 2217 in src/v0/util/index.js

View check run for this annotation

Codecov / codecov/patch

src/v0/util/index.js#L2217

Added line #L2217 was not covered by tests
}
return converToLowercase ? event.toString().toLowerCase() : event.toString();

return convertToLowerCase ? event.toString().toLowerCase() : event.toString();
};

// ========================================================================
Expand Down

0 comments on commit a0493a0

Please sign in to comment.