ag-common 0.0.33 → 0.0.34
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.
|
@@ -52,17 +52,19 @@ function objectToArray(obj) {
|
|
|
52
52
|
return ret;
|
|
53
53
|
}
|
|
54
54
|
exports.objectToArray = objectToArray;
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
56
|
const objectAlphaSort = (object, depthLeft = -1) => {
|
|
56
57
|
if (depthLeft === 0) {
|
|
57
58
|
return object;
|
|
58
59
|
}
|
|
59
60
|
if (object !== null && typeof object === 'object') {
|
|
60
|
-
return Object.keys(object)
|
|
61
|
+
return (Object.keys(object)
|
|
61
62
|
.sort((a, b) => (a.toLowerCase() < b.toLowerCase() ? -1 : 1))
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
64
|
.reduce((result, key) => {
|
|
63
65
|
result[key] = (0, exports.objectAlphaSort)(object[key], depthLeft - 1);
|
|
64
66
|
return result;
|
|
65
|
-
}, {});
|
|
67
|
+
}, {}));
|
|
66
68
|
}
|
|
67
69
|
else if (Array.isArray(object)) {
|
|
68
70
|
return object.map((obj) => (0, exports.objectAlphaSort)(obj, depthLeft - 1));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UseLocalStorage = exports.getLocalStorageItem = exports.setLocalStorageItem = exports.clearAllLocalStorage = exports.clearLocalStorageItem = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
4
5
|
const log_1 = require("../../common/helpers/log");
|
|
5
6
|
const object_1 = require("../../common/helpers/object");
|
|
6
7
|
const getTimeSeconds = () => Math.ceil(new Date().getTime() / 1000);
|
|
@@ -66,6 +67,8 @@ exports.getLocalStorageItem = getLocalStorageItem;
|
|
|
66
67
|
// Hook
|
|
67
68
|
function UseLocalStorage(key, initialValue, ttl) {
|
|
68
69
|
const storedValue = (0, exports.getLocalStorageItem)(key, initialValue, ttl);
|
|
70
|
+
//bump use of stored value
|
|
71
|
+
const [, setT] = (0, react_1.useState)(0);
|
|
69
72
|
// Return a wrapped version of useState's setter function that ...
|
|
70
73
|
// ... persists the new value to localStorage.
|
|
71
74
|
const setValue = (value) => {
|
|
@@ -74,6 +77,7 @@ function UseLocalStorage(key, initialValue, ttl) {
|
|
|
74
77
|
}
|
|
75
78
|
const valueToStore = (value instanceof Function ? value(storedValue) : value);
|
|
76
79
|
(0, exports.setLocalStorageItem)(key, valueToStore, ttl);
|
|
80
|
+
setT(new Date().getTime());
|
|
77
81
|
};
|
|
78
82
|
return [storedValue, setValue];
|
|
79
83
|
}
|