function getHash () {
  let url = window.location.href
  let index = url ? url.indexOf("#") : -1
  return 0 <= index ? url.substring(index + 1) : ""
}

export default function getHashParameters (hash, value) {
  let type = typeof value
  let hashParameters = getHash().split("&").reduce(function(hashObject, hash) {
    hash = hash.split("=")
    hashObject[decodeURIComponent(hash[0])] = decodeURIComponent(hash[1])
    return hashObject
  }, {})
  if ("boolean" === type && "undefined" !== typeof hashParameters[hash]) {
    type = hashParameters[hash]
    if ("true" === type || "1" === type)
        return !0
    if ("false" === type || "0" === type)
        return !1
  }
  return hashParameters[hash] || value
}
