// Calls a function in the middle of a promise chain without effecting the chain
export function promiseFinally(promise, callback) {
  const p = promise.constructor;

  return promise.then(
    value => p.resolve(callback()).then(() => value),
    reason => p.resolve(callback()).then(() => {throw reason;})
  );
}
