UNPKG

1.02 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var getWindow_1 = require("./dom/getWindow");
4/**
5 * Fetches an item from session storage without throwing an exception
6 * @param key The key of the item to fetch from session storage
7 */
8function getItem(key) {
9 var result = null;
10 try {
11 var win = getWindow_1.getWindow();
12 result = win ? win.sessionStorage.getItem(key) : null;
13 }
14 catch (e) {
15 /* Eat the exception */
16 }
17 return result;
18}
19exports.getItem = getItem;
20/**
21 * Inserts an item into session storage without throwing an exception
22 * @param key The key of the item to add to session storage
23 * @param data The data to put into session storage
24 */
25function setItem(key, data) {
26 var _a;
27 try {
28 (_a = getWindow_1.getWindow()) === null || _a === void 0 ? void 0 : _a.sessionStorage.setItem(key, data);
29 }
30 catch (e) {
31 /* Eat the exception */
32 }
33}
34exports.setItem = setItem;
35//# sourceMappingURL=sessionStorage.js.map
\No newline at end of file