(jsonEncodedValue: string)
| 10 | // As an improvement, we should maybe allow users to intercept here or possibly use |
| 11 | // a different parsing function from JSON.parse |
| 12 | function tryParseStorage(jsonEncodedValue: string): unknown { |
| 13 | try { |
| 14 | return JSON.parse(jsonEncodedValue); |
| 15 | } catch (e) { |
| 16 | return null; |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | function makeTypeExceptionString(instance: string) { |
| 21 | return `useLocalStorage: Native serialization of ${instance} is not supported. You are attempting to serialize a ${instance} instance, this data will be lost. For more info, see how ${instance.toLowerCase()}s are serialized https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#examples`; |
no test coverage detected