function promiseFinally(promise, finalBlock) {
    return promise
      .then(function(result) {
        return Promise.resolve(finalBlock())
          .then(function() {
            return result;
          });
      }, function(err) {
        return Promise.resolve(finalBlock())
          .then(function() {
            throw err;
          });
      });
  }
// whether it fulfills or rejects.
whether it fulfills or rejects.
whether it fulfills or rejects .
function promiseFinally(promise, finalBlock) {
    return promise
      .then(function(result) {
        return Promise.resolve(finalBlock())
          .then(function() {
            return result;
          });
      }, function(err) {
        return Promise.resolve(finalBlock())
          .then(function() {
            throw err;
          });
      });
  }
function promiseFinally ( promise , finalBlock ) { return promise . then ( function ( result ) { return Promise . resolve ( finalBlock ( ) ) . then ( function ( ) { return result ; } ) ; } , function ( err ) { return Promise . resolve ( finalBlock ( ) ) . then ( function ( ) { throw err ; } ) ; } ) ; }
whether it fulfills or rejects.
whether it fulfills or rejects .