UNPKG

978 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var getWindow_1 = require("./dom/getWindow");
4/**
5 * Fetches an item from local storage without throwing an exception
6 * @param key The key of the item to fetch from local storage
7 */
8function getItem(key) {
9 var result = null;
10 try {
11 var win = getWindow_1.getWindow();
12 result = win ? win.localStorage.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 local storage without throwing an exception
22 * @param key The key of the item to add to local storage
23 * @param data The data to put into local storage
24 */
25function setItem(key, data) {
26 try {
27 var win = getWindow_1.getWindow();
28 win && win.localStorage.setItem(key, data);
29 }
30 catch (e) {
31 /* Eat the exception */
32 }
33}
34exports.setItem = setItem;
35//# sourceMappingURL=localStorage.js.map
\No newline at end of file