-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
refactor: hashObjectNullableWithPrefix #8601
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
Conversation
crypto/object-hasher/src/index.ts
Outdated
export function createPackageExtensionsChecksum (packageExtensions: Record<string, PackageExtension> | undefined): PackageExtensionsChecksum { | ||
if (!packageExtensions || isEmpty(packageExtensions)) return undefined | ||
const packageExtensionsChecksum = hash(packageExtensions, withSortingOptions) | ||
return `sha256-${packageExtensionsChecksum}` | ||
} |
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.
This function could be more generic, but the name hashObject
is already taken. Maybe we should change hashObject
to return undefined
for empty objects?
Why is this change needed now? The function is used in a single place. |
The function will be reused. You told me to base |
ok, but in the original PR it was a generic function while here it is specific to package extensions. Which is OK but in this case I don't think it should be part of a generic hashing package. Maybe just keep it in that package that you want to create for checking lockfile settings. |
I wonder how many places would |
no, it is used in multiple places. you could add a new function like |
done. |
crypto/object-hasher/src/index.ts
Outdated
export const hashObject = (object: unknown): string => hashUnknown(object, withSortingOptions) | ||
|
||
export type PrefixedHash = `sha256-${string}` | ||
export function hashObjectNullablePrefix (object: Record<string, unknown> | undefined): PrefixedHash | undefined { |
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.
export function hashObjectNullablePrefix (object: Record<string, unknown> | undefined): PrefixedHash | undefined { | |
export function hashObjectNullableWithPrefix (object: Record<string, unknown> | undefined): PrefixedHash | undefined { |
otherwise it sounds like the prefix is nullable
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.
No description provided.