@koine/browser 1.0.98 → 1.0.101
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.
- package/createStorage.d.ts +2 -2
- package/createStorage.js +3 -3
- package/navigateToHash.js +1 -1
- package/node/createStorage.js +3 -3
- package/node/navigateToHash.js +1 -1
- package/node/storageClient.js +5 -3
- package/package.json +3 -3
- package/storageClient.js +5 -3
package/createStorage.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare const createStorage: <T extends CreateStorageConfig>(config: Part
|
|
|
11
11
|
* On ssr or if the given `key` argument is not found `defaultValue` is
|
|
12
12
|
* returned, otherwise `null`.
|
|
13
13
|
*/
|
|
14
|
-
get<TKey extends keyof T
|
|
14
|
+
get<TKey extends Extract<keyof T, string>>(key: TKey, defaultValue?: T[TKey] | null | undefined): T[TKey] | null;
|
|
15
15
|
/**
|
|
16
16
|
* Get all storage values (it uses `localStorage.get()`).
|
|
17
17
|
*
|
|
@@ -23,7 +23,7 @@ export declare const createStorage: <T extends CreateStorageConfig>(config: Part
|
|
|
23
23
|
*
|
|
24
24
|
* Non-string values are stringified with `JSON.stringify()`
|
|
25
25
|
*/
|
|
26
|
-
set<TKey_1 extends Extract<keyof T, string>>(key: TKey_1, value
|
|
26
|
+
set<TKey_1 extends Extract<keyof T, string>>(key: TKey_1, value?: T[TKey_1] | undefined): void;
|
|
27
27
|
/**
|
|
28
28
|
* Set all given storage values (it uses `localStorage.set()`).
|
|
29
29
|
*
|
package/createStorage.js
CHANGED
|
@@ -37,7 +37,7 @@ export var createStorage = function (config, useSessionStorage) {
|
|
|
37
37
|
}
|
|
38
38
|
var all = {};
|
|
39
39
|
for (var key in keys) {
|
|
40
|
-
var value =
|
|
40
|
+
var value = this.get(key);
|
|
41
41
|
var defaultValue = defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues[key];
|
|
42
42
|
if (!isNullOrUndefined(value)) {
|
|
43
43
|
all[key] = value;
|
|
@@ -72,10 +72,10 @@ export var createStorage = function (config, useSessionStorage) {
|
|
|
72
72
|
for (var key in newValues) {
|
|
73
73
|
var value = newValues[key];
|
|
74
74
|
if (!isNullOrUndefined(value)) {
|
|
75
|
-
|
|
75
|
+
this.set(key, value);
|
|
76
76
|
}
|
|
77
77
|
else {
|
|
78
|
-
|
|
78
|
+
this.remove(key);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
}
|
package/navigateToHash.js
CHANGED
|
@@ -8,6 +8,6 @@ import navigateToUrl from "./navigateToUrl";
|
|
|
8
8
|
export function navigateToHash(hash) {
|
|
9
9
|
if (hash === void 0) { hash = ""; }
|
|
10
10
|
var pathname = location.pathname, search = location.search;
|
|
11
|
-
navigateToUrl(pathname + (search ? "?" + search : "") + "#" + hash, true);
|
|
11
|
+
navigateToUrl(pathname + (search ? "?" + search : "") + (hash ? "#" + hash : ""), true);
|
|
12
12
|
}
|
|
13
13
|
export default navigateToHash;
|
package/node/createStorage.js
CHANGED
|
@@ -40,7 +40,7 @@ var createStorage = function (config, useSessionStorage) {
|
|
|
40
40
|
}
|
|
41
41
|
var all = {};
|
|
42
42
|
for (var key in keys) {
|
|
43
|
-
var value =
|
|
43
|
+
var value = this.get(key);
|
|
44
44
|
var defaultValue = defaultValues === null || defaultValues === void 0 ? void 0 : defaultValues[key];
|
|
45
45
|
if (!(0, utils_1.isNullOrUndefined)(value)) {
|
|
46
46
|
all[key] = value;
|
|
@@ -75,10 +75,10 @@ var createStorage = function (config, useSessionStorage) {
|
|
|
75
75
|
for (var key in newValues) {
|
|
76
76
|
var value = newValues[key];
|
|
77
77
|
if (!(0, utils_1.isNullOrUndefined)(value)) {
|
|
78
|
-
|
|
78
|
+
this.set(key, value);
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
81
|
-
|
|
81
|
+
this.remove(key);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
}
|
package/node/navigateToHash.js
CHANGED
|
@@ -12,7 +12,7 @@ var navigateToUrl_1 = tslib_1.__importDefault(require("./navigateToUrl"));
|
|
|
12
12
|
function navigateToHash(hash) {
|
|
13
13
|
if (hash === void 0) { hash = ""; }
|
|
14
14
|
var pathname = location.pathname, search = location.search;
|
|
15
|
-
(0, navigateToUrl_1.default)(pathname + (search ? "?" + search : "") + "#" + hash, true);
|
|
15
|
+
(0, navigateToUrl_1.default)(pathname + (search ? "?" + search : "") + (hash ? "#" + hash : ""), true);
|
|
16
16
|
}
|
|
17
17
|
exports.navigateToHash = navigateToHash;
|
|
18
18
|
exports.default = navigateToHash;
|
package/node/storageClient.js
CHANGED
|
@@ -34,9 +34,11 @@ var storageClient = function (useSessionStorage) {
|
|
|
34
34
|
}
|
|
35
35
|
catch (_e) {
|
|
36
36
|
value = stored;
|
|
37
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
38
|
-
|
|
39
|
-
}
|
|
37
|
+
// if (process.env["NODE_ENV"] !== "production") {
|
|
38
|
+
// console.warn(
|
|
39
|
+
// `[@koine/utils:storage]: 'get' failed to parse stored value as JSON. Plain '${stored}' value is returned.`
|
|
40
|
+
// );
|
|
41
|
+
// }
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
}
|
package/package.json
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
"main": "./node/index.js",
|
|
5
5
|
"typings": "./index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@koine/utils": "1.0.
|
|
7
|
+
"@koine/utils": "1.0.101",
|
|
8
8
|
"ts-debounce": "^4.0.0",
|
|
9
|
-
"@koine/dom": "1.0.
|
|
9
|
+
"@koine/dom": "1.0.101",
|
|
10
10
|
"date-fns-tz": "^1.3.7",
|
|
11
11
|
"tslib": "^2.4.0"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {},
|
|
14
|
-
"version": "1.0.
|
|
14
|
+
"version": "1.0.101",
|
|
15
15
|
"module": "./index.js",
|
|
16
16
|
"types": "./index.d.ts"
|
|
17
17
|
}
|
package/storageClient.js
CHANGED
|
@@ -31,9 +31,11 @@ export var storageClient = function (useSessionStorage) {
|
|
|
31
31
|
}
|
|
32
32
|
catch (_e) {
|
|
33
33
|
value = stored;
|
|
34
|
-
if (process.env["NODE_ENV"] !== "production") {
|
|
35
|
-
|
|
36
|
-
}
|
|
34
|
+
// if (process.env["NODE_ENV"] !== "production") {
|
|
35
|
+
// console.warn(
|
|
36
|
+
// `[@koine/utils:storage]: 'get' failed to parse stored value as JSON. Plain '${stored}' value is returned.`
|
|
37
|
+
// );
|
|
38
|
+
// }
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
}
|