can.isPromise

  • function
 

Check if an object is a Promise.

can.isPromise(subject)

Parameters

  1. subject {*}

    The object to check.

Returns

{Boolean}

Whether subject is a Promise.

can.isPromise returns if an object has the methods expected of a Promise object.

Example

Convert any value to a Promise:

function convertPromise(prm) {
    return can.isPromise(prm) 
        ? prm 
        : new Promise(function(resolve) { resolve(prm) });
}