function cancelable(promise) {
  let canceled = false;

  const wrappedPromise = new Promise((resolve, reject) => {
    promise.then(
      value => (canceled ? reject({ isCanceled: true }) : resolve(value)),
      error => (canceled ? reject({ isCanceled: true }) : reject(error)),
    );
  });

  wrappedPromise.cancel = function() {
    canceled = true;
  };

  return wrappedPromise;
}
// return a promise wrapping the provided one but with a "cancel" method
return a promise wrapping the provided one but with a "cancel" method
return a promise wrapping the provided one but with a " cancel " method
function cancelable(promise) {
  let canceled = false;
  const wrappedPromise = new Promise((resolve, reject) => {
    promise.then(
      value => (canceled ? reject({ isCanceled: true }) : resolve(value)),
      error => (canceled ? reject({ isCanceled: true }) : reject(error)),
    );
  });
  wrappedPromise.cancel = function() {
    canceled = true;
  };
  return wrappedPromise;
}
function cancelable ( promise ) { let canceled = false ; const wrappedPromise = new Promise ( ( resolve , reject ) => { promise . then ( value => ( canceled ? reject ( { isCanceled : true } ) : resolve ( value ) ) , error => ( canceled ? reject ( { isCanceled : true } ) : reject ( error ) ) , ) ; } ) ; wrappedPromise . cancel = function ( ) { canceled = true ; } ; return wrappedPromise ; }
return a promise wrapping the provided one but with a "cancel" method
return a promise wrapping the provided one but with a " cancel " method