code: function thennable (ref, cb, ec, cn) {
        // Promises can be rejected with other promises, which should pass through
        if (state == 2) {
          return 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()
        }
      }
docs: ref : reference to 'then' function cb, ec, cn : successCallback, failureCallback, notThennableCallback