Skip to content

Commit 01a9e5d

Browse files
committed
Fix indentation and remove unnecessary if statement
1 parent ef3d200 commit 01a9e5d

File tree

1 file changed

+12
-15
lines changed
  • packages/optimizely-sdk/lib/optimizely

1 file changed

+12
-15
lines changed

packages/optimizely-sdk/lib/optimizely/index.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -545,22 +545,19 @@ export default class Optimizely {
545545
eventTags?: unknown
546546
): boolean {
547547
try {
548-
// Null, undefined or non-string user Id is invalid.
549-
if (typeof stringInputs === 'object' && stringInputs !== null) {
550-
if (stringInputs.hasOwnProperty('user_id')) {
551-
const userId = stringInputs['user_id'];
552-
if (typeof userId !== 'string' || userId === null || userId === 'undefined') {
553-
throw new Error(sprintf(ERROR_MESSAGES.INVALID_INPUT_FORMAT, MODULE_NAME, 'user_id'));
554-
}
555-
556-
delete stringInputs['user_id'];
548+
if (stringInputs.hasOwnProperty('user_id')) {
549+
const userId = stringInputs['user_id'];
550+
if (typeof userId !== 'string' || userId === null || userId === 'undefined') {
551+
throw new Error(sprintf(ERROR_MESSAGES.INVALID_INPUT_FORMAT, MODULE_NAME, 'user_id'));
557552
}
558-
Object.keys(stringInputs).forEach(key => {
559-
if (!stringValidator.validate(stringInputs[key])) {
560-
throw new Error(sprintf(ERROR_MESSAGES.INVALID_INPUT_FORMAT, MODULE_NAME, key));
561-
}
562-
})
553+
554+
delete stringInputs['user_id'];
563555
}
556+
Object.keys(stringInputs).forEach(key => {
557+
if (!stringValidator.validate(stringInputs[key])) {
558+
throw new Error(sprintf(ERROR_MESSAGES.INVALID_INPUT_FORMAT, MODULE_NAME, key));
559+
}
560+
})
564561
if (userAttributes) {
565562
validate(userAttributes);
566563
}
@@ -1343,7 +1340,7 @@ export default class Optimizely {
13431340
let resolveTimeoutPromise: (value: OnReadyResult) => void;
13441341
const timeoutPromise = new Promise<OnReadyResult>(
13451342
(resolve) => {
1346-
resolveTimeoutPromise = resolve;
1343+
resolveTimeoutPromise = resolve;
13471344
}
13481345
);
13491346

0 commit comments

Comments
 (0)