Skip to content

Commit 5201173

Browse files
committed
Remove reseting specific keys
1 parent 8269d55 commit 5201173

File tree

5 files changed

+8
-46
lines changed

5 files changed

+8
-46
lines changed

README.md

-10
Original file line numberDiff line numberDiff line change
@@ -342,17 +342,7 @@ Note: This is same as `getId();` the difference being it only returns the first
342342
const requestIdentifier = store.getShortId();
343343
```
344344

345-
### reset()
346345

347-
Reset the store or a specific key of the global store.
348-
349-
- `@returns {void}`
350-
351-
```js
352-
store.reset(); // Reset the whole store
353-
354-
store.reset('foo') // It will delete the key foo from store and get will result undefined
355-
```
356346

357347
## Example Projects
358348

src/AsyncStore.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface AsyncStore {
1313
isInitialized: () => boolean;
1414
getId: () => string | undefined;
1515
getShortId: () => string | undefined;
16-
reset: (key?: string) => void;
16+
reset: () => void;
1717
}
1818

1919
export default AsyncStore;

src/impl/domain.ts

+1-13
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,8 @@ export function set(properties: any) {
101101

102102
/**
103103
* Reset the store by removing all values or a specific value by key.
104-
*
105-
* @param {string} key
106104
*/
107-
export function reset(key?: string) {
108-
const store = getStore();
109-
110-
if (key) {
111-
logDomain(`Resetting ${key} in the domain store.`);
112-
113-
delete store[key];
114-
115-
return;
116-
}
117-
105+
export function reset() {
118106
logDomain('Resetting the domain store.');
119107

120108
const activeDomain = getActiveDomain();

src/index.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,17 @@ export function initialize(adapter: AsyncStoreAdapter = AsyncStoreAdapter.DOMAIN
116116
}
117117

118118
/**
119-
* Reset the store or a specific key.
120-
*
121-
* @param {string} [key]
122-
*/
123-
export function reset(key?: string) {
119+
* Reset the store.
120+
*
121+
* */
122+
export function reset() {
124123
if (!isInitialized()) {
125124
throw new Error('Async store not initialized.');
126125
}
127126

128-
coreLog(`Resetting store or key = ${key}`);
127+
coreLog(`Resetting the store`);
129128

130-
getInstance(initializedAdapter).reset(key);
129+
getInstance(initializedAdapter).reset();
131130
}
132131

133132
/**

test/domain.test.ts

-15
Original file line numberDiff line numberDiff line change
@@ -504,21 +504,6 @@ describe('store: [adapter=DOMAIN]', () => {
504504

505505
expect(globalStore.isInitialized()).to.equal(false);
506506
});
507-
508-
it('should reset the store by removing a specific value by key', (done) => {
509-
const callback = () => {
510-
globalStore.set({ foo: 'foo', bar: 'bar' });
511-
512-
globalStore.reset('foo');
513-
514-
expect(globalStore.get('foo')).to.equal(undefined);
515-
expect(globalStore.get('bar')).to.equal('bar');
516-
517-
done();
518-
};
519-
520-
globalStore.initialize(adapter)(callback);
521-
});
522507
});
523508

524509
describe('Test Cases:', () => {

0 commit comments

Comments
 (0)