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

Add getAllKeys Method to SyncStorage #5

Merged
merged 11 commits into from
Oct 29, 2018
Prev Previous commit
Next Next commit
Add update method
  • Loading branch information
iamsoorena committed Sep 3, 2018
commit 652a6d79609c84830bd40aaf834a0f609d9a4bc9
11 changes: 11 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ class SyncStorage {
getAllKeys(): Array<*> {
return Array.from(this.data.keys());
}

update(key: KeyType, value: any): Promise<*> {
if (!key) return handleError('update', 'a key');
const item = this.get(key);
if (item !== undefined) {
return this.set(key, value);
}
const message = 'You can not update a key that has not been set yet.';
console.warn(message); // eslint-disable-line no-console
return Promise.reject(message);
}
}

const syncStorage = new SyncStorage();
Expand Down