1 | import { getWindow } from './dom/getWindow';
|
2 | /**
|
3 | * Fetches an item from local storage without throwing an exception
|
4 | * @param key The key of the item to fetch from local storage
|
5 | */
|
6 | export function getItem(key) {
|
7 | var result = null;
|
8 | try {
|
9 | var win = getWindow();
|
10 | result = win ? win.localStorage.getItem(key) : null;
|
11 | }
|
12 | catch (e) {
|
13 | /* Eat the exception */
|
14 | }
|
15 | return result;
|
16 | }
|
17 | /**
|
18 | * Inserts an item into local storage without throwing an exception
|
19 | * @param key The key of the item to add to local storage
|
20 | * @param data The data to put into local storage
|
21 | */
|
22 | export function setItem(key, data) {
|
23 | try {
|
24 | var win = getWindow();
|
25 | win && win.localStorage.setItem(key, data);
|
26 | }
|
27 | catch (e) {
|
28 | /* Eat the exception */
|
29 | }
|
30 | }
|
31 | //# sourceMappingURL=localStorage.js.map |
\ | No newline at end of file |