src/angular-websocket.js
function cancelableify(promise) {
      promise.cancel = cancel;
      var then = promise.then;
      promise.then = function() {
        var newPromise = then.apply(this, arguments);
        return cancelableify(newPromise);
      };
      return promise;
    }
function cancelableify(promise) {
      promise.cancel = cancel;
      var then = promise.then;
      promise.then = function() {
        var newPromise = then.apply(this, arguments);
        return cancelableify(newPromise);
      };
      return promise;
    }
function cancelableify ( promise ) { promise . cancel = cancel ; var then = promise . then ; promise . then = function ( ) { var newPromise = then . apply ( this , arguments ) ; return cancelableify ( newPromise ) ; } ; return promise ; }
Credit goes to @btford
Credit goes to