UNPKG

all-node-versions

Version:
18 lines (14 loc) 430 B
import isPlainObj from"is-plain-obj"; export const getOpts=(opts={})=>{ if(!isPlainObj(opts)){ throw new TypeError(`Options must be a plain object: ${opts}`) } const{fetch:fetchOpt,...fetchNodeOpts}=opts; validateFetch(fetchOpt); return{fetchOpt,fetchNodeOpts} }; const validateFetch=(fetchOpt)=>{ if(fetchOpt!==undefined&&typeof fetchOpt!=="boolean"){ throw new TypeError(`Option "fetch" must be a boolean: ${fetchOpt}`) } };