Skip to content

Commit 8daa59d

Browse files
committed
feat: added hasActiveStorage and JSDocs
1 parent 19ccb41 commit 8daa59d

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/main.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ describe("index exports", () => {
4949

5050
// token utils
5151
"getActiveStorage",
52+
"hasActiveStorage",
5253
"getClaim",
5354
"getClaims",
5455
"getCurrentOrganization",

lib/utils/token/index.ts

+17
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,34 @@ const storage = {
1515
value: null as SessionManager | null,
1616
};
1717

18+
/**
19+
* Sets the active storage
20+
* @param store Session manager instance
21+
*/
1822
const setActiveStorage = (store: SessionManager) => {
1923
storage.value = store;
2024
};
2125

26+
/**
27+
* Gets the current active storage
28+
* @returns Session manager instance or null
29+
*/
2230
const getActiveStorage = (): SessionManager | null => {
2331
return storage.value || null;
2432
};
2533

34+
/**
35+
* Checks if there is an active storage
36+
* @returns boolean
37+
*/
38+
const hasActiveStorage = (): boolean => {
39+
return storage.value !== null;
40+
};
41+
2642
export {
2743
setActiveStorage,
2844
getActiveStorage,
45+
hasActiveStorage,
2946
getClaim,
3047
getClaims,
3148
getCurrentOrganization,

0 commit comments

Comments
 (0)