-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: move sdk code to limit number of new deps #3259
fix: move sdk code to limit number of new deps #3259
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code changes approved, not tested 👍
d1c8b50
to
9df2664
Compare
assertLength(expectedLength, target); | ||
// eslint-disable-next-line wrap-regex | ||
if (target.length > 0 && !/^[\da-f]+$/i.test(target)) { | ||
throw new Error('expected hex string'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code more readable and removes need for eslint comment
assertLength(expectedLength, target); | |
// eslint-disable-next-line wrap-regex | |
if (target.length > 0 && !/^[\da-f]+$/i.test(target)) { | |
throw new Error('expected hex string'); | |
} | |
assertLength(expectedLength, target); | |
const isHexString = /^[\da-f]+$/i; | |
if (target.length > 0 && !isHexString.test(target)) { | |
throw new Error('expected hex string'); | |
} |
export const typedHex = <T,>(value: string, length?: number): T => { | ||
assertIsHexString(value, length); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return (value as any) as T; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to use unknown for this case imo, also complies with eslint requirements
export const typedHex = <T,>(value: string, length?: number): T => { | |
assertIsHexString(value, length); | |
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |
return (value as any) as T; | |
}; | |
export const typedHex = <T>(value: string, length?: number): T => { | |
assertIsHexString(value, length); | |
return value as unknown as T; | |
}; |
Most probably, we are not going to include these changes. |
LW-11966
Move sdk code to limit number of new deps