@uifabric/utilities
Version:
Fluent UI React utilities for building components.
1 lines • 1.48 kB
Source Map (JSON)
{"version":3,"file":"sessionStorage.js","sourceRoot":"../src/","sources":["sessionStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,GAAW;IACjC,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,IAAI;QACF,IAAM,GAAG,GAAG,SAAS,EAAE,CAAC;QACxB,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;KACvD;IAAC,OAAO,CAAC,EAAE;QACV,uBAAuB;KACxB;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,GAAW,EAAE,IAAY;;IAC/C,IAAI;QACF,MAAA,SAAS,EAAE,0CAAE,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE;KAChD;IAAC,OAAO,CAAC,EAAE;QACV,uBAAuB;KACxB;AACH,CAAC","sourcesContent":["import { getWindow } from './dom/getWindow';\n\n/**\n * Fetches an item from session storage without throwing an exception\n * @param key The key of the item to fetch from session storage\n */\nexport function getItem(key: string): string | null {\n let result = null;\n try {\n const win = getWindow();\n result = win ? win.sessionStorage.getItem(key) : null;\n } catch (e) {\n /* Eat the exception */\n }\n return result;\n}\n\n/**\n * Inserts an item into session storage without throwing an exception\n * @param key The key of the item to add to session storage\n * @param data The data to put into session storage\n */\nexport function setItem(key: string, data: string): void {\n try {\n getWindow()?.sessionStorage.setItem(key, data);\n } catch (e) {\n /* Eat the exception */\n }\n}\n"]}