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: return undefined instead of null for non existing keys #260

Closed
wants to merge 4 commits into from

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Jul 4, 2023

πŸ”— Linked issue

Resolves #205

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This is a rework of #206

By changes to this PR, storage returns undefined instead of null when a key does not exist.

On the downside, this change makes unstorage less consistent with local storage and Cloudflare KV when getItem returns null when the key does not exist.

On the benefits, more thinking this is less a breaking change for users but actually a fix since we were already listing null as a valid Storage value (which does exist!). And we reduce use of evil null. (sindresorhus/meta#7)

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@nuxt-studio
Copy link

nuxt-studio bot commented Jul 4, 2023

βœ… Live Preview ready!

Name Edit Preview Latest Commit
unstorage Edit on Studio β†—οΈŽ View Live Preview c9ca0ba

@pi0 pi0 force-pushed the fix/undefined-non-existing branch from 4a23ea9 to c9ca0ba Compare July 4, 2023 15:05
@codecov
Copy link

codecov bot commented Jul 4, 2023

Codecov Report

Merging #260 (c9ca0ba) into main (cb8577b) will increase coverage by 0.06%.
The diff coverage is 65.00%.

@@            Coverage Diff             @@
##             main     #260      +/-   ##
==========================================
+ Coverage   76.27%   76.33%   +0.06%     
==========================================
  Files          25       25              
  Lines        3030     3064      +34     
  Branches      441      451      +10     
==========================================
+ Hits         2311     2339      +28     
- Misses        718      724       +6     
  Partials        1        1              
Impacted Files Coverage Ξ”
src/drivers/azure-app-configuration.ts 40.68% <0.00%> (ΓΈ)
src/drivers/azure-cosmos.ts 44.05% <0.00%> (ΓΈ)
src/drivers/azure-key-vault.ts 35.76% <0.00%> (-1.08%) ⬇️
src/drivers/azure-storage-blob.ts 33.33% <0.00%> (-0.38%) ⬇️
src/drivers/azure-storage-table.ts 43.93% <80.00%> (ΓΈ)
src/drivers/cloudflare-kv-binding.ts 83.90% <100.00%> (+3.08%) ⬆️
src/drivers/cloudflare-kv-http.ts 84.47% <100.00%> (+1.06%) ⬆️
src/drivers/github.ts 89.41% <100.00%> (ΓΈ)
src/drivers/localstorage.ts 80.00% <100.00%> (ΓΈ)
src/drivers/lru-cache.ts 91.42% <100.00%> (ΓΈ)
... and 7 more

@danielroe danielroe changed the title fix: return undefined instead of null for non exisiting keys fix: return undefined instead of null for non existing keys Jul 5, 2023
@pi0
Copy link
Member Author

pi0 commented May 1, 2024

PR stalled. Let's track via #205

@pi0 pi0 closed this May 1, 2024
@pi0 pi0 deleted the fix/undefined-non-existing branch May 1, 2024 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

getItem will return null for unexisting keys, instead of undefined
1 participant