UNPKG

test-openapi

Version:
60 lines (43 loc) 1.23 kB
"use strict";require("core-js/modules/es.array.iterator");require("core-js/modules/es.promise");Object.defineProperty(exports,"__esModule",{value:true});exports.callReporters=void 0;var _process=require("process"); var _util=require("util"); var _result=require("../../utils/result.js"); const callReporters=async function({reporters,type},...args){ const promises=reporters.map((reporter)=> callReporter({reporter,type},...args)); await Promise.all(promises); };exports.callReporters=callReporters; const callReporter=async function( { reporter, reporter:{ options, options:{output}}, type}, ...args) { if(reporter[type]===undefined){ return; } const argsA=getArgs({args,options}); const message=await reporter[type](...argsA); if(message!==undefined){ output.write(message); } if(type==="end"){ await endReporting({output}); } }; const getArgs=function({args,options}){ const[argA,context]=args.map(arg=>(0,_result.result)(arg,{options})); const argsA=[argA,{...context,options}].filter( argB=>argB!==undefined); return argsA; }; const endReporting=async function({output}){ await(0,_util.promisify)(setTimeout)(); if(output===_process.stdout){ return; } output.destroy(); }; //# sourceMappingURL=call.js.map