When using protractor.js,
I am working with functions that utilize promises/defer. For instance:
var myFunc = function(_params) {
var deferred = protractor.promise.defer();
/***do some magic code***/
/****wait for other promises****/
/*****deferred.fulfill();*****/
return deferred.promise;
};
Is there a specific way, besides typeof
statements, to determine if this function (when passed elsewhere) involves promises?
typeof promiseMaybe === 'function'
typeof promiseMaybe.then === 'function'
&&
combined with the previous statement?
Alternatively, is there a different method rather than typeof
, such as...
promiseMaybe.isThenable
protractor.promise.isThenable(promiseMaybe)
A Clear Explanation
I have a function that will accept myFunc
as an argument, but it may also receive strings and finders. How can I determine if a parameter represents a function that involves promising something, potentially before invoking the function?