(rawValue: SettingValue)
| 129 | const encoder = new TextEncoder() // always utf-8 |
| 130 | const decoder = new TextDecoder('utf-8') |
| 131 | export function encodeValue(rawValue: SettingValue) { |
| 132 | return Array.isArray(rawValue) || typeof rawValue === 'boolean' |
| 133 | ? encoder.encode(JSON.stringify(rawValue)) |
| 134 | : rawValue |
| 135 | } |
| 136 | function decodeValue(value: Uint8Array<ArrayBuffer>) { |
| 137 | return JSON.parse(decoder.decode(value)) as SettingValue |
| 138 | } |
no outgoing calls
no test coverage detected