diff --git a/README.md b/README.md index 900300a..cbeaaf3 100644 --- a/README.md +++ b/README.md @@ -342,17 +342,7 @@ Note: This is same as `getId();` the difference being it only returns the first const requestIdentifier = store.getShortId(); ``` -### reset() -Reset the store or a specific key of the global store. - -- `@returns {void}` - -```js -store.reset(); // Reset the whole store - -store.reset('foo') // It will delete the key foo from store and get will result undefined -``` ## Example Projects diff --git a/src/AsyncStore.ts b/src/AsyncStore.ts index 7e2c9d9..fb5bd44 100644 --- a/src/AsyncStore.ts +++ b/src/AsyncStore.ts @@ -13,7 +13,7 @@ interface AsyncStore { isInitialized: () => boolean; getId: () => string | undefined; getShortId: () => string | undefined; - reset: (key?: string) => void; + reset: () => void; } export default AsyncStore; diff --git a/src/impl/domain.ts b/src/impl/domain.ts index 878d7c3..afdca7c 100644 --- a/src/impl/domain.ts +++ b/src/impl/domain.ts @@ -101,20 +101,8 @@ export function set(properties: any) { /** * Reset the store by removing all values or a specific value by key. - * - * @param {string} key */ -export function reset(key?: string) { - const store = getStore(); - - if (key) { - logDomain(`Resetting ${key} in the domain store.`); - - delete store[key]; - - return; - } - +export function reset() { logDomain('Resetting the domain store.'); const activeDomain = getActiveDomain(); diff --git a/src/index.ts b/src/index.ts index c24bc47..1a9cb47 100644 --- a/src/index.ts +++ b/src/index.ts @@ -116,18 +116,17 @@ export function initialize(adapter: AsyncStoreAdapter = AsyncStoreAdapter.DOMAIN } /** - * Reset the store or a specific key. - * - * @param {string} [key] - */ -export function reset(key?: string) { + * Reset the store. + * + * */ +export function reset() { if (!isInitialized()) { throw new Error('Async store not initialized.'); } - coreLog(`Resetting store or key = ${key}`); + coreLog(`Resetting the store`); - getInstance(initializedAdapter).reset(key); + getInstance(initializedAdapter).reset(); } /** diff --git a/test/domain.test.ts b/test/domain.test.ts index e9b2227..08c1913 100644 --- a/test/domain.test.ts +++ b/test/domain.test.ts @@ -504,21 +504,6 @@ describe('store: [adapter=DOMAIN]', () => { expect(globalStore.isInitialized()).to.equal(false); }); - - it('should reset the store by removing a specific value by key', (done) => { - const callback = () => { - globalStore.set({ foo: 'foo', bar: 'bar' }); - - globalStore.reset('foo'); - - expect(globalStore.get('foo')).to.equal(undefined); - expect(globalStore.get('bar')).to.equal('bar'); - - done(); - }; - - globalStore.initialize(adapter)(callback); - }); }); describe('Test Cases:', () => {