function thennable (ref, cb, ec, cn) {
    if ((typeof val === 'object' || typeof val === 'function') && typeof ref === 'function') {
      try {
        // cnt protects against abuse calls from spec checker
        var cnt = 0;
        ref.call(val, function(v) {
          if (cnt++) {
            return;
          }

          val = v;

          cb();
        }, function(v) {
          if (cnt++) {
            return;
          }

          val = v;

          ec();
        })
      } catch (e) {
        val = e;

        ec();
      }
    } else {
      cn();
    }
  }
// cb, ec, cn: successCallback, failureCallback, notThennableCallback
cb, ec, cn: successCallback, failureCallback, notThennableCallback
cb ec cn : successCallback failureCallback notThennableCallback
function thennable (ref, cb, ec, cn) {
    if ((typeof val === 'object' || typeof val === 'function') && typeof ref === 'function') {
      try {
        var cnt = 0;
        ref.call(val, function(v) {
          if (cnt++) {
            return;
          }
          val = v;
          cb();
        }, function(v) {
          if (cnt++) {
            return;
          }
          val = v;
          ec();
        })
      } catch (e) {
        val = e;
        ec();
      }
    } else {
      cn();
    }
  }
function thennable ( ref , cb , ec , cn ) { if ( ( typeof val === 'object' || typeof val === 'function' ) && typeof ref === 'function' ) { try { var cnt = 0 ; ref . call ( val , function ( v ) { if ( cnt ++ ) { return ; } val = v ; cb ( ) ; } , function ( v ) { if ( cnt ++ ) { return ; } val = v ; ec ( ) ; } ) } catch ( e ) { val = e ; ec ( ) ; } } else { cn ( ) ; } }
cb, ec, cn: successCallback, failureCallback, notThennableCallback
cb ec cn : successCallback failureCallback notThennableCallback
// cnt protects against abuse calls from spec checker