ag-common 0.0.97 → 0.0.98
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.
|
@@ -25,7 +25,7 @@ const enforceDynamoProvisionCap = ({ tables, readsMax = 25, writesMax = 25, must
|
|
|
25
25
|
throw new Error('exceeded dynamo provision cap');
|
|
26
26
|
}
|
|
27
27
|
if (mustEqual && (reads !== readsMax || writes !== writesMax)) {
|
|
28
|
-
throw new Error(`dynamo provision cap not met
|
|
28
|
+
throw new Error(`dynamo provision cap not met`);
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
exports.enforceDynamoProvisionCap = enforceDynamoProvisionCap;
|
|
@@ -5,8 +5,11 @@ const react_1 = require("react");
|
|
|
5
5
|
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
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
let nodeLocalStorage = {};
|
|
8
10
|
const clearLocalStorageItem = (key) => {
|
|
9
11
|
if (typeof window === 'undefined') {
|
|
12
|
+
delete nodeLocalStorage[key];
|
|
10
13
|
return;
|
|
11
14
|
}
|
|
12
15
|
try {
|
|
@@ -20,6 +23,7 @@ exports.clearLocalStorageItem = clearLocalStorageItem;
|
|
|
20
23
|
const clearAllLocalStorage = (except) => {
|
|
21
24
|
try {
|
|
22
25
|
if (typeof window === 'undefined') {
|
|
26
|
+
nodeLocalStorage = {};
|
|
23
27
|
return;
|
|
24
28
|
}
|
|
25
29
|
for (let i = 0; i < localStorage.length; i += 1) {
|
|
@@ -38,6 +42,7 @@ exports.clearAllLocalStorage = clearAllLocalStorage;
|
|
|
38
42
|
const setLocalStorageItem = (key, value, ttl) => {
|
|
39
43
|
try {
|
|
40
44
|
if (typeof window === 'undefined') {
|
|
45
|
+
nodeLocalStorage[key] = value;
|
|
41
46
|
return;
|
|
42
47
|
}
|
|
43
48
|
const set = {
|
|
@@ -54,7 +59,7 @@ const setLocalStorageItem = (key, value, ttl) => {
|
|
|
54
59
|
exports.setLocalStorageItem = setLocalStorageItem;
|
|
55
60
|
const getLocalStorageItem = (key, initialValue, ttl) => {
|
|
56
61
|
if (typeof window === 'undefined') {
|
|
57
|
-
return initialValue;
|
|
62
|
+
return nodeLocalStorage[key] || initialValue;
|
|
58
63
|
}
|
|
59
64
|
const itemraw = window.localStorage.getItem(key);
|
|
60
65
|
const item = (0, object_1.tryJsonParse)(itemraw, undefined);
|
|
@@ -78,9 +83,6 @@ function UseLocalStorage(key, initialValue, ttl) {
|
|
|
78
83
|
// Return a wrapped version of useState's setter function that ...
|
|
79
84
|
// ... persists the new value to localStorage.
|
|
80
85
|
const setValue = (value) => {
|
|
81
|
-
if (typeof window === 'undefined') {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
86
|
const valueToStore = (value instanceof Function ? value(storedValue) : value);
|
|
85
87
|
(0, exports.setLocalStorageItem)(key, valueToStore, ttl);
|
|
86
88
|
setT(new Date().getTime());
|