var speculation = function speculation (fn) {
  // Don't cancel by default:
  var cancel = (
    arguments.length > 1 &&
    arguments[1] !== undefined
  ) ? arguments[1] : Promise.reject();

  return new Promise(function (resolve, reject) {
    var noop = function noop () {};

    var onCancel = function onCancel (handleCancel) {
      return cancel.then(
        handleCancel,
        // Filter out the expected "not cancelled" rejection:
        noop
      ).catch(function (e) {
        // Reject the speculation if there's a an error in
        // onCancel:
        return reject(e);
      });
    };

    return fn(resolve, reject, onCancel);
  });
};

module.exports = speculation;

@@ -1,12 +1,154 @@
+var noop = function noop () %7B%7D;%0A%0A// HOF Wraps the native Promise API%0A// to add take a shouldCancel promise and add%0A// an onCancel() callback.%0A
 var speculat
@@ -209,17 +209,16 @@
  default
-:
 %0A  var c
@@ -380,45 +380,8 @@
 ) %7B%0A
-    var noop = function noop () %7B%7D;%0A%0A
     
@@ -493,21 +493,13 @@
  // 
-Filter out th
+Ignor
 e ex
@@ -509,23 +509,14 @@
 ted 
-%22not 
 cancel
-led%22
  rej
@@ -521,16 +521,17 @@
 ejection
+s
 :%0A      
@@ -548,109 +548,68 @@
    )
-.catch(function (e) %7B%0A        // Reject the speculation if there's a an
+%0A      // handle onCancel
  error
- in
+s
 %0A      
-  // onCancel:
+.catch(function (e) %7B
 %0A   
@@ -653,23 +653,16 @@
 %7D;%0A%0A    
-return 
 fn(resol

Add comments & cleanup formatting.