Skip to content

Make storage methods destructurable and scope clear to the prefix - #17

Merged
arnelirobles merged 1 commit into
mainfrom
fix/nano-safe-storage-closures-clear
Nov 12, 2026
Merged

arnelirobles merged 1 commit into
mainfrom
fix/nano-safe-storage-closures-clear

Conversation

@arnelirobles

Copy link
Copy Markdown
Contributor

Fixes the plain parts of F7. createStorage() methods are closures, so const { get, has } = createStorage() works. clear() with a prefix now removes only keys with that prefix, in localStorage and in the memory fallback (before, memory mode wiped every namespace). Without a prefix the library cannot tell its keys from others, so clear() still clears the whole store and the README now says so. No ttl check bug found that is not the ttl 0 decision, so none changed.

Not changed, design decisions: no key separator between prefix and key, set returning void, ttl: 0 meaning no expiry, and the "quota management" claim in the README.

Tests: packages/nano-safe-storage/src/index.test.ts, new destructuring and clear block. 3 fail on main, all 14 pass here, tsc clean.

- test: packages/nano-safe-storage/src/index.test.ts
  breaks: packages/nano-safe-storage/src/index.ts "return { set, get, remove, has, clear, isAvailable };"
- test: packages/nano-safe-storage/src/index.test.ts
  breaks: packages/nano-safe-storage/src/index.ts ".filter(k => k.startsWith(prefix))"

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f3e9a569-113f-4364-a242-e06a09745d90
Commits

Reviewing files that changed from the base of the PR and between 0f20b1a and 30da066.

Files selected for processing: 4

  • .changeset/nano-safe-storage-clear.md
  • packages/nano-safe-storage/README.md
  • packages/nano-safe-storage/src/index.test.ts
  • packages/nano-safe-storage/src/index.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@arnelirobles
arnelirobles marked this pull request as ready for review November 12, 2026 15:33
@arnelirobles
arnelirobles merged commit 9c18db2 into main Nov 12, 2026
2 checks passed
@arnelirobles
arnelirobles deleted the fix/nano-safe-storage-closures-clear branch November 12, 2026 15:33
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.

1 participant