import previewDoc from './doc'

interface PreviewHandler {
  doc: () => void
}

async function preview(type: keyof PreviewHandler) {
  const previewHandler:PreviewHandler = {
    doc: previewDoc, // 处理文档生成
  }
  if (Object.prototype.hasOwnProperty.call(previewHandler, type)) {
    await previewHandler[type]()
  }
}

function execPreview(options: object) {
  Object.keys(options).forEach(async (type) => {
    await preview(type as keyof PreviewHandler)
  })
}

export default execPreview
