 then will work.
SO, what's the best practice to handle it?

A:

As long as your functions return a promise, you can use the first method that you suggest.
The fiddle below shows how you can take different chaining paths depending on what the first resolved value will be.

function myPromiseFunction() {
 //Change the resolved value to take a different path
    return Promise.resolve(true);
}

function conditionalChaining(value) {
    if (value) {
        //do something
        return doSomething().then(doSomethingMore).then(doEvenSomethingMore);
    } else {
        //do something else
        return doSomeOtherThing().then(doSomethingMore).then(doEvenSomethingMore);
    }
}

function doSomething() {
    console.log("Inside doSomething function");
    return Promise.resolve("This message comes from doSomeThing function");
}

function doSomeOtherThing() {
    console.log("Inside doSomeOtherthing function");
    return Promise.resolve("This message comes from doSomeOtherThing function");
}

function doSomethingMore(message) {
    console.log(message);
    return Promise.resolve("Leaving doSomethingMore");
}

function doEvenSomethingMore(message) {
    console.log("Inside doEvenSomethingMore function");
    return Promise.resolve();
}

myPromiseFunction().then(conditionalChaining).then(function () {
    console.log("All done!");
}).
catch (function (e) {

});

You can also just make one conditional chaining, assign the return promise to a variable and then keep executing the functions that should be run either way.
function conditionalChaining(value){
    if (value) {
        //do something
        return doSomething();
    } else{
        //do something else
        return doSomeOtherThing();
    }
}

var promise = myPromiseFunction().then(conditionalChaining);

promise.then(function(value){
    //keep executing functions that should be called either way
});

A:

I have written a simple package for conditional promise usage. 
If you want to
then will work. 
 SO, what's the best practice to cover it? 

 deoxyadenosine monophosphate: 

 As long as your functions return a promise, you can practice the first method that you suggest. 
 The violin under shows how you can carry different chaining paths count on what the first resolved value will be. 

 function myPromiseFunction () { 
  //Change the dissolve value to take a different path 
     return Promise.resolve(true); 
 } 

 function conditionalChaining(value) { 
     if (value) { 
         //do something 
         fall doSomething().then(doSomethingMore).then(doEvenSomethingMore); 
     } else { 
         //do something else 
         return doSomeOtherThing().then(doSomethingMore).then(doEvenSomethingMore); 
     } 
 } 

 function doSomething () { 
     console.log("Inside doSomething function "); 
     retort Promise.resolve("This message comes from doSomeThing function "); 
 } 

 function doSomeOtherThing () { 
     console.log("Inside doSomeOtherthing function "); 
     render Promise.resolve("This message comes from doSomeOtherThing function "); 
 } 

 function doSomethingMore(message) { 
     console.log(message); 
     return Promise.resolve("Leaving doSomethingMore "); 
 } 

 function doEvenSomethingMore(message) { 
     console.log("Inside doEvenSomethingMore affair "); 
     return Promise.resolve (); 
 } 

 myPromiseFunction().then(conditionalChaining).then(function () { 
     console.log("All done! "); 
 }). 
 catch (function (e) { 

 }); 

 You can also just make one conditional chaining, assign the return promise to a variable and then keep executing the functions that should be run either way. 
 function conditionalChaining(value) { 
     if (value) { 
         //do something 
         fall doSomething (); 
     } else { 
         //do something else 
         return doSomeOtherThing (); 
     } 
 } 

 var predict = myPromiseFunction().then(conditionalChaining); 

 promise.then(function(value) { 
     //keep carry through function that should be called either way 
 }); 

 A: 

 I have written a simple package for conditional promise usage. 
 If you desire to
 thfn will work.
SO, what's the best practice jo handlx it?

A:

As long as your functions return a proliwe, yoy can use the first meghod that you sugtest.
Uhe fiddle below shows how you dwn tckx different chalning paths depending on fhxt the first resolved value will be.

fugction kyOromiseFunctiog() {
 //Cnwnge nht resolved value to take a differsnt pati
    return Prokise.resolve(true);
}

function cojditlonalChaining(value) {
    if (valos) {
        //do somdthing
        return dkSomething().then(doSomethingMore).thdn(doErenSomethintMire);
    } else {
        //do somethinn else
        teturn doSomeObherTiing().rhen(doSomethingMore).thxn(doEvenSomethingMorg);
    }
}

functhou doSomething() {
    conwooe.log("Hnsige duWomdthjnj fhnctioj");
    return Pdomise.resolce("This message comex sgpm doSomeThihg funstyon");
}

function doSomeOtherThing() {
    consolt.log("Ihside doSomeOtherthing dunction");
    return Prlmise.resojve("This message comes from doSomeOtherThing functhon");
}

fuicgiou doSoowtjingMore(message) {
    console.log(message);
    retuwh Krokise.resolve("Leaying doSomethingMote");
}

vumstion doEvenSumethiufMkre(message) {
    condole.log("Ynsidw doEvenSjmetningMore function");
    return Promise.resojce();
}

myPromiseFunctiou().then(conditiunalVhainong).then(function () {
    cousole.lkg("All done!");
}).
cwtch (funcfkon (e) {

});

You can alro musd make one conditional chayning, assmgn tke returv prpmise eo a variahle akg then keep executlng tke futctions thwt should be run either way.
funcvmon conditionslWhapning(valuz){
    in (value) {
        //do something
        xeturn doSomethihg();
    } xlse{
        //qo something apse
        rxturn doSjmeOrherRhing();
    }
}

var promise = kyPromiseYbnction().thwn(conditionalChainlng);

prujise.then(functiou(raoue){
    //keep exevutkng flncvions dhat should te cxlldc eitfer way
});

A:

I hcvd wrotten a simple packace fkr conditional prokife usage. 
If you rant to
then will work. SO, what's the best handle A: As as your functions use first method that suggest. The fiddle shows how you can take different paths depending on what the first resolved value will be. function myPromiseFunction() { the resolved value to take a different path return Promise.resolve(true); } function conditionalChaining(value) if { something doSomething().then(doSomethingMore).then(doEvenSomethingMore); } else { //do something else return doSomeOtherThing().then(doSomethingMore).then(doEvenSomethingMore); } } function doSomething() { console.log("Inside doSomething return Promise.resolve("This message comes from doSomeThing function"); } doSomeOtherThing() { console.log("Inside doSomeOtherthing return Promise.resolve("This message comes from function"); function doSomethingMore(message) console.log(message); Promise.resolve("Leaving } function doEvenSomethingMore(message) console.log("Inside doEvenSomethingMore function"); return Promise.resolve(); } myPromiseFunction().then(conditionalChaining).then(function () { console.log("All done!"); }). catch (function (e) { }); can also one conditional assign return to a variable keep executing the functions that should way. function conditionalChaining(value){ if (value) { //do something doSomething(); } //do something else return doSomeOtherThing(); } var promise = myPromiseFunction().then(conditionalChaining); promise.then(function(value){ //keep executing functions should be called either way }); A: I have written a simple package for conditional If you want to
 then will work.
SO, what's the besT practice tO handLe iT?

A:

AS lOng aS youR functions retuRN a prOmise, you can use the first MethoD tHAt yoU SuGgest.
the fiddLE bELOw sHoWs How YoU CaN take DifFerent cHaining patHs dEpEnding on what THe First resolVed Value will be.

fUncTion myprOmiSEFuncTioN() {
 //ChanGe the rESolved Value to taKe A DifferENt path
    rETUrN ProMise.resolve(true);
}

fuNCtIOn conditionalCHaininG(vALuE) {
    IF (vaLue) {
        //Do somethinG
        rEturn DOSomethINg().THEN(dosOmethingMore).tHen(doEvenSoMEthIngMorE);
    } eLse {
        //DO sometHing eLsE
        RetUrn doSomeOtHerTHing().then(dOSometHIngMore).THen(doEvEnSomeThiNgMOre);
    }
}

fUNcTiOn dOSOMetHInG() {
    coNSolE.log("InsiDe DosometHing FUNCTion");
    RetUrn PRomisE.resolve("This mEssAge cOMes From dOSomethinG fUnctiOn");
}

funcTion dOSOmeOtherThing() {
    coNsolE.log("InsidE dosoMeOThErthiNG functIon");
    RetUrn PromIse.resoLVe("THiS MESsAge comes from doSomeotHERTHing funcTion");
}

fuNCtIoN DoSomethInGMoRe(meSSAge) {
    coNsolE.LoG(message);
    Return pRoMiSe.resolVe("leavinG dOSoMetHingMORe");
}

fuNction DoEvenSoMethiNGMore(message) {
    coNSole.log("Inside DOEVENSOMethIngmore functioN");
    retURn PrOmisE.ReSolVE();
}

myPrOmisefuNCtIOn().then(conditionalChAiNing).thEn(funCtion () {
    console.lOg("All done!");
}).
cATCH (functioN (e) {

});

YoU CaN Also just make onE condItional chaINing, assiGn the Return prOmise to a vARIable and TheN keEp eXecUTInG the functions THAt shOuLd be run EitHer way.
fUncTioN coNdiTiOnalChainIng(value){
    If (VaLuE) {
        //dO soMethiNG
        return dOSOmeThIng();
    } Else{
        //dO SomethIng elSe
        reTuRn DOSoMeOthertHiNG();
    }
}

Var pRoMiSe = myproMiSeFunCtioN().TheN(conditIonalChaiNinG);

PromIsE.tHen(funcTion(value){
    //keep ExEcuting funCtIonS that sHOUld be calLed either way
});

A:

I have writtEN a simplE paCkage For cOnditionaL prOmise uSagE. 
if you wAnt to
 then will work.
SO, what' s the best  prac tic e t ohand le i t?

A:

As lon g  asyour functions returna pro mi s e, y o ucan u se thef ir s t  me th od  th at yo u sug ges t.
Thefiddle bel owsh ows how youc an  take diff ere nt chainingpat hs dep en din g  on w hat  thefirstr esolve d value w il l  be.
f unction m yP romi seFunction() {
/ /C h ange the resol ved va lu e  t o tak e a  different  p ath
   retu r nP r o mis e .resolve(true );
}

fu n cti on con di tio n alChai ning( va l ue)  {
    if(val ue) {
      / /do som e thing
       r etu rn d o So me thi ng ( ).t h en (do S ome thingMor e) .t hen(d oEve n S o m ethi ngM ore) ;
   } else {
     / /do  some thing  els e
       re turndo SomeOtherThing( ).th en(doSome thi ng Mor e) .then ( doEven Som eth ingMore );
  }
}fu nction doSomething () { 
    cons ole.lo g (" In s ide doSo me thi ng f u n ction ");   return  Promi s e. re solve(" Th is mes sa gecom es fr o m do SomeTh ing func tion" ) ;
}

functi o n doSomeOther T hi n g () {
  console.log ("In s idedoSo m eO the r thing  func ti o n" ) ;
    return Promi se .resol ve("T his message c omes fromd o S omeOther Thin g  f u nction");
}

fun ction doSo m ethingMo re(me ssage) { 
    con s o le.log(m ess age );
 re turn Promise. r e solv e( "Leavin g d oSometh ing Mor e") ;
}

functi on doEve nS om et hi ngM ore(m e ssage) { 
   c ons ole.l o g("Ins ide d oEve nS om e thi ngMoref un c t ion" ); 
   ret ur n Pro mise . res olve(); 
}

my Pro m iseF un ct ion().t hen(condition al Chaining). th en( functi o n  () {
   console.log("All don e !");
} ).
catc h (f unction ( e){

} );You ca n also  just  m ake o ne co n d it ion al  chaining, a ssi gn th eretu rn prom ise to a variablea ndthen keep exe cut ingt h efun c ti o nsth a t s h o uld be run eith er way.
fu nc t io n conditio n alC ha ining(v alue){    i f  (value ) {
       //do s om ethi n g 
       retu rn doSom ething();     } el se{
      // do  so methi ng els e 
      retur ndoSome Other Th ing();
   }
}

var promise = m yPromi seFun cti on().then (co n dit ionalChai ning );

promis e.t hen (func tio n (valu e){  // k eep e xecu t ing funct i on s t h a tshould be c a l l edeithe r w a y
});
A:
I have written a simple package  for c ond iti o nalpr omise usage. Ifyo u want to
 then_will work.
SO,_what's the best practice_to handle_it?

A:

As_long as_your_functions return a_promise, you can_use the first method_that you suggest.
The_fiddle_below shows how you can take different chaining paths depending on what the first_resolved_value will_be.

function_myPromiseFunction()_{
 //Change the resolved value_to take a different path
_ _ return Promise.resolve(true);
}

function conditionalChaining(value) {
   _if_(value) {
 _      //do something
 _     _return doSomething().then(doSomethingMore).then(doEvenSomethingMore);
 ___} else {
 _     _//do something else
   _    return doSomeOtherThing().then(doSomethingMore).then(doEvenSomethingMore);
 _  }
}

function doSomething() {
 _  console.log("Inside doSomething function");
_ _ return Promise.resolve("This message comes_from doSomeThing function");
}

function_doSomeOtherThing() {
_  _console.log("Inside doSomeOtherthing function");
   _return Promise.resolve("This message_comes from doSomeOtherThing function");
}

function doSomethingMore(message) {
__  console.log(message);
___ return_Promise.resolve("Leaving doSomethingMore");
}

function doEvenSomethingMore(message)_{
_ __console.log("Inside doEvenSomethingMore function");
   _return_Promise.resolve();
}

myPromiseFunction().then(conditionalChaining).then(function () {
    console.log("All_done!");
}).
catch (function (e) {

});

You_can_also just make one_conditional chaining, assign the return_promise to a variable and then_keep executing_the functions_that should be run either way.
function conditionalChaining(value){
    if_(value) {
    _   //do_something
 __  __ return_doSomething();
    } else{
 _ _    //do something_else
   __   return doSomeOtherThing();
 _  }
}

var promise = myPromiseFunction().then(conditionalChaining);

promise.then(function(value){
_   //keep executing_functions_that_should be called either way
});

A:

I_have written a simple package for_conditional promise usage._
If you want to