archive/v.js
function processBranch (args, resolve, reject) {
  let condition = args.shift()
  let val = args.shift()
  let las = _.last(args)

  return Promise.resolve(condition)
    .then(c => {
      if (c === true) {
        return Promise.resolve(_.isFunction(val) ? val() : val)
          .then(resolve, reject)
      } else if (args.length === 1) {
        return Promise.resolve(_.isFunction(las) ? las() : las)
          .then(resolve, reject)
      } else {
        return processBranch(args, resolve, reject)
      }
    }, reject)
}
function processBranch (args, resolve, reject) {
  let condition = args.shift()
  let val = args.shift()
  let las = _.last(args)

  return Promise.resolve(condition)
    .then(c => {
      if (c === true) {
        return Promise.resolve(_.isFunction(val) ? val() : val)
          .then(resolve, reject)
      } else if (args.length === 1) {
        return Promise.resolve(_.isFunction(las) ? las() : las)
          .then(resolve, reject)
      } else {
        return processBranch(args, resolve, reject)
      }
    }, reject)
}
function processBranch ( args , resolve , reject ) { let condition = args . shift ( ) let val = args . shift ( ) let las = _ . last ( args ) return Promise . resolve ( condition ) . then ( c => { if ( c === true ) { return Promise . resolve ( _ . isFunction ( val ) ? val ( ) : val ) . then ( resolve , reject ) } else if ( args . length === 1 ) { return Promise . resolve ( _ . isFunction ( las ) ? las ( ) : las ) . then ( resolve , reject ) } else { return processBranch ( args , resolve , reject ) } } , reject ) }
recursively processes the branch statements
@param args
@param resolve
@param reject
@return {*|Promise.<*>|Promise.<TResult>}
recursively processes the branch statements