ag-common 0.0.98 → 0.0.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,10 +6,15 @@ const log_1 = require("../../common/helpers/log");
6
6
  const object_1 = require("../../common/helpers/object");
7
7
  const getTimeSeconds = () => Math.ceil(new Date().getTime() / 1000);
8
8
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- let nodeLocalStorage = {};
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ if (!process.nodeLocalStorage) {
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ process.nodeLocalStorage = {};
13
+ }
10
14
  const clearLocalStorageItem = (key) => {
11
15
  if (typeof window === 'undefined') {
12
- delete nodeLocalStorage[key];
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ delete process.nodeLocalStorage[key];
13
18
  return;
14
19
  }
15
20
  try {
@@ -23,7 +28,8 @@ exports.clearLocalStorageItem = clearLocalStorageItem;
23
28
  const clearAllLocalStorage = (except) => {
24
29
  try {
25
30
  if (typeof window === 'undefined') {
26
- nodeLocalStorage = {};
31
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
+ process.nodeLocalStorage = {};
27
33
  return;
28
34
  }
29
35
  for (let i = 0; i < localStorage.length; i += 1) {
@@ -42,7 +48,8 @@ exports.clearAllLocalStorage = clearAllLocalStorage;
42
48
  const setLocalStorageItem = (key, value, ttl) => {
43
49
  try {
44
50
  if (typeof window === 'undefined') {
45
- nodeLocalStorage[key] = value;
51
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
+ process.nodeLocalStorage[key] = value;
46
53
  return;
47
54
  }
48
55
  const set = {
@@ -59,7 +66,9 @@ const setLocalStorageItem = (key, value, ttl) => {
59
66
  exports.setLocalStorageItem = setLocalStorageItem;
60
67
  const getLocalStorageItem = (key, initialValue, ttl) => {
61
68
  if (typeof window === 'undefined') {
62
- return nodeLocalStorage[key] || initialValue;
69
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
+ const value = process.nodeLocalStorage[key] || initialValue;
71
+ return value;
63
72
  }
64
73
  const itemraw = window.localStorage.getItem(key);
65
74
  const item = (0, object_1.tryJsonParse)(itemraw, undefined);
@@ -75,7 +84,6 @@ const getLocalStorageItem = (key, initialValue, ttl) => {
75
84
  return itemv;
76
85
  };
77
86
  exports.getLocalStorageItem = getLocalStorageItem;
78
- // Hook
79
87
  function UseLocalStorage(key, initialValue, ttl) {
80
88
  const storedValue = (0, exports.getLocalStorageItem)(key, initialValue, ttl);
81
89
  //bump use of stored value
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ag-common",
3
- "version": "0.0.98",
3
+ "version": "0.0.100",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Andrei Gec <@andreigec> (https://gec.dev/)",