UNPKG

local-storage

Version:

A simplified localStorage API that just works

22 lines (16 loc) 299 B
'use strict'; function parse (rawValue) { const parsed = parseValue(rawValue); if (parsed === undefined) { return null; } return parsed; } function parseValue (rawValue) { try { return JSON.parse(rawValue); } catch (err) { return rawValue; } } module.exports = parse;