UNPKG

@newrelic/gatsby-theme-newrelic

Version:

[![Community Project header](https://github.com/newrelic/opensource-website/raw/master/src/images/categories/Community_Project.png)](https://opensource.newrelic.com/oss-category/#community-project)

17 lines (15 loc) 444 B
const createStorage = (provider) => ({ get(key, defaultValue) { const json = provider.getItem(key); // eslint-disable-next-line no-nested-ternary return json === null || typeof json === 'undefined' ? typeof defaultValue === 'function' ? defaultValue() : defaultValue : JSON.parse(json); }, set(key, value) { provider.setItem(key, JSON.stringify(value)); }, }); export default createStorage;