Check if an object is a Promise
function isPromise(object){ | |
if(Promise && Promise.resolve){ | |
return Promise.resolve(object) == object; | |
}else{ | |
throw "Promise not supported in your environment" | |
} | |
} | |
var i = 1; | |
var p = new Promise(function(resolve,reject){ | |
resolve() | |
}); | |
isPromise(i) // false | |
isPromise(p) // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment