[Feature Request] Add GetKeys()/RemoveKeys methods
Is your feature request related to a problem? Please describe. I am porting a ReactJS website to Blazor and due to 'reasons' I store data with 'random' keys which I want to delete every x days. (this is vague I know). The easiest way is to compare all the keys in store with keys I 'allow' and then remove unwanted data by key.
Describe alternatives you've considered
I can fix this now by:
int Length(); -> foreach index -> string Key(int index); -> and depending on an if call: void RemoveItem(string key);
So when I have 100 keys in store and I have to remove 50. I will have to make 1 + 100 + 50 = 151 calls to JS interop.
Describe the solution you'd like
If there were also IEnumerable<string> GetKeys() + void RemoveKeys(IEnumerable<string> keys)
Then I could achieve the same with just 2 calls. Which is nicer, more readable and faster.
var toRemoveKeys = localStorage.GetKeys().Except(allowedKeys);
localStorage.RemoveKeys(toRemoveKeys);
Additional context I describe it here as sync buth it would of cource also be nice in async.
FYI, code in my ReacttJS (TypeScript) app:
Object
.keys(localStorage)
.filter(k => !allowedKeys.includes(k))
.forEach(r => localStorage.removeItem(r));
Yes I need too
I need the enumeration via GetKeys as well
Fixed in #162