const addressKeys = ['province', 'city', 'area', 'street', 'committee']

export function toAddressArr(obj = {}, prefix = '', suffix = '') {
  return addressKeys.reduce((prev, curr, index) => {
    const key = `${prefix}${addressKeys[index]}${suffix}`
    if (obj[key]) {
      prev.push(obj[key])
    }
    return prev
  }, [])
}

export function toAddressObj(arr = [], prefix = '') {
  return arr.reduce((prev, curr, index) => {
    prev[`${prefix}${addressKeys[index]}`] = curr
    return prev
  }, {})
}
