@koine/browser 1.0.96 → 1.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.
package/createStorage.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { __assign } from "tslib";
2
2
  import { decode, encode, isBrowser, isNullOrUndefined } from "@koine/utils";
3
3
  import { on } from "@koine/dom";
4
- import { storage } from "./storage";
4
+ import storage from "./storage";
5
5
  /**
6
6
  * Utility to create a storage instance to interact with `localStorage` using
7
7
  * encrypted (encoded) key/values.
@@ -54,7 +54,7 @@ export var createStorage = function (config, useSessionStorage) {
54
54
  * Non-string values are stringified with `JSON.stringify()`
55
55
  */
56
56
  set: function (key, value) {
57
- client.set(key, value, encode);
57
+ client.set(keys[key], value, encode);
58
58
  },
59
59
  /**
60
60
  * Set all given storage values (it uses `localStorage.set()`).
@@ -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
- client.set(key, value);
75
+ client.set(keys[key], value);
76
76
  }
77
77
  else {
78
- client.remove(key);
78
+ client.remove(keys[key]);
79
79
  }
80
80
  }
81
81
  }
@@ -4,13 +4,13 @@ exports.createStorage = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var utils_1 = require("@koine/utils");
6
6
  var dom_1 = require("@koine/dom");
7
- var storage_1 = require("./storage");
7
+ var storage_1 = tslib_1.__importDefault(require("./storage"));
8
8
  /**
9
9
  * Utility to create a storage instance to interact with `localStorage` using
10
10
  * encrypted (encoded) key/values.
11
11
  */
12
12
  var createStorage = function (config, useSessionStorage) {
13
- var client = useSessionStorage ? storage_1.storage.s : storage_1.storage.l;
13
+ var client = useSessionStorage ? storage_1.default.s : storage_1.default.l;
14
14
  var keys = Object.keys(config).reduce(function (map, key) {
15
15
  var _a;
16
16
  return (tslib_1.__assign(tslib_1.__assign({}, map), (_a = {}, _a[key] = (0, utils_1.encode)(key), _a)));
@@ -57,7 +57,7 @@ var createStorage = function (config, useSessionStorage) {
57
57
  * Non-string values are stringified with `JSON.stringify()`
58
58
  */
59
59
  set: function (key, value) {
60
- client.set(key, value, utils_1.encode);
60
+ client.set(keys[key], value, utils_1.encode);
61
61
  },
62
62
  /**
63
63
  * Set all given storage values (it uses `localStorage.set()`).
@@ -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
- client.set(key, value);
78
+ client.set(keys[key], value);
79
79
  }
80
80
  else {
81
- client.remove(key);
81
+ client.remove(keys[key]);
82
82
  }
83
83
  }
84
84
  }
package/node/storage.js CHANGED
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.storage = void 0;
4
- var storageClient_1 = require("./storageClient");
4
+ var tslib_1 = require("tslib");
5
+ var storageClient_1 = tslib_1.__importDefault(require("./storageClient"));
5
6
  /**
6
7
  * Storage, for `localStorage` and `sessionStorage`
7
8
  */
8
9
  exports.storage = {
9
- l: (0, storageClient_1.storageClient)(),
10
- s: (0, storageClient_1.storageClient)(true),
10
+ l: (0, storageClient_1.default)(),
11
+ s: (0, storageClient_1.default)(true),
11
12
  };
12
13
  exports.default = exports.storage;
@@ -12,7 +12,7 @@ var storageClient = function (useSessionStorage) {
12
12
  ? window[useSessionStorage ? "sessionStorage" : "localStorage"][methodsMap[method]](key, value)
13
13
  : function () {
14
14
  if (process.env["NODE_ENV"] !== "production") {
15
- console.warn("[@koine/utils:storage]:ls localStorage does not exists outside of browser.");
15
+ console.warn("[@koine/utils:storageClient]: ".concat(useSessionStorage ? "sessionStorage" : "localStorage", " does not exists outside of browser."));
16
16
  }
17
17
  };
18
18
  };
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.96",
7
+ "@koine/utils": "1.0.98",
8
8
  "ts-debounce": "^4.0.0",
9
- "@koine/dom": "1.0.96",
9
+ "@koine/dom": "1.0.98",
10
10
  "date-fns-tz": "^1.3.7",
11
11
  "tslib": "^2.4.0"
12
12
  },
13
13
  "peerDependencies": {},
14
- "version": "1.0.96",
14
+ "version": "1.0.98",
15
15
  "module": "./index.js",
16
16
  "types": "./index.d.ts"
17
17
  }
package/storage.js CHANGED
@@ -1,4 +1,4 @@
1
- import { storageClient } from "./storageClient";
1
+ import storageClient from "./storageClient";
2
2
  /**
3
3
  * Storage, for `localStorage` and `sessionStorage`
4
4
  */
package/storageClient.js CHANGED
@@ -9,7 +9,7 @@ export var storageClient = function (useSessionStorage) {
9
9
  ? window[useSessionStorage ? "sessionStorage" : "localStorage"][methodsMap[method]](key, value)
10
10
  : function () {
11
11
  if (process.env["NODE_ENV"] !== "production") {
12
- console.warn("[@koine/utils:storage]:ls localStorage does not exists outside of browser.");
12
+ console.warn("[@koine/utils:storageClient]: ".concat(useSessionStorage ? "sessionStorage" : "localStorage", " does not exists outside of browser."));
13
13
  }
14
14
  };
15
15
  };