Skip to content
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 IDBKeyVal get returning undefined instead of null #408

Merged
merged 4 commits into from
Oct 31, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/storage/providers/IDBKeyVal.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const provider = {
* @param {String} key
* @return {Promise<*>}
*/
getItem: key => get(key, getCustomStore()),
getItem: key => get(key, getCustomStore()).then(val => (val != null ? val : null)),
Copy link
Collaborator

@tgolen tgolen Oct 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to your explanation, shouldn't this check if the value is undefined, and if so, return null? This change looks like the ternary isn't doing anything and is the same thing as returning the value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will check for null / undefined double = and return null in both cases, I could change the check to === undefined if you think it is clearer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good shout, I think given the explanation and RCA, checking for === undefined would be cleaner

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please. Our styles prefer strict comparison. Could you also please add a comment to the code that the purpose for this logic is to make the storage APIs consistent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated


/**
* Remove given key and it's value from storage
Expand Down
Loading