test-openapi
Version:
Automated client requests
37 lines (28 loc) • 961 B
JavaScript
Object.defineProperty(exports,"__esModule",{value:true});exports.reduceAsync=void 0;var _promise=require("./promise.js");
const reduceAsync=function(
array,
mapFunc,
{prevVal,secondMapFunc,stopFunc})
{
return asyncReducer(prevVal,{array,mapFunc,secondMapFunc,stopFunc});
};exports.reduceAsync=reduceAsync;
const asyncReducer=function(prevVal,input){
const{array,mapFunc,stopFunc,index=0}=input;
if(index===array.length){
return prevVal;
}
if(stopFunc!==undefined&&stopFunc(prevVal)){
return prevVal;
}
const nextVal=mapFunc(prevVal,array[index],index,array);
const inputA={...input,index:index+1};
return(0,_promise.promiseThen)(nextVal,applySecondMap.bind(null,prevVal,inputA));
};
const applySecondMap=function(prevVal,input,nextVal){
if(input.secondMapFunc===undefined){
return asyncReducer(nextVal,input);
}
const nextValA=input.secondMapFunc(prevVal,nextVal);
return asyncReducer(nextValA,input);
};
//# sourceMappingURL=reduce.js.map
;