Skip to content

Commit

Permalink
fix: optimize function
Browse files Browse the repository at this point in the history
  • Loading branch information
solaris007 committed Dec 2, 2023
1 parent 6618cf2 commit 1badcdf
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/lhs/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,16 @@ const AUDIT_TYPES = {
* @throws {Error} - Throws an error if the type is not supported.
*/
const typeToPSIStrategy = (type) => {
let strategy;
switch (type) {
case AUDIT_TYPES.MOBILE:
strategy = 'mobile';
break;
case AUDIT_TYPES.DESKTOP:
strategy = 'desktop';
break;
default:
throw new Error('Unsupported type. Supported types are lhs-mobile and lhs-desktop.');
const strategyMap = {
[AUDIT_TYPES.MOBILE]: 'mobile',
[AUDIT_TYPES.DESKTOP]: 'desktop',
};

if (!strategyMap[type]) {
throw new Error('Unsupported type. Supported types are lhs-mobile and lhs-desktop.');
}
return strategy;

return strategyMap[type];
};

/**
Expand Down

0 comments on commit 1badcdf

Please sign in to comment.