import { encodeURI, decode } from 'js-base64'

export function encode(data) {
  return encodeURI(JSON.stringify(data))
}

export function parse(str) {
  try {
    return JSON.parse(decode(str))
  } catch {
    return null
  }
}
