iodide-project/iodide

validate _all_ API args, break out API arg validation in #1703 into a little library that we can use to

開放

#1,760 建立於 2019年4月22日

 (0 則留言) (0 個反應) (0 位負責人)JavaScript (147 個分叉)batch import
good first issue

倉庫指標

星標
 (1,483 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

following from @hamilton's nice file API argument validation in #1703, we should apply argument validation to all of the iodide API. in the process, we should break the argument validation into proptypes-style helper function

see: https://github.com/iodide-project/iodide/pull/1703#discussion_r274200088

export function loadFile(fileName, fetchType, variableName = undefined) {
  argType.validate({
    fileName: [fileName, argType.string],
    fetchType: [fetchType, argType.enum(FETCH_RETURN_TYPES)],
    variableName: [variableName, argType.string.optional]
  })
  return sendFileRequestToEditor(fileName, "LOAD_FILE", {
    fetchType
  }).request.then(handleResourceLoad(fetchType, variableName));
}

貢獻者指南