string/unescapeHtml.jsjavascript
const entities = { '&amp;': '&', '&lt;': '<', '&gt;': '>', '&quot;': String.fromCharCode(34), '&#39;': String.fromCharCode(39) }

/**
 * 解码 escapeHtml 生成的 HTML 实体,不依赖 DOM。
 * @function unescapeHtml
 * @memberof module:string
 * @param {string} value 已转义字符串
 * @returns {string} 解码后的字符串
 * @throws {TypeError} 参数不是字符串时抛出
 */
function unescapeHtml(value) {
  if (typeof value !== 'string') throw new TypeError('value must be a string')
  return value.replace(/&(amp|lt|gt|quot|#39);/g, entity => entities[entity])
}

export default unescapeHtml