@ace-util/core
Version:
Utils.
16 lines • 456 B
JavaScript
/**
* check if a value is a promise
*/
export function isPromise(obj) {
return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
}
/**
* transform a value to a promise
*/
export function promisify(promise) {
if (promise && promise instanceof Promise && typeof promise.then === 'function') {
return promise;
}
return Promise.resolve(promise);
}
//# sourceMappingURL=promise.js.map