Description
jaubourg states at http://bugs.jquery.com/ticket/14293#comment:2:
As for determining if an object is a promise... you test for the presence of a method called promise and call it to get the actual promise
The presence of the .promise method on the promise object is currently not documented.
It is missing in two places. One place is http://api.jquery.com/deferred.promise which currently states:
The Promise exposes only the Deferred methods needed to attach additional handlers or determine the state (then, done, fail, always, pipe, progress, and state),...
The list of methods should include the promise method (and should not include the deprecated pipe method) and thus should be:
The Promise exposes only the Deferred methods needed to attach additional handlers or determine the state (then, done, fail, always, progress, state and promise),...
It would also be very helpful if http://api.jquery.com/deferred.promise documents the fact that one can/should determine if an object is a promise by testing for the presence of the promise method, as jaubourg described. For example:
To test if an object is a promise, you test for the presence of a method called promise.
Another place is http://api.jquery.com/Types/#Promise which currently states:
This object provides a subset of the methods of the Deferred object (then, done, fail, always, pipe. isResolved, and isRejected) to...
The list of methods should include the promise method. Additionally, the list currently includes deprecated methods. Instead, it should say:
This object provides a subset of the methods of the Deferred object (then, done, fail, always, progress, state and promise) to...